ZoomCharts
Back to overview

FacetChart integration example

To integrate FacetChart into your web application, follow these steps:
  1. Extract the library under your web application root folder (e.g. where your index.html is)
  2. Add following code snippet in your html file
    <script src="zoomcharts/zoomcharts.js"></script>
    (where zoomcharts is the name of the folder where you extracted the library)
  3. Alternatively you can include the script from the CDN
    <script src="//cdn.zoomcharts-cloud.com/1/latest/zoomcharts.js"></script>
  4. Add container element in which the chart will be added
    <div id="chart"></div>
  5. Initialize chart:
        <script>
            var t = new FacetChart({
                container: document.getElementById("demo"),
                area: { height: 350 },
                data: {
                    preloaded: {
                        subvalues: [
                            {
                                id: "foo", value: 100, value2: 50, subvalues: [
                                   { id: "foo-1", value: 50, value2: 10 },
                                   { id: "foo-2", value: 50, value2: 5 }
                                ]
                            },
                            { id: "bar", value: 50, value2: 100 },
                            { id: "baz", value: 30, value2: 15 }
                        ]
                    }
                },
                series: [
                    { name: "Foo", data: { field: "value" } },
                    { name: "Bar", data: { field: "value2" } }
                ]
            });
        </script>
    
  6. Follow the instructions on the ZoomCharts dashboard to include the license key in your application.
  7. Congratulations. You have now successfully integrated ZoomCharts into your web application if you can see the same chart as below in the live demo.

Live Demo

Try it on jsFiddle

More Information: