在Highcharts中为每个酒吧添加不同的名字 [英] put different names to each bar in Highcharts

查看:120
本文介绍了在Highcharts中为每个酒吧添加不同的名字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何重命名每个栏,我想拥有不同的名字。总是出现bar1,bar2等,这是该系列的名称。但我希望它出现在这些文本的位置,我想要自定义的其他文本。这就是我所做的。把不同的名字,如果有9个酒吧,我想把不同的名字,以bar1,bar2,bar3,bar4,bar5,bar6,bar7,bar8,bar9。我不想在我的例子中重复



 系列:[{
名称:'bar1',
数据:[1000,950,920,0,850],
颜色:#FF0000
},{
名称:'bar2',
数据:[800,770,750,0,730],
颜色:# 000000

,{
名称:'bar3',
数据:[600,540,535,500,30],
颜色:#00FF00


{
名称:'bar4',
数据:[28,28,28,28,28],
颜色: #00FF00

}]

http://jsfiddle.net/05L1n3wb/

解决方案

这是通过将 name:'bar1'更改为你想要的东西来完成的。如果你仍然需要 series.name 作为'bar1',那么你应该更加认真地考虑你的数据模型。如果要根据 series.name 的内容更改显示的文本,可以使用标签格式化程序或dataLabel格式化程序来完成。


How I can rename each bar, I want to have different names. always it appears "bar1", "bar2", etc. this is the name of the series. but I want it to appear in place of those texts, others I want to customize. this is what I do. put different names, if there are 9 bars I want to put different names to the bars, bar1, bar2, bar3, Bar4, Bar5, Bar6, Bar7, Bar8, Bar9. I do not want to repeat in my example.

series: [{
  name: 'bar1',
  data: [1000, 950, 920, 0, 850],
  color: "#FF0000"
}, {
  name: 'bar2',
  data: [800, 770, 750, 0, 730],
  color: "#000000"

}, {
  name: 'bar3',
  data: [600, 540, 535, 500, 30],
  color: "#00FF00"

},
 {
  name: 'bar4',
  data: [28, 28, 28, 28, 28],
  color: "#00FF00"

}]

http://jsfiddle.net/05L1n3wb/

解决方案

This is done by changing name: 'bar1' to something you want. If you still need series.name to be 'bar1' then you should really think harder about your data model. If you want to change the text displayed based on the contents of series.name you can do that with the label formatter or dataLabel formatter.

这篇关于在Highcharts中为每个酒吧添加不同的名字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆