You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

启用setIntensityInterpolation("disabled")后LightningChart绘制频谱图崩溃

解决LightningChart JS v4.1.0调用setIntensityInterpolation崩溃的问题
  • 问题根源:v4.1.0版本中,setIntensityInterpolation方法不接受字符串参数(如"disabled"),必须使用**IntensityInterpolation枚举类型**的值。直接传字符串会触发类型不匹配,导致图表渲染崩溃。

  • 修复步骤:

    1. 从LightningChart库中导入IntensityInterpolation枚举
    2. 用IntensityInterpolation.Disabled替代字符串"disabled"调用方法
  • 修改后的完整测试代码:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>频谱图测试</title>
    <script src="https://unpkg.com/@arction/lcjs@4.1.0/dist/lcjs.iife.js"></script>
</head>
<body>
    <div id="chart" style="width: 800px; height: 600px;"></div>
    <script>
        const { lightningChart, IntensityInterpolation } = lcjs

        // 创建图表与热力图系列
        const chart = lightningChart().ChartXY()
        const spectrumSeries = chart.addHeatmapSeries({
            columns: 200,
            rows: 100
        })

        // 使用枚举值关闭强度插值
        spectrumSeries.setIntensityInterpolation(IntensityInterpolation.Disabled)

        // 生成模拟频谱数据
        const mockSpectrumData = Array.from({ length: 100 }, (_, row) => 
            Array.from({ length: 200 }, (_, col) => Math.sin(col/20) * Math.cos(row/10) * 50 + 50)
        )
        spectrumSeries.invalidateIntensityValues(mockSpectrumData)
    </script>
</body>
</html>
  • 补充说明:
    • 查阅v4.1.0版本API文档可知,setIntensityInterpolation仅支持枚举参数,可选值为Disabled和Linear。
    • 若想使用字符串形式参数,需升级到LightningChart JS v5.x及以上版本,后续版本才兼容字符串传入方式。

内容的提问来源于stack exchange,提问作者Youngchae Kim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 13:14:58