图表 - 如果在折线图上找不到数据,则隐藏 x 轴数据值

Flot chart - Hide x-axis data value if no data found on line chart

如果找不到数据,我正试图隐藏 x 轴数据标签。请参考下面的屏幕截图。我想显示“0”或空文本而不是日期“01/01/1970”。

我该怎么做?我当前的图表代码如下:

$.plot(elem, dataset1, 
        {
            lines: { show: true, fill:true },
            points: { show: true },
            shadowSize: 0,
            yaxis : {
                show : true,
                axisLabel : '<font style="color:#787878"><i>Total Views</i></font>',
                position: 'left',
                axisLabelPadding: 10,
                tickDecimals: 0,
                color: "#E0E0E0"
            },
            xaxis: {
                mode: "time",
                timeformat: "%d/%m/%Y",
                minTickSize: [1, "day"],
                color: "#E0E0E0",
                axisLabel: '<font style="color:#787878">Date</font>',
                axisLabelPadding: 20,
            },
            grid: {
                hoverable: true,
                borderWidth: 0
            },
            legend: { show: true, container: $('#legend-container'), noColumns: 1 },
            tooltip: true,
            tooltipOpts: {
                content: function(label, xval, yval) {
                    var d = new Date(xval);
                    return label + ' (' + d.getDate() + '/' + (d.getMonth()+1) + '/' + d.getFullYear() +') : ' + yval
                },
                shifts: {
                    x: 20,
                    y: 0
                },
                defaultTheme: false
            },
            colors: [ "#4682B4" ]
        }

如果数据集中有数据点,您可以将以下内容添加到轴选项以仅显示轴:

xaxis: {
    show: dataset1.length > 0
    ...