使用 plotly.js 时如何定义 x 轴悬停格式
How to define x-axis hover format when using plotly.js
在这样的示例中:https://plot.ly/12/~streaming-demos/,通过使用轴 > 标签 > 悬停格式下的设计器工具,我能够将时间 x 轴工具提示的格式更改为类似“%y /%m/%d %I:%M%p").我如何在代码中实现相同的功能?
我已经浏览过参考资料 (https://plot.ly/javascript/reference/),但在这方面找不到任何内容。
找到答案了。在 plotly 设计器上有一个 "View JSON" 按钮,它显示 json 配置对象以达到我想要的效果。
以下代码格式化 x 轴 (tickformat) 和工具提示悬停 (hoverformat)
var layout = {
xaxis:{
tickformat: "%y/%m/%d %I:%M %p",
hoverformat: "%y/%m/%d %I:%M %p"
}
}
Plotly.newPlot('myDiv', data, layout);
在这样的示例中:https://plot.ly/12/~streaming-demos/,通过使用轴 > 标签 > 悬停格式下的设计器工具,我能够将时间 x 轴工具提示的格式更改为类似“%y /%m/%d %I:%M%p").我如何在代码中实现相同的功能?
我已经浏览过参考资料 (https://plot.ly/javascript/reference/),但在这方面找不到任何内容。
找到答案了。在 plotly 设计器上有一个 "View JSON" 按钮,它显示 json 配置对象以达到我想要的效果。
以下代码格式化 x 轴 (tickformat) 和工具提示悬停 (hoverformat)
var layout = {
xaxis:{
tickformat: "%y/%m/%d %I:%M %p",
hoverformat: "%y/%m/%d %I:%M %p"
}
}
Plotly.newPlot('myDiv', data, layout);