2014-07-21 48 views
1

我有一个图表显示收到1 - 5(1星级,2星级等)的项目收到的数量,但我无法让它正确显示图表。这是我来得到它显示最接近:Highcharts相同类型的数据与不同系列

$('#chartdiv').highcharts({ 
    chart: { 
     type: "column" 
    }, 
    title: { 
     text: 'My Ads' 
    }, 
    xAxis: { 
     categories: ["1 Star", "2 Stars", "3 Stars", "4 Stars", "5 Stars"], 
     tickInterval: 1, 
     labels: { 
      rotation: -20, 
      style: { 
       fontSize: '13px', 
       fontFamily: 'Verdana, sans-serif' 
      } 
     } 
    }, 
    yAxis: { 
     "min": 0, 
     "title": { 
      "text": "Number of Ratings" 
     } 
    }, 
    series: [{ 
     "name": "1 Stars", 
     "data": [10] 
    }, { 
     "name": "2 Stars", 
     "data": [42] 
    }, { 
     "name": "3 Stars", 
     "data": [60] 
    }, { 
     "name": "4 Stars", 
     "data": [110] 
    }, { 
     "name": "5 Stars", 
     "data": [100] 
    }], 
    tooltip: { 
     //shared: true, 
     crosshairs: false 
    }, 
    series: series, 
}); 

,这里是什么样子:

Output

我怎样才能得到它像她那样,但有都标签?我一直在使用这样的数据集也试过:

[{ 
    "data": [10, 0, 0, 0, 0] 
}, { 
    "data": [0, 42, 0, 0, 0] 
}, { 
    "data": [0, 0, 60, 0, 0] 
}, { 
    "data": [0, 0, 0, 110, 0] 
}, { 
    "data": [0, 0, 0, 0, 100] 
}], 

,这让我这个输出

Graph 2

那些被间隔太远,所以基本上我怎么能得到这个显示像第一个图像,但每个数据集中只有一个项目?

------------
UPDATE:
------------

该系列为我工作。我唯一的问题是它在工具提示中说Series 1: 10(图像有点模糊,抱歉)。

Graph 3

"series": [{ 
     "data": [{ 
       "name": "1 Star", 
       "y": 10 
      }, { 
       "name": "2 Stars", 
       "y": 42 
      }, { 
       "name": "3 Stars", 
       "y": 60 
      }, { 
       "name": "4 Stars", 
       "y": 110 
      }, { 
       "name": "5 Stars", 
       "y": 100 
      }] 
    }], 
+1

'唯一的问题是它说的系列1:10在工具提示中 - 你想说什么? – Mark

+0

工具提示中应该包含哪些值? –

回答

1

您可以尝试使用这些设置(尝试用pointWidth玩 - 列的宽度)

 plotOptions: { 
      series: { 
       pointPadding: 0.2, 
       groupPadding: 0, 
       pointWidth: 50//width of the column 
      }, 
      column: { 
         pointPadding: 0, 
         borderWidth: 0 
        } 
     }, 
    tooltip: { 
     formatter: function() { 
     return 'The value for <b>' + this.x + '</b> is <b>'+ '</b>, in series '+ this.series.name; 
    } 

更新 - 我已经添加了自定义提示

+0

我已更新我的问题,请看看 –

+0

@RyanNaddy我已更新我的答案。您需要使用自定义“工具提示”。请再次查看我的代码。 – Oyeme

0

我能够得到我正在寻找使用这个系列的东西:

"series": [{ 
     "name": "Number of Ratings", 
     "data": [{ 
       "name": "1 Star", 
       "y": 10 
      }, { 
       "name": "2 Stars", 
       "y": 42 
      }, { 
       "name": "3 Stars", 
       "y": 60 
      }, { 
       "name": "4 Stars", 
       "y": 110 
      }, { 
       "name": "5 Stars", 
       "y": 100 
      }] 
    }], 
相关问题