简体   繁体   English

Highcharts xAxis多种颜色

[英]Highcharts xAxis multiple colors

I am creating the following Highcharts chart: 我正在创建以下Highcharts图表:

var chart = {
        type: 'scatter',
        zoomType: 'xy',
        backgroundColor: 171515,
    events: {
        selection:function(event){
                var myChart = $('#chartContainer').highcharts();
                if(event.xAxis || event.yAxis){
                    xAxisBool = true;
                    $('#chartContainer').highcharts().xAxis[1].update({
                        visible: false
                    });
                } 
                else{
                    xAxisBool = false;
                    $('#chartContainer').highcharts().xAxis[1].update({
                        visible: true
                    });
                }
            }
        }
    };

var  title = {
    text: '<span style="color: #a85757">discovery</span>'
};

var subtitle = {
    text: '<span style="color: #a85757">Source: VR-Forces</span>'
};

var xAxis = [{
    title: {
        enabled: true,
        text: '<span style="color: #a85757">Heading (Deg)</span>'
    },
    startOnTick: true,
    endOnTick: true,
    showLastLabel: true,
    tickPositions: [-180,-160,-140,-120,-100,-80,-60,-40,-20,0,20,40,60,80,100,120,140,160,180],
    lineColor: '#a85757',
    tickColor: '#FF0000',
    tickWidth: 3,
    labels: {
        style: {
            color: 'white'
        }
    }
},{
    title: {
        enabled: false
    },
    valueDecimals: 1,
    startOnTick: true,
    endOnTick: true,
    ceiling: 360,
    /*lineColor: '#a85757',*/
    tickColor: '#FF0000',
    tickWidth: 3,
    labels: {
        style: {
            color: 'white'
        }
    },
    colors: {
        minColor: '#0b933f',
        maxColor: '#cc1c0f'
    }
}];

var yAxis = {
    title: {
        enabled: true,
        text: '<span style="color: #a85757">Frequency [GHz]</span>'
    },
    allowDecimals: true,
    valueDecimals: 4,
    startOnTick: true,
    endOnTick: true,
    showLastLabel: true,
    ceiling: 20.0000,
    min: 0.0000,
    max: 20.0000,
    tickAmount: 15,
    labels: {
        style: {
            color: 'white'
        }
    }
};

var borderColor = '#696969';

var legend = {
    layout: 'vertical',
    align: 'left',
    verticalAlign: 'top',
    x: 800,
    y: -8,
    floating: true,
    backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#a6a6a6',
    borderWidth: 1
};

var plotOptions = {
    scatter: {
        marker: {
            radius: 5,
            states: {
                hover: {
                    enabled: true,
                    lineColor: 'rgb(100,100,100)'
                }
            }
        },
        states: {
            hover: {
                marker: {
                    enabled: false
                }
            }
        },
        tooltip: {
            headerFormat: '<b>{series.name}</b><br>',
            pointFormat: '{point.id}, {point.x} Deg, {point.y} GHz',
            valueDecimals: 3
        },
        showInLegend: true
    },
    series: {
        cursor: 'pointer',
        events: {
            click: function (e) {
                var id = e.point.id;
                chartSelect(id);
            }
        }
    }
};

var credits = {
    enabled: false        
};

var series = [{
    name: 'firstSeries',
    color: '#ffffff',
    data: [],
    valueDecimals: 4,
    marker: {
        symbol: 'url(./icons/GreenSquare.png)'
    }
    },{
    name: 'secondSeries',
    color: '#ffffff',
    data: [],
    valueDecimals: 4,
    marker: {
        symbol: 'url(./icons/BlueSquare.png)'
    }
}, {
    name: 'thirdSeries',
    color: '#ffffff',
    data: [],
    valueDecimals: 4,
    marker: {
        symbol: 'url(./icons/PurpleSquare.png)'
    }
}];



var chartJson = {};
chartJson.chart = chart;
chartJson.title = title;
chartJson.subtitle = subtitle;
chartJson.xAxis = xAxis;
chartJson.yAxis = yAxis;
chartJson.borderColor = borderColor;
chartJson.legend = legend;
chartJson.plotOptions = plotOptions;
chartJson.credits = credits;
chartJson.series = series;

$('#chartContainer').highcharts(chartJson);

I need to set the second xAxis colors to more then one color. 我需要将第二种xAxis颜色设置为一种以上的颜色。 My second xAxis is dynamically updated. 我的第二个xAxis是动态更新的。 How can I decide on different colors for different values of the line? 如何为线的不同值确定不同的颜色? I need to update those values dynamically. 我需要动态更新这些值。

Thy this example 你这个例子

var chart = $('#container').highcharts();
chart.xAxis[0].update(xAxis);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM