Styled mode pie

author(s): Torstein Hønsi

by Torstein Hønsi

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>

<figure class="highcharts-figure">
    <div id="container"></div>
    <p class="highcharts-description">
        Charts can be styled using CSS, such as this example overriding
        the default styles for a pie chart. This can be done without the
        use of Javascript, allowing designers and developers to better
        collaborate on chart design.
    </p>
</figure>

CSS

@import url("https://code.highcharts.com/css/highcharts.css");

JavaScript

// Data retrieved from https://gs.statcounter.com/vendor-market-share/mobile/
Highcharts.chart('container', {
    chart: {
        styledMode: false,
        type: 'column'
    },
    title: {
        text: 'Mobile vendor market share, 2021'
    },
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },
    plotOptions: {
        series: {
        
            allowPointSelect: true,
            cursor: 'pointer',
            innerSize: '30%',
            depth: 45,
            dataLabels: {
                enabled: false
            },
            showInLegend: true,
            inactiveOtherPoints: true,
            colorByPoint: true
        }
    },
    series: [{
        allowPointSelect: true,
        keys: ['name', 'y', 'selected'],
        data: [
            ['Samsung', 27.79, true],
            ['Apple', 27.34, false],
            ['Xiaomi', 10.87, false],
            ['Huawei', 8.48, false],
            ['Oppo', 5.38, false],
            ['Vivo', 4.17, false],
            ['Realme', 2.57, false],
            ['Unknown', 2.45, false],
            ['Motorola', 2.22, false],
            ['LG', 1.53, false],
            ['Other', 7.2, false]
        ],
        showInLegend: true
    }]
});