首页 > 解决方案 > 为散点图设置单个大小的大小

问题描述

我们可以更改单个分散系列项目的大小吗?现在这可以改变颜色

点系列

 .add([
        { x: 2.5, y: 0, color: ColorRGBA( 255, 0, 0 ) },
        { x: 5, y: 10 },
        { x: 7.5, y: 20, color: ColorRGBA( 0, 255, 0 ) },
        { x: 10, y: 30, color: ColorRGBA( 0, 0, 255 ) },
    ])

就像是

    { x: 2.5, y: 0, color: ColorRGBA( 255, 0, 0 ) , size : 2 },

标签: lightningchart

解决方案


可以指定PointSeries的单个点的大小。

添加新点时,您需要启用单个点大小调整series.setIndividualPointSizeEnabled(true)以启用字段的使用。size然后,您可以在将点添加到系列时包含尺寸信息。 series.add({ x: 2.5, y: 0, size: 30 })

series.setPointSize可用于定义未定义单独大小的点的大小。

const {
    lightningChart,
    IndividualPointFill,
    ColorRGBA
} = lcjs

const lc = lightningChart()
const chart = lc.ChartXY()

const series = chart.addPointSeries()

series.setIndividualPointSizeEnabled(true)
series.setPointFillStyle(new IndividualPointFill())
series.setPointSize(10)

series.add([
    { x: 2.5, y: 0, color: ColorRGBA(255, 0, 0), size: 30 },
    { x: 5, y: 10 },
    { x: 7.5, y: 20, color: ColorRGBA(0, 255, 0), size: 5  },
    { x: 10, y: 30, color: ColorRGBA(0, 0, 255), size: 20  },
])
<script src="https://unpkg.com/@arction/lcjs@2.2.1/dist/lcjs.iife.js"></script>


推荐阅读