Highcharts bar chart with bar colored based on value

删除回忆录丶 提交于 2020-01-07 07:56:15

问题


I am looking for a way to create a bar chart where bars change color from light to dark depending on their value (length) as in following example:


回答1:


Color can be set per point, so you could calculate what color a point should have and set it through data in chart's options.

$(function() {
  var data = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  Highcharts.each(data, function(point, i) {
    data[i] = [point, '#f' + point + '0'];
  });
  $('#container').highcharts({
    series: [{
      type: 'bar',
      data: data,
      keys: ['y', 'color']
    }]
  });
});

JSFiddle: http://jsfiddle.net/w8c8fxju/



来源:https://stackoverflow.com/questions/34092997/highcharts-bar-chart-with-bar-colored-based-on-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!