Flot Chart未正确堆叠

时间:2014-08-30 04:29:05

标签: charts flot bar-chart stacked-chart stackedbarseries

我的堆积条形图有这个问题 它没有正确堆叠。

请参阅红色箭头指向的栏 当我尝试单击下方栏时,会选择上方栏。

Stacked Bar Chart

你能帮我吗?

以下是我的数据集:

  

[{" bars" :{" barWidth" :20000,           "填充" :真的,           "的lineWidth" :0,           "为了" :1,           "显示" :是的         },       "数据" :[[50000,             0           ]           [150000,             0           ]           [250000,             0           ]           [350000,             0           ]           [450000,             0           ]           [550000,             0           ]           [650000,             0           ]           [750000,             0           ]           [850000,             0           ]           [950000,             0           ]           [1050000,             0           ]           [1150000,             0           ]           [1250000,             0           ]           [1350000,             0           ]           [1450000,             0           ]           [1550000,             0           ]           [1650000,             0           ]           [1750000,             0           ]           [1850000,             0           ]           [1950000,             0           ]           [2050000,             0           ]           [2150000,             0           ]           [2250000,             0           ]           [2350000,             0           ]           [2450000,             0           ]           [2550000,             0           ]           [2650000,             0           ]           [2750000,             0           ]           [2850000,             0           ]           [2950000,             0           ]           [3050000,             0           ]           [3150000,             0           ]           [3250000,             0           ]           [3350000,             0           ]           [3450000,             0           ]           [3550000,             0           ]           [3650000,             0           ]           [3750000,             0           ]           [3850000,             0           ]           [3950000,             0           ]           [4050000,             0           ]           [4150000,             0           ]           [4250000,             0           ]           [4350000,             0           ]           [4450000,             0           ]           [4550000,             0           ]           [4650000,             0           ]           [4750000,             0           ]           [4850000,             0           ]           [4950000,             0           ]           [5050000,             0           ]           [5150000,             0           ]         ]       "堆" :真的,       " XAXIS" :1},{" bars" :{" barWidth" :20000,           "填充" :真的,           "的lineWidth" :1,           "为了" :2,           "显示" :是的         },       "颜色" :"#0066FF",       "数据" :[[50000,             35           ]           [150000,             41           ]           [250000,             40           ]           [350000,             45           ]           [450000,             50           ]           [550000,             55           ]           [650000,             1           ]           [750000,             2           ]           [850000,             70           ]           [950000,             4           ]           [1050000,             五           ]           [1150000,             6           ]           [1250000,             7           ]           [1350000,             8           ]           [1450000,             9           ]           [1550000,             10           ]           [1650000,             11           ]           [1750000,             12           ]           [1850000,             13           ]           [1950000,             15           ]           [2050000,             三十           ]           [2150000,             29           ]           [2250000,             28           ]           [2350000,             27           ]           [2450000,             26           ]           [2550000,             24           ]           [2650000,             24           ]           [2750000,             23           ]           [2850000,             22           ]           [2950000,             21           ]           [3050000,             20           ]           [3150000,             19           ]           [3250000,             18           ]           [3350000,             17           ]           [3450000,             16           ]         ]       "标签" :"水果",       "堆" :真的,       " XAXIS" :1},{" bars" :{" barWidth" :20000,           "填充" :真的,           "的lineWidth" :1,           "为了" :3,           "显示" :是的         },       "颜色" :"#93CDDD",       "数据" :[[150000,             65           ]           [750000,             32           ]         ]       "标签" :"蔬菜",       "堆" :真的,       " XAXIS" :1},{" bars" :{" barWidth" :20000,           "填充" :真的,           "的lineWidth" :1,           "为了" :4,           "显示" :是的         },       "颜色" :"#0066FF",       "数据" :[[450000,             100           ]           [950000,             50           ]           [1450000,             114           ]           [1550000,             6           ]           [1750000,             44           ]           [1850000,             71           ]           [2550000,             2           ]           [2850000,             71           ]           [2950000,             35           ]           [3250000,             99           ]         ]       "标签" :"动物",       "堆" :真的,       " XAXIS" :1}]

1 个答案:

答案 0 :(得分:1)

这看起来像堆叠插件中的错误。

你的"蔬菜"系列介于你的"水果"和"动物"系列在该位置没有栏(450000)。它导致插件没有堆叠"水果"和"动物"系列,但改为覆盖它们。添加0栏到"蔬菜"该位置的系列解决了问题:

{
    "bars": {
      "barWidth": 20000,
      "fill": true,
      "lineWidth": 1,
      "order": 3,
      "show": true
    },
    "color": "green",
    "data": [
      [150000, 65],
      [450000, 0], // ADDED THIS POINT
      [750000, 32]
    ],
    "label": "Vegetables",
    "stack": true,
    "xaxis": 1
  }

这是一个固定的example。我改变了颜色,以便更好地想象发生了什么。