首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用lightningchart将比例更改为任意数字

如何使用lightningchart将比例更改为任意数字
EN

Stack Overflow用户
提问于 2020-05-31 19:00:54
回答 1查看 133关注 0票数 0

使用lightningchart设置要显示的比例时,默认大小为5或10个增量。

是否可以将其更改为任意增量(2个增量、3个增量等)?

请让我知道。

EN

回答 1

Stack Overflow用户

发布于 2020-06-09 15:34:04

轴根据轴的缩放级别和每个记号标签的可用空间自动计算增量大小。我们希望在今年夏天的下一个主要版本中改善我们的Axis行为。

同时,可以使用customTicks手动创建此行为。

代码语言:javascript
运行
复制
/*
 * LightningChartJS example that showcases a simple XY line series.
 */
// Import LightningChartJS
const lcjs = require('@arction/lcjs')

// Extract required parts from LightningChartJS.
const {
    lightningChart,
    ColorRGBA,
    UIElementBuilders,
    emptyFill,
    emptyLine,
    emptyTick,
    SolidLine,
    SolidFill
} = lcjs
    // Create a XY Chart.
const chart = lightningChart().ChartXY()
    .setTitle('XY Chart with custom tick interval')

// Get the default X Axis and cache it
const defXAxis = chart.getDefaultAxisX()
// Set the default Axis style as emptyTick, hiding the default Ticks created
// by the AxisTickStrategy
defXAxis.setTickStyle(emptyTick)
// Iterate an arbitrary amount of ticks, creating a new customTick with interval of 2
for ( let i = 10; i <= 90; i += 2 ) {
    // Add a new custom tick to the X Axis
    defXAxis.addCustomTick(
        // Modify the textBox to hide its background and border
        UIElementBuilders.PointableTextBox.addStyler(
            (styler) => {
                styler.setBackground(
                    (bg)=> 
                        bg
                            .setFillStyle(emptyFill)
                            .setStrokeStyle(emptyLine)
            ) }
        ))
        // Set the tick position
        .setValue( i )
        // Make the Grid stroke less visible
        .setGridStrokeStyle(
            new SolidLine( {
                thickness: 1,
                fillStyle: new SolidFill( { color: ColorRGBA(200, 200, 200, 50)})
            })
        )
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62115206

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档