HighCharts: How to combine custom colors with gradient

十年热恋 提交于 2019-12-24 02:13:15

问题


For some while now Im playing with coloring of my pie chart... And either I got my custom colors without gradient, or default colors with gradient... My colors are stored in php field, which I want to load like colors: <?echo $myColors;?> . Actual state of my code is like this (it shows default colors with gradient):

colors: Highcharts.map(Highcharts.getOptions().colors, function(color) {
    return {
        radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
        stops: [
                [0, color],
                [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
        ]
    };
})

How should I edit it so it would show my own colors in simple way? Also I didn´t find what is "stops" option for...


回答1:


Use your colors in map instead of Highcharts built-in ones:

colors: Highcharts.map(<?echo $myColors;?>, function(color) {
    return {
        radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
        stops: [
                [0, color],
                [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
        ]
    };
})


来源:https://stackoverflow.com/questions/14851418/highcharts-how-to-combine-custom-colors-with-gradient

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