Highcharts标记对齐与Axis网格线不匹配

时间:2017-09-29 08:11:50

标签: javascript highcharts lineseries

enter image description here

选项如下所示:

var chartOptions = {
                        chart: {
                            backgroundColor: 'white',
                            type:'line'
                        },
                        title: { 
                            text:null
                        },
                        xAxis: {
                            gridLineWidth:0.5,
                            gridLineColor:'#e1e1e1',
                            tickInterval:intervalPeriod,
                            tickWidth: 0,
                            type: 'datetime',
                            dateTimeLabelFormats: dateTimeLabelFormats
                        },  
                        yAxis: {
                            gridLineWidth:0.5,
                            gridLineColor:'#e1e1e1',
                            allowDecimals:false,
                            tickAmount: 5,
                            title: {
                                text: null
                            }
                        },
                        tooltip:{
                            shared:true,
                            xDateFormat:'%e  %b, %Y',
                            crosshairs:true
                        }
                }

1 个答案:

答案 0 :(得分:0)

您需要为tickIntervalpointInterval设置相同的值才能显示与系列点同步的标记。当点具有不规则的间隔时,您可以使用tickPositions数组。

API参考:
http://api.highcharts.com/highcharts/xAxis.tickInterval
http://api.highcharts.com/highcharts/plotOptions.series.pointInterval
http://api.highcharts.com/highcharts/xAxis.tickPositions

例:
http://jsfiddle.net/zycwaexa/ - 使用相同的tickIntervalpointInterval http://jsfiddle.net/z7pnwtrs/ - 使用tickPositions