Back

Pie chart - donut chart, flat theme, hierarchical structure

Latvian car market composition as of 1st of January, 2013. Source: csdd.lv

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
let pc = new PieChart({
    container: document.getElementById("demo"),
    data: { url: "https://cpapi.zoomcharts.com/csdd/api/api.php?request=top&mode=json&sequence=mark-model-year&category=b" },
    info: {
        contentsFunction: function (data) {
            return "" + data.name + " " + data.value + " units";
        }
    },
    theme: PieChart.themes.flat,
    slice: {
        styleFunction: function (slice, data) {
            var logos = { 'maz': 1, 'audi': 1, 'hyundai': 1, 'citroen': 1, 'yamaha': 1, 'kia': 1, 'lexus': 1, 'mercedes-benz': 1, 'honda': 1, 'chrysler': 1, 'dacia': 1, 'lada': 1, 'vw': 1, 'iveco': 1, 'škoda': 1, 'renault': 1, 'bmw': 1, 'chevrolet': 1, 'vaz': 1, 'daf': 1, 'suzuki': 1, 'saab': 1, 'seat': 1, 'kawasaki': 1, 'nissan': 1, 'mazda': 1, 'scania': 1, 'dodge': 1, 'aprilia': 1, 'opel': 1, 'land-rover': 1, 'peugeot': 1, 'mitsubishi': 1, 'volvo': 1, 'fiat': 1, 'jeep': 1, 'alfa-romeo': 1, 'ford': 1, 'toyota': 1, 'subaru': 1, 'man': 1 };
            var r = /mark=([^@]+)$/;
            var m;
            if (data.id && (m = data.id.match(r))) {
                mark = m[1].toLowerCase();
                mark = mark.replace(' ', '-');
                if (logos[mark]) {
                    slice.icon = '/templates/default/demo/csdd/' + mark + '.png';
                }
            }
            
            slice.label.text = data.name + " " + slice.percent.toFixed(1) + "%";
        }
    },
    interaction: { resizing: { enabled: false } }
});

Data

Data
//No separate data for this example