从日期时间 X 轴隐藏非活动日期

Hide inactive dates from datetime X-Axis

我创建了 fiddle 来显示我当前的图表: http://jsfiddle.net/LLExL/4445/

密码是

$('#container').highcharts({
    chart: {
        backgroundColor: 'none',
        spacingRight: 20,
        zoomType: 'x'
    },
    credits: {
        enabled: false
    },
    exporting: {
        enabled: false
    },
    legend: {
        borderWidth: 0,
        enabled: true,
        verticalAlign: 'top',
        y: 25
    },
    plotOptions: {
        series: {
            animation: false,
            marker: {
                enabled: false,
                states: {
                    hover: {
                        enabled: true,
                        radius: 5
                    }
                }
            }
        },
    },
    title: {
        text: 'Points'
    },
    tooltip: {
        shared: true
    },
    xAxis: {
        labels: {
            format: '{value: %d/%m}'
        },
        type: 'datetime'
    },
    yAxis: {
        title: {
            text: null
        },
        showFirstLabel: true
    },
    series: [{
        type: 'column',
        name: 'Reached',
        data: [
            [1427328000000, 198],
            [1427414400000, 127],
            [1427673600000, 104],
            [1427760000000, 107],
            [1427846400000, 102],
            [1427932800000, 1],
            [1428278400000, 1],
            [1428364800000, 55],
            [1428451200000, 83],
            [1428537600000, 77],
            [1428624000000, 107],
            [1428883200000, 99],
            [1428969600000, 140],
            [1429056000000, 134],
            [1429142400000, 108],
            [1429228800000, 104],
            [1429488000000, 113],
            [1429574400000, 115],
            [1429660800000, 115],
            [1429747200000, 97],
        ]
    }, {
        type: 'line',
        name: 'Target',
        color: 'red',
        lineWidth: 2,
        data: [
            [1427328000000, 123],
            [1427414400000, 123],
            [1427673600000, 123],
            [1427760000000, 123],
            [1427846400000, 143],
            [1427932800000, 0],
            [1428278400000, 0],
            [1428364800000, 143],
            [1428451200000, 143],
            [1428537600000, 143],
            [1428624000000, 114],
            [1428883200000, 143],
            [1428969600000, 143],
            [1429056000000, 143],
            [1429142400000, 143],
            [1429228800000, 114],
            [1429488000000, 143],
            [1429574400000, 143],
            [1429660800000, 143],
            [1429747200000, 143],
        ]
    } ]
});

我想从 X 轴上删除不活动的日期,例如。 02/04 和 06/04 之间的日期(但不是这两个,因为它们有值)。

我发现唯一有效的解决方案是通过类别自己声明日期,然后远离日期时间类型轴。这对我来说不是正确的解决方案,因为轴将无法正确适合较小的屏幕。

这是否可以删除无价值日期?

在 Highcharts 中轴没有序号选项,但如果您使用 Highstock 可以设置它。此选项隐藏 x 轴上没有点的值。

您可以使用 Highstock 创建 Highcharts 图表,其轴具有序号 x 轴。

加载 Highstock JS 文件而不是 Highcharts:

<script src="http://code.highcharts.com/stock/highstock.js"></script>

在轴选项中将序号设置为真:

xAxis: {
        ordinal: true,

jsFiddle: http://jsfiddle.net/LLExL/4451/