Chart from a json field
A chart plugin made with recharts. Works only with JSON Fields
This is the source data for the example image. The Data must have an attribute "name" to identify the X axis elements and the other keys are data items related to named points.
This plugin is an addon so you could create more chart instance on the same field, to change source data, you can specify another json field. The alternative source field must belong to the same record.
in this example we are using a previous json field named "source" as datasource for he chart.
You can personalize lines bars and pies colors passing a string containing a comma separated color list per intance.
for example: '#0088FE,#00C49F,#FFBB28,#FF8042'
Example of Bars Chart
Expample of Pie Chart
1[2 { "name": "Group A", "value": 400 },3 { "name": "Group B", "value": 300 },4 { "name": "Group C", "value": 300 },5 { "name": "Group D", "value": 200 },6 { "name": "Group E", "value": 278 },7 { "name": "Group F", "value": 189 }8]
Install all the project dependencies with:
1yarn install
Add this plugin in development mode to one of your DatoCMS project with:
1yarn addToProject
Start the local development server with:
1yarn start
The plugin will be served from <https://datocms-plugin-chart.localtunnel.me/>. Insert this URL as the plugin Entry point URL.
Before publishing this plugin, make sure:
package.json
following the official rules;cover.png
) and a preview GIF (preview.gif
) into the docs
folder.When everything's ready, just run:
1yarn publish