删除图表上的网格线

Ily*_* Z. 21 highcharts highstock

我有lib HighCharts 的图表,我想在我写的图表上删除yAxis的网格线,gridLineWidth: 0 但网格线没有删除所有代码:

<script type="text/javascript">
(function($){ // encapsulate jQuery

$(function() {
    Highcharts.setOptions({
        lang: {
            rangeSelectorZoom: '??c????',
            rangeSelectorFrom: '??',
            rangeSelectorTo: '??',
            thousandsSep: ' '
        },
        global: {
            useUTC: false
        }
    });

    $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function(data) {
        // Create the chart
        window.chart = new Highcharts.StockChart({
            chart : {
                borderColor: 'white',
                renderTo : <?php echo "cont".$i; ?>,
                backgroundColor: '#f9f9f9' // ??????? ?????? ????? ???
            },

            rangeSelector: {
                buttons: [  
                { 
                    type: 'week', 
                    count: 1, 
                    text: '??????',
                },  
                { 
                    type: 'month', 
                    count: 1, 
                    text: '?????',
                },              
                { 
                    type: 'year', 
                    count: 1, 
                    text: '???'
                },
                {
                    type: 'all',
                    text: '???'
                }],
                inputDateFormat: '%d.%m.%Y', // ?????? ?? ????????? ??? ??? ?????? ???? ? ??????????
                inputEditDateFormat: '%d.%m.%Y',
                buttonTheme: {
                    width: 43 // ???????? ?????? ??????
                },
                selected: 1 // ????? ?????? ??????? ?? ?????????
            },

            yAxis: [{
            gridLineWidth: 0,
            plotBands: [{ 
                 color: 'rgba(1, 143, 189, 1)',
                 from: -2,
                 to: 11
             },
             { 
                 color: 'rgba(157, 200, 5, 1)',
                 from: 11,
                 to: 21
             },
             { 
                 color: 'rgba(202, 1, 94, 1)',
                 from: 21,
                 to: 50
             }],


                title: {
                    text: '???????'
                },
                startOnTick: false,
             //   min: 1,
                showFirstLabel: true,
                showLastLabel: true,
                reversed: true,
                tickPositioner: function(min, max) {
                    // specify an interval for ticks or use max and min to get the interval
                    var interval = Math.round((max-min)/5);
                    // push the min value at beginning of array
                    var dataMin=this.dataMin;
                    var dataMax=this.dataMax;          
                    var positions = [dataMin];
                    var defaultPositions = this.getLinearTickPositions(interval, dataMin, max);
                    //push all other values that fall between min and max
                    for (var i = 0; i < defaultPositions.length; i++) {
                        if (defaultPositions[i] > dataMin && defaultPositions[i] < dataMax) {
                            positions.push(defaultPositions[i]);
                        }
                    }
                    // push the max value at the end of the array
                    positions.push(dataMax);
                    return positions;
                },
                //changed min valuereversed: true
            }],
            navigator: {
                enabled: false,
                maskFill: 'rgba(255, 255, 255, 0.45)',
                //margin: 20,
                series: {
                    type: 'areaspline',
                    color: 'rgba(255, 255, 255, 0.00)',
                    fillOpacity: 0.4,
                    dataGrouping: {
                        smoothed: false
                    },
                    lineWidth: 2,
                    lineColor: '#e9cc00',
                    marker: {
                        enabled: false
                    },
                    shadow: true
                },
                yAxis: {
                    reversed: true
                }
            },
            xAxis : { 
                gridLineWidth: 0,
                type: 'datetime',
                title : {
                    text : ' '
                },
            },

            title : {
                //text : '??????? ?????'
            },
            legend: {
                enabled: true,
                align: 'center',
                itemWidth: 234, // ?????? ??????, ????? ?????????? ????? ? 4 ???????
                verticalAlign: 'top'
            },          
            series : [{
                lineColor: 'white',
                name : '??????? ? ???????',
                id : 'dataseries',
                data : <?php echo $d ?>,
                tooltip: {
                    backgroundColor: 'rgba(250, 250, 250, .85)', // ??? ??????? ??????
                    borderColor: 'rgba(100, 100, 100, .90)', // ???? ??????? (?? ????????? ???????? ?????????)
                    xDateFormat: '%d.%m.%Y %H:%M', // ??? ?????? ????
                    // ??? ??????? ??????????? ?????? ????
                    headerFormat: '<span style="font-size: 12px">{point.key}</span><br/>',
                    // ?????? ???????? ? ?????????, ???????? ?????? ???????, ? ???????? ??????
                    pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b><br/>',
                    //valueDecimals: 2
                }
            }]
        });
    });

});

})(jQuery);
</script>
Run Code Online (Sandbox Code Playgroud)

Hor*_*ren 34

问题不在于gridLineWidth.你已经正确设置了.

此外,您需要设置minorGridLineWidth必须设置的值0

工作演示


Ira*_*yes 5

如果您不想触摸配置对象,只需通过 css 隐藏网格:

.chart-container .highcharts-grid {
   display: none;
}
Run Code Online (Sandbox Code Playgroud)