如何将项目添加到Highcharts图例? [英] How to add an item to Highcharts legend?

查看:95
本文介绍了如何将项目添加到Highcharts图例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含两个系列的图: column spline 。在编程方面,我改变了某些符合某些标准的列的颜色,假设10个最低分数以绿色呈现,其余为蓝色。

I have a graph with two series: column and spline. Programatically I changed the color of some columns that met some criteria, let's say the 10 lowest scores are rendered in green, while the rest is blue.

现在,在图例,我有系列名称,但很明显,它显示了样条系列名称和列系列名称默认的蓝色。例如,我想知道如何为图例添加一个名称,例如以绿色呈现最低分数的列。

Now, in the legend, I have the series names, but it shows, obviously, the spline series name and the column series name in the default blue color. I want to know how to add a name to the legend for the columns that are rendered in green that says "lowest scores" for example.

编辑:

系列代码:

The code for the series:

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'},
    ]
  }
]


推荐答案

我刚刚添加了一个需要的属性(名称和颜色)的空系列,它工作。以防万一你在这种情况下发现自己。

I just added an empty series with the properties needed (name and color) and it worked. Just in case you find yourself in this scenario.

这篇关于如何将项目添加到Highcharts图例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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