簡體   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