How can i have color axis in bubble chart using Highchart?

大城市里の小女人 提交于 2019-12-13 10:14:35

问题


I need to develop color axis using bubble highchart with [x, y, z] values , for reference https://developers.google.com/chart/interactive/docs/gallery/bubblechart#color-by-numbers

I need to develop above mentioned bubble chart which is developed in google chart to High chart [bubble] .


回答1:


Based on the answer from this topic - stepped-color-shading-in-highcharts-doughnut-chart.

Wrapping bubble's prototype:

var bubbleProto = Highcharts.seriesTypes.bubble.prototype;

  bubbleProto.axisTypes = ['xAxis', 'yAxis', 'colorAxis'];
  bubbleProto.optionalAxis = 'colorAxis';
  bubbleProto.colorKey = 'y';

  Highcharts.wrap(bubbleProto, 'translate', function(proceed) {
    proceed.apply(this, Array.prototype.slice.call(arguments, 1));

    Highcharts.seriesTypes.heatmap.prototype.translateColors.call(this);
  });

Live example and output

http://jsfiddle.net/4y3qgdmn/41/




回答2:


Since Highcharts v7.2.0 you can add coloraxis module and use it for almost all series types:

Highcharts.chart('container', {
    ...,

    colorAxis: {
        minColor: '#c6e48b',
        maxColor: '#196127'
    }
});

Live demo: http://jsfiddle.net/BlackLabel/swL0ngvm/

API Reference: https://api.highcharts.com/highcharts/colorAxis

Blog: https://www.highcharts.com/blog/news/color-coded-data/



来源:https://stackoverflow.com/questions/42534527/how-can-i-have-color-axis-in-bubble-chart-using-highchart

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