繁体   English   中英

带有HighChart的不同事物数据的饼图

[英]Pie Chart for Data on Different Things with HighChart

我正在使用HichChart的饼图来显示有关不同学生的报告的数据-此图表分为以下部分:

  • 积极数据。
  • 负数数据。

我已经为单个学生完美地工作了,但是当我在某人的积极领域内时又出现问题,然后我紧紧抓住另一名学生-饼图使用了积极方面的颜色(而且我不记得要告诉它这样做这个)。 主要的问题是,当我处于钻探阶段时,我必须返回,否则它将以不同的颜色加载不同的数据。

这是我的代码:

<div id="ChartContainer" style="width: 600px; height: 400px; margin: 0 auto"></div>

$(function(){
    HighCharts.chart('ChartContainer', {
        chat: {
            type: 'pie'
        },
        title: {
            text: 'Positive: 426 / Need Work: 28'
        },
        plotOptions: {
            pie: {
                size: 250,
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    color: '#000000',
                    connectorColor: '#000000',
                    formatter: function() {
                        return '<b>' + this.point.name + '</b>: ' + this.percentage + '%';
                    }
                }
            }
        },
        tooltip: {
            formatter: function() {
                return '<b>' + this.point.name + '</b>: ' + this.percentage + '%';
            }
        },
        series: [{
            data: [{
                name: 'Positive',
                y: 4,
                color:'#00ff00',
                drilldown: 'Posit'
            }, {
                name: 'Negative',
                y: 4,
                color: '#ff7a0f',
                drilldown: 'Negit'
            }, ]
        }],
        drilldown: {
            series: [{
                color: 'green',
                id: 'Posit',
                data: [
                    {name:'one', y:4, color: 'Red'},
                    ['two', 2],
                    ['three', 1],
                    ['four', 2],
                    ['five', 1]
                ]

            }, {
                 color: 'Blue',
                id: 'Negit',
                data: [
                    {name:'one', y:4, color: 'Blue'},
                    ['Seven', 4],
                    ['Eight', 2],
                    ['Nine', 3]
                ]

            }

           ]
        }
    });
});

您会忘记在脚本标记中包含https://code.highcharts.com/modules/drilldown.js ,它应该在index.html中引用。 您的价值将转换为百分比。 是的,它显示了不同的值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM