0

JSFIDDLE

如何使用jqplot将两个饼图合并为一个饼图

var firstv=30;
            var secondv=40;
            var thirdv=30;
            var name1="giri";
            var name2="shiva";
            var name3="nanda";
    var data =  [[name1, firstv],[name2, secondv],[name3,thirdv]];

var plot1 = jQuery.jqplot('chart1', [data],
        {
            grid: {
                shadow: false,
                background: '#FFFFFF',                                                                                          
            },
            seriesDefaults: {
                // Make this a pie chart.
                renderer: jQuery.jqplot.PieRenderer,
                rendererOptions: {
                    showDataLabels: true,
                    padding: 20,
                    startAngle: 270
                }
            },
            legend: {
                show: true,
                location: 'e',
                fontSize: 11,
                marginTop: 10,                                
            }
        });
4

1 回答 1

1

仍然不确定你在追求什么,但猜测一下。

鉴于此数据:

var firstv=10;
var secondv=20;
var thirdv=70;
var name1="ram";
var name2="kumar";
var name3="manju";

var data1 = [[name1, firstv],[name2, secondv],[name3,thirdv]];

和:

var firstv=30;
var secondv=40;
var thirdv=30;
var name1="giri";
var name2="shiva";
var name3="nanda";

var data2 =  [[name1, firstv],[name2, secondv],[name3,thirdv]];

然后将两个数据集合并在一起:

  var plot2 = jQuery.jqplot('chart2', [$.merge(data,data2)], //using jquery to merge the two datasets
  {
      grid: {
          shadow: false,
          background: '#FFFFFF',                                                                                          
      },
      seriesDefaults: {
          // Make this a pie chart.
          renderer: jQuery.jqplot.PieRenderer,
          rendererOptions: {
              showDataLabels: true,
              padding: 20,
              startAngle: 270
          }
      },
      legend: {
          show: true,
          location: 'e',
          fontSize: 11,
          marginTop: 10,                                
      }
  });

产生:

在此处输入图像描述

于 2012-09-19T00:09:47.603 回答