【问题标题】:Flot Chart - remove tick labels between points浮动图表 - 删除点之间的刻度标签
【发布时间】:2017-03-17 20:15:48
【问题描述】:

我有一个 Flot 图表,它在 x 轴刻度标签中显示日期,但在点之间显示标签。我只想在我有值(点)时显示 x 轴刻度标签。这可能吗?

查看我的图表的这张图片:

下面是我的代码:

sin.push([dataToTimestamp('01/03/2017'), 60000]);
sin.push([dataToTimestamp('02/03/2017'), 70000]);
sin.push([dataToTimestamp('03/03/2017'), 50000]);


cos.push([dataToTimestamp('01/03/2017'), 50000]);
cos.push([dataToTimestamp('02/03/2017'), 80000]);
cos.push([dataToTimestamp('03/03/2017'), 70000]);


var line_data1 = {
  data: sin,
  color: "#3c8dbc"
};
var line_data2 = {
  data: cos,
  color: "#00c0ef"
};
$.plot("#line-chart", [line_data1, line_data2], {
  grid: {
    hoverable: true,
    borderColor: "#f3f3f3",
    borderWidth: 1,
    tickColor: "#f3f3f3"
  },
  series: {
    shadowSize: 0,
    lines: {
      show: true
    },
    points: {
      show: true
    }
  },
  lines: {
    fill: false,
    color: ["#3c8dbc", "#f56954"]
  },
  yaxis: {
    show: true,
  },
  xaxis: {
    show: true,
    mode: "time", 
    timeformat:"%d/%m/%y",
    //timeformat:"%d/%m/%y %H:%M:%S",
    //tickSize: [4, 'hour']
  }
});

【问题讨论】:

  • 顺便说一句:你所说的图例被 Flot 称为轴刻度标签。图例包含数据系列的标签(未包含在您的示例中)。

标签: javascript jquery charts flot


【解决方案1】:

你可以试试

tickSize: [1, 'day']

xaxis 选项中或直接自己指定刻度

ticks: [dataToTimestamp('01/03/2017'), dataToTimestamp('02/03/2017'), dataToTimestamp('03/03/2017')]

请参阅documentation 以获得更多帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-19
    • 1970-01-01
    • 1970-01-01
    • 2014-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多