Back

Custom background image

It is possible to add an image as a background for a PieChart.

Documentation Open in JSFiddle
Start Free Trial Purchase

HTML

HTML
<script src="https://cdn.zoomcharts-cloud.com/1/nightly/zoomcharts.js"></script>

<div id="demo"></div>

CSS

CSS
//No CSS for this example 

JavaScript

JavaScript

    function success(data) {
        var r = { subvalues: [] };
        for (var k in data.subvalues) {
            r.subvalues.push(
                {
                    name: data.subvalues[k][0] + " - " + data.subvalues[k][1],
                    value: data.subvalues[k][2]
                }
            );
        }
        t = new PieChart(
            settings = {
                theme: PieChart.themes.flat,
                container: document.getElementById("demo"),
                data: {
                    preloaded: r,
                    sortField: "value"
                },
                slice: {
                    styleFunction: function (slice, data) {
                        if (data.name) {
                            slice.label.text = data.name + ": " + data.value + " units";
                        }
                    }
                },
                interaction: { resizing: { enabled: false } },
                area: { style: { image: "/dvsl/doc/pie-chart/images/britney.png" } },
                pie: { innerRadius: 0.9 }
            }
        );
    }
    // using a custom library to load CSV data
    loadCSV("/dvsl/data/pie-chart/britney-spears.csv", null, [
            { type: "string", name: "name" },
            { type: "decimal", name: "year" },
            { type: "decimal", name: "units" },
    ], "\t", function (data) {
        success(data);
    });

Data

Data
//Data too large to output
Download Data