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

调用Arction LightningChart JS的saveToFile函数报错't.captureFrame is not a function',是否必须传入PublicEngine参数?

Solution: Fix "t.captureFrame is not a function" in LCJS saveToFile

Yes, you absolutely need to pass a PublicEngine instance to resolve this error—here's why and how to fix your code:

Why the Error Happens

The saveToFile function relies on the engine's captureFrame method to capture the chart visual. When you don't pass the PublicEngine instance, the internal reference to the engine (t in the error message) is undefined or invalid, hence the "not a function" error.

Why the Official Example Seems to Skip the Parameter

The official examples likely run in a context where the saveToFile function is pre-bound to an existing engine instance—for example, when working within the scope of a chart you've already created, or using library utilities that auto-inject the active engine. The documentation might simplify the syntax for brevity, but under the hood, the engine reference is still being passed implicitly.

Fixed Code Implementation

Update your screenShot function to accept and pass the PublicEngine instance (this is the chart object you create with LCJS, e.g., lightningChart().ChartXY()):

export function screenShot(engine, fileName) {
  const lcjs = require('@arction/lcjs');
  const { saveToFile } = lcjs;
  // Pass the engine instance as the first argument
  saveToFile(engine, fileName, 'image/bmp');
}

How to Use It

When calling your screenShot function, pass the initialized engine/chart instance:

// Example: Create a chart first
const lcjs = require('@arction/lcjs');
const { lightningChart } = lcjs;
const chart = lightningChart().ChartXY();

// Later, trigger screenshot
screenShot(chart, 'my-screenshot');

Key Notes

  • Ensure the engine instance is fully initialized before calling screenShot (e.g., in React, call it after the component mounts and the chart is rendered).
  • The PublicEngine type includes all LCJS chart instances (ChartXY, Chart3D, PieChart, etc.)—you can safely pass any of these.

内容的提问来源于stack exchange,提问作者Shoni Nemavhidi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.27 21:57:31