繁体   English   中英

高图中的X轴间隔

[英]X-axis interval in Highcharts

我的图表图表

我的网站上显示了这个图表高图。 如何设置X轴的间隔? 例如,我希望显示拳头值,然后跳过第二个并显示第三个。 能做到吗? 或者,您是否始终只是要以阵列形式显示要传递给轴的所有数据?

我的代码:(时间戳是一个包含我的时间的JS数组。我可以以时间格式获取该时间。act和temps是用于沿y轴绘制数据的数组)

$(function () {
    $('#tempactgraph').highcharts({
        chart: {
            zoomType: 'xy'
        },
        title: {
            text: 'Temperature & Activity Monitoring '
        },
        subtitle: {
            text: 'Source: Cowlar Sensors'
        },
        xAxis: [{
            categories: timestamp,
            crosshair: true
        }],
        yAxis: [{ // Primary yAxis
            labels: {
                format: '{value}°C',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },
            title: {
                text: 'Temperature',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            }
        }, { // Secondary yAxis
            title: {
                text: 'Activity',
                style: {
                    color: Highcharts.getOptions().colors[0]
                }
            },
            labels: {
                format: '{value} xx',
                style: {
                    color: Highcharts.getOptions().colors[0]
                }
            },
            opposite: true
        }],
        tooltip: {
            shared: true
        },
        legend: {
            layout: 'vertical',
            align: 'left',
            x: 120,
            verticalAlign: 'top',
            y: 100,
            floating: true,
            backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
        },
        series: [{
            name: 'Activities',
            type: 'spline',
        connectNulls: 1,
            yAxis: 1,
            data: act,
            tooltip: {
                valueSuffix: ' xx'
            }

        }, {
            name: 'Temperature',
            type: 'spline',
        connectNulls: 1,
            data: temps,
            tooltip: {
                valueSuffix: '°C'
            }
        }]
    });
});

您需要像这样在x轴tickInterval:2添加tickInterval:2

xAxis: [{
            categories: timestamp,
            crosshair: true,
            tickInterval: 2
        }],

Highcharts API参考

暂无
暂无

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

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