【问题标题】:Can we create pie chart and scatter plot combined using highcharts.js?我们可以使用 highcharts.js 创建饼图和散点图吗?
【发布时间】:2014-06-06 00:12:57
【问题描述】:

这个问题是关于 highcharts 的。我们可以在 highcharts 中创建类似的东西吗?散点图上的饼图?请查看网址https://www.dropbox.com/s/mcmzn0t0hz4s2x7/pieChartScatterPlot.png

【问题讨论】:

    标签: highcharts


    【解决方案1】:

    我会先画一个正常的散点图,然后循环点,在上面放置额外的饼图:

    // initial scatter
    series: [{
        type: 'scatter',
        name: 'Scatter Me',
        data: [3, 2, 1, 3, 4]
    }]
    
    // in load event, loop our scatter series
    // and add a pie chart at each point
    chart: {
        events: {
            load: function(){
                var chart = this;
                $.each(chart.series[0].data, function(i,datap){
                    chart.addSeries({
                        type: 'pie',
                        minSize: 50,
                        size: 50,
                        dataLabels: {enabled: false},
                        data: [Math.random() * 10, Math.random() * 10, Math.random() * 10],
                        center: [datap.plotX-21, datap.plotY-21],
                    }, false);
                });
                chart.redraw();
            }
        }
    }
    

    这是fiddle 及其外观:

    让我摸不着头脑的一件事是,我必须引入 fudge factor 才能使饼图中心与点对齐。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多