highcharts - 如何使用 highcharts-react 将默认缩放设置为 6 个月?
问题描述
我有几个highcharts-react
图表,其中默认缩放级别应为 6 个月(对于 x 轴)。有一个使用默认 Highcharts library 的解决方案,但我不明白如何使用 React 来做到这一点。
这是我走了多远:
// …
import Highcharts from "highcharts/highstock";
import HighchartsReact from "highcharts-react-official";
import more from "highcharts/highcharts-more";
// …
if (typeof Highcharts === "object") {
more(Highcharts);
}
// …
<HighchartsReact
highcharts={Highcharts}
constructorType={"stockChart"}
options={{
credits: {
enabled: false
},
xAxis: {
events: {
setExtremes: () => {
// Is this right? What should be in this function?
}
}
},
series: [
{
type: "candlestick",
name: props.timeSeries.name,
data: openHighLowClose
}
]
}}
/>
解决方案
我看到您正在创建一个stockChart,因此在这种情况下,您可以使用rangeSelector功能设置显示范围。
下面是一个演示,我将选定的按钮设置为 2,默认情况下等于 6 个月。您可以在我上面发布的 API 中找到更多信息。
推荐阅读
- visual-studio-2017 - Visual Studio 2017 中的 nuget 包参考蓝色图标
- hyperledger-fabric - fabric-sdk-go 连接失败
- sql - 从组合框/文本框选择中插入 SQL
- shell - 当我更新 oh-my-zsh 时出现错误。我该如何解决?
- google-cloud-dataflow - BeamSql 对数组和地图的支持
- scala - 在带有密码确认的注册表单上键入不匹配
- python - Git Hooks 不在 Windows 上运行
- html - 我的 css 样式与元素在同一页面上工作,但从 .css 文件链接时不工作
- reactjs - 更新redux(用户身份验证)后反应渲染私有路由
- javascript - jQuery on() / living() 问题