composer require cmen/google-charts-bundle
Composer will install the bundle in vendor directory.
Enable the bundle in the kernel :
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new CMEN\GoogleChartsBundle\CMENGoogleChartsBundle(),
);
}
If you use Symfony < 4 put the configuration in app/config.yml, otherwise put the configuration in config/packages/cmen_google_charts.yaml.
The latest stable version :
cmen_google_charts:
version: "current"
The next version in development :
cmen_google_charts:
version: "upcoming"
A frozen version :
cmen_google_charts:
version: "45"
See this page for more information.
If you do not configure the bundle, the latest stable version is used.
You can change locale to customize text for a country or language, affecting the formatting of values such as currencies, dates, and numbers. For example, if you want to use french :
cmen_google_charts:
language: "fr"
If you need to set dynamically the locale, you can use gc_language
Twig function in Twig template :
<html>
<head></head>
<body>
<div id="div_histogram"></div>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
{{ gc_language('fr') }}
{{ gc_draw(histogram, 'div_histogram') }}
</script>
</body>
</html>
By default, Google Chart libraries are loaded with the "en" locale.