如何将项目添加到Highcharts图例?

时间:2012-08-29 20:21:43

标签: javascript highcharts

我有一个包含两个系列的图表:columnspline。以编程方式,我改变了符合某些条件的某些列的颜色,假设10个最低分数以绿色呈现,而其余则为蓝色。

现在,在图例中,我有系列名称,但它显然显示了样条系列名称和默认蓝色的列系列名称。我想知道如何为绿色渲染的列添加名称,例如“最低分”。

编辑:

该系列的代码:

series: [{
  type: 'column',
  color: '#215868',
  name: 'Score per round ',
  data: [
    {y:65,name:'Caracas Country Club', color: '#7EB035'},
    {y:72,name:'Biltmore Golf Course', color: '#7EB035'},
    {y:72,name:'Nashua Country Club', color: '#7EB035'},
    {y:90,name:'Hilaman Park Golf Course'},
    {y:105,name:'Biltmore Golf Course'},
    {y:90,name:'Binks Forest Golf Club', color: '#7EB035'},
    {y:90,name:'Binks Forest Golf Club', color: '#7EB035'},
    {y:90,name:'Blackhawk Country Club | The Falls', color: '#7EB035'},
    {y:90,name:'Blackhawk Country Club | The Falls', color: '#7EB035'},
    {y:72,name:'Pembroke Country Club', color: '#7EB035'},
    {y:90,name:'The Greens At North Hills Country Club'},
    {y:90,name:'Havana Country Club | Kilamanjaro/Kenya'},
    {y:90,name:'Biltmore Golf Course'},
    {y:90,name:'Biltmore Golf Course'},
    {y:90,name:'Challenge At Santa Rita'},
    {y:100,name:'Lake Chabot Golf Course | Lake Chabot'},
    {y:90,name:'Hillcrest Golf & Country Club | Championship', color: '#7EB035'},
    {y:100,name:'Hillcrest Golf & Country Club | Championship'},
    {y:100,name:'Hillcrest Golf & Country Club | Championship'},
    {y:90,name:'Hillcrest Golf & Country Club | Championship', color: '#7EB035'},]
  },
  {
    type: 'spline',
    name: 'Avg Score',
    color: '#009900',
    data: [
      {y:89.9,name:'Caracas Country Club'},
      {y:89.4,name:'Biltmore Golf Course'},
      {y:88.9,name:'Nashua Country Club'},
      {y:88.9,name:'Hilaman Park Golf Course'},
      {y:89.4,name:'Biltmore Golf Course'},
      {y:89.4,name:'Binks Forest Golf Club'},
      {y:89.4,name:'Binks Forest Golf Club'},
      {y:89.4,name:'Blackhawk Country Club | The Falls'},
      {y:89.4,name:'Blackhawk Country Club | The Falls'},
      {y:89.0,name:'Pembroke Country Club'},{y:89.0,name:'The Greens At North Hills Country Club'},
      {y:89.0,name:'Havana Country Club | Kilamanjaro/Kenya'},
      {y:89.1,name:'Biltmore Golf Course'},
      {y:89.1,name:'Biltmore Golf Course'},
      {y:89.1,name:'Challenge At Santa Rita'},
      {y:89.3,name:'Lake Chabot Golf Course | Lake Chabot'},
      {y:89.4,name:'Hillcrest Golf & Country Club | Championship'},
      {y:89.6,name:'Hillcrest Golf & Country Club | Championship'},{y:89.8,name:'Hillcrest Golf & Country Club | Championship'},
      {y:89.8,name:'Hillcrest Golf & Country Club | Championship'},
    ]
  }
]

1 个答案:

答案 0 :(得分:12)

我刚刚添加了一个空系列,其中包含所需的属性(名称和颜色),并且它有效。以防您在这种情况下发现自己。