javascript - 删除 LightningChart Chart3D 中的所有轴线
问题描述
我在 React 沙盒应用程序中使用lcjs,试图制作一个仅呈现条形本身的 3D 条形图。(这些条在示例中隐藏)
但是,API 文档似乎没有给我一种访问 3D 画布中绘制的所有线条的方法。
这是所有行的示例:
this.chart = lightningChart().Chart3D({ container: this.chartId });
我能够用这个删除主轴线:
this.chart.forEachAxis((axis) => {
axis.setStrokeStyle(emptyLine);
});
注意主轴现在是空的,但所有其他“非默认”的仍然存在。
我将如何隐藏所有这些并让图表呈现没有任何轴线?
解决方案
可以使用自定义主题编辑边界框线样式。
LightningChart JS 导出customTheme
功能,可用于基于另一个主题创建新主题。您可以使用该功能创建一个新主题,其中边界框线设置为emptyLine
。
const myTheme = customTheme(Themes.dark, {
boundingBoxStyle3D: emptyLine
})
然后,当您创建 3D 图表时,您可以使用创建的主题作为图表应使用的主题。
const chart3D = lightningChart().Chart3D({
theme: myTheme
})
请参阅下面的工作示例。
// Extract required parts from LightningChartJS.
const {
lightningChart,
SolidFill,
SolidLine,
Themes,
customTheme,
emptyLine,
emptyTick
} = lcjs
// Create custom theme based on the dark theme and edit the boundingBoxStyle3D property to be emptyLine to hide the bounding box lines
const myTheme = customTheme(Themes.dark, {
boundingBoxStyle3D: emptyLine
})
// Initiate chart
const chart3D = lightningChart().Chart3D({
theme: myTheme
})
// Set Axis titles
chart3D.getDefaultAxisX()
.setTickStrategy("Empty")
.setStrokeStyle(emptyLine)
chart3D.getDefaultAxisY()
.setTickStrategy("Empty")
.setStrokeStyle(emptyLine)
chart3D.getDefaultAxisZ()
.setTickStrategy("Empty")
.setStrokeStyle(emptyLine)
<script src="https://unpkg.com/@arction/lcjs@2.1.0/dist/lcjs.iife.js"></script>
推荐阅读
- c - C中带有插入排序程序的双向链表
- xml - 无法从嵌套的多人游戏 XML 创建数据框
- php - Laravel 通过 eloquent 存储多对多关系
- r - 我可以对主成分分析进行事后分析吗?
- pandas - 根据列名删除重复列
- java - mvn dependency:go-offline 在升级几个依赖项后失败
- matlab - 试图将 8 个数字放入 2 个窗口中
- greasemonkey-4 - Greasemonkey Get and Set Value 不工作并且没有错误地杀死脚本
- javascript - JavaScript 中的带提升的时间死区
- c++ - 基于 C++ 中的种子混淆字符串的代码?