[英]How can I add a drop-down menu to change the theme of sci chart using html and js?
I have an XY SciChart.js chart in which I added two line charts with dummy data.我有一个 XY SciChart.js 图表,我在其中添加了两个带有虚拟数据的折线图。
Then I added a drop-down menu.然后我添加了一个下拉菜单。
How can I add a drop-down menu to change the theme of sci chart using html css and js in visual studio code?如何在visual studio code中使用html css和js添加下拉菜单更改sci图表的主题?
You can update the theme for a sciChartSurface by calling sciChartSurface.applyTheme.您可以通过调用 sciChartSurface.applyTheme 更新 sciChartSurface 的主题。 Documentation for this is here这方面的文档在这里
If your select has the id "theme":如果您的 select 的 ID 为“主题”:
document.querySelector("#theme").onchange = (ev) => {
const value = ev.target.value;
let theme = new SciChart.SciChartJSDarkv2Theme();
if (value === "Light") {
theme = new SciChart.SciChartJSLightTheme();
} else if (value === "Custom") {
theme.lineSeriesColor = "red";
theme.sciChartBackground = `radial-gradient(circle, #615EFF 0%, #C4DFFF 100%)`;
theme.axisBandsFill = "#AACDFF33";
theme.tickTextBrush = "#0C0C63";
}
sciChartSurface.applyTheme(theme);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.