Apex 图表 - 在工具提示中显示日期

使用 Apex 图表,如何在自定义工具提示中显示当前突出显示栏的日期?例如,在此屏幕截图中,我想显示“Jun 2020”而不是硬编码的“Month”字符串。所以我正在寻找 X 轴类别标签,但我不明白如何在工具提示中显示它。

http://img4.mukewang.com/636e0d920001342511430390.jpg

  series: [{

    name: 'Month',

    data: [<?= $data ?>]

  }],          

  xaxis: {

    categories: [<?= $labels ?>],

    labels: {

      rotateAlways: true,

    }

  },

  tooltip: {

    y: {

      formatter: function (val) {

        return val + " products sold"

      }

    }

  },


慕桂英3389331
浏览 192回答 3
3回答

临摹微笑

对此进行测试,在您的选项中添加这些工具提示参数options: {&nbsp; &nbsp; &nbsp; &nbsp; tooltip: {&nbsp; &nbsp; &nbsp; &nbsp; x: {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; format: "dd MMM yyyy",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; formatter: function(value, { series, seriesIndex, dataPointIndex, w }) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new Date(value)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp;或者将此用于日期格式:options: {&nbsp; &nbsp; tooltip: {&nbsp; &nbsp; x: {&nbsp; &nbsp; &nbsp; &nbsp; format: "MMM yyyy"&nbsp; &nbsp; &nbsp; &nbsp;}&nbsp; &nbsp; &nbsp;}}

九州编程

这对我有用。*不要忘记使用时刻库...tooltip.x.formatter =function(value,{ series, seriesIndex, dataPointIndex, w }){&nbsp; &nbsp;return moment(new Date(tooltip_manual_set[value-1])).format('M/D HH:mm');};

catspeake

这为我解决了它:tooltip: {&nbsp; &nbsp; &nbsp; &nbsp; x: {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; show: true,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; format: "dd MMM yyyy",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; formatter: function (value,{ series, seriesIndex, dataPointIndex, w }) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new Date(value).toDateString();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript