To do that, we can click on the "Charts & Maps" item in WP admin menu, then select "+ Pie". It might be easier to start from a working Pie chart, then just modify it’s code. thus preserving the uniqueness and avoiding any potential id conflicts. When displaying the chart, the plugin will replace it with something unique like "amchart1" for each instance on the same page.įor example if you have three charts on the same page, the first one will replace all occurrences of "$CHART$" to "amchart1", the second to "amchart2", etc. You are encouraged to use this code whenever you want some uniqueness. Var series = (new am4charts.PieSeries()) In this callback function, you can add data into the existing data array as usual, but you dont need to call the update function as it is called internally. Var chart = am4core.create("$CHART$", am4charts.PieChart) To enable this, the plugin provides two options: onRefresh which is the callback function that is called at a regular interval to check the data source and refresh which specifies the interval. Most of the amCharts-enabled charts or maps start with a call of am4core.create() function call.įor example the following code creates a fully functional Pie chart: // Create chart instance It contains the actual JavaScript code for the chart or map. JavaScript box is where all the magic happens. Resource box needs to show either relative or absolute path, with the latter being recommended. Maps require core.js and maps.js, as well as a map definition file, such as worldLow.js. Depending on your requirements, it may need additional files, such as plugins, themes, or map definition files (geodata). All amCharts instances require the core.js and charts.js files. Resources box holds all the JavaScript and CSS files you will need for this chart. Naming your chart with something like "Chart 1" is not as descriptive as "Pie chart for expenditures by department for 2019". Make it something meaningful, so that when you have a lot of charts, you exactly know what it does. The "Title" field is the same field you have for all of the WP posts, pages and other content types. You’ll get a familiar post edit interface with a few additional fields. To create a new chart or a map we click "Add New" under "Charts & Maps" in WP admin. You can either use a default template or start from scratch. There are several ways to create a chart or map. Edit default code templates for each chart type.(it loads those files directly from amCharts CDN servers by default) Set the location from where to load amCharts files. Most of the users might skip this, and dive right in. If you’d like to tinker with the config, you’ll find it under Settings > Charts & Maps. The plugin comes with 100% usable default configuration. Make sure you click "Activate" when the button pops up instead of "Install Now".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |