The examples in this article use @mcui/mccharts 3.0.0, a native chart component for ArkUI on HarmonyOS. It reuses the Apache ECharts 6.1.0 option model, draws through a native GLES path, and needs no WebView. The package is published on OHPM: ohpm install @mcui/mccharts@3.0.0.
“The chart has 100,000 points” sounds like a graphics problem. Sometimes it is. But before the GPU draws anything, the application still creates or receives the data, the chart runtime processes it, a visible window is selected, and geometry is prepared for the native renderer.
The mccharts demo is useful because it lets us change the total data count and the visible window separately. The screenshot below shows the demo with 10,000 source points and a 500-point window; the code in this article requests a different, 100,000-point dataset.
Start with the existing factory
The component exports a demo factory. This page requests 100,000 source points, a 500-point window, large mode and progressive processing:
import { McChartsV2, createLargeScatterDemoOption } from '@mcui/mccharts';
import type { Options } from '@mcui/mccharts';
@Entry
@ComponentV2
struct LargeScatterExample {
private option: Options = createLargeScatterDemoOption(100000, 500, true, true, 0);
build() {
Column() {
McChartsV2({
options: this.option,
enableDataZoom: true,
showRenderStats: true
}).width('100%').height(390)
}.width('100%').padding(16)
}
}
enableDataZoom permits the component's inside zoom gestures; the factory also creates the dataZoom model. showRenderStats exposes a demo statistics area that is read on demand. It does not measure end-to-end FPS or prove that a particular device can sustain a given update rate.
The factory computes the initial window like this:
const visible = Math.min(count, windowSize), start = Math.floor((count - visible) / 2);
It then creates count records and sets startValue: start and endValue: start + visible - 1 in the inside dataZoom configuration. With the example inputs, the original series contains 100,000 points and the initial window covers 500 of them. A smaller visible window does not erase the source array or its earlier processing cost.
Follow one update through the layers
- The page creates or receives the records and submits an option.
- The runtime constructs the data model, axes and visible data window.
- The painter prepares geometry and drawing commands for the current frame.
- The session passes the frame to the native module; the native renderer uploads and draws it on the XComponent surface.
- Labels and interaction are handled through their respective host paths.
The session's ordinary geometry submission is visible in the source:
const frame = this.runtime.tick(this.elapsedMs);
if (frame.revision !== this.revision || (this.rasterizer?.needsPresent() ?? false)) {
let rasterDiagnostics: string[] = [];
if (this.rasterText && this.rasterizer) { rasterDiagnostics = this.rasterizer.present(frame); }
else { nativeChart.setScene(this.id, frame.vertices, frame.commands, 0, 0); }
The rest of the method handles diagnostics and delivery. tick produces frame data; it is not the same as measuring the entire path through the device GPU and display. Geometry can be expensive even when the runtime model is fast, and data preparation can be expensive before any geometry exists.
Large mode and progressive work are separate switches
The factory creates a scatter series with a uniform symbol and style. Its relevant fields are:
large: Boolean(large), largeThreshold: 0,
progressive: progressive ? 1000 : 0, progressiveThreshold: 0,
progressiveChunkMode: 'sequential',
Large mode selects a batch-oriented path. It comes with limits: do not assume per-point styles, labels, emphasis and individual animations work like an ordinary scatter series. Progressive processing divides work across steps; it does not make the original 100,000 records disappear, and the first partial frame is not proof that all visible points are complete.
The factory uses largeThreshold: 0 for its demo. That is not a universal threshold for every product. Choose the mode based on the interaction and visual requirements, then test with the actual dataset.
Why an unchanged batch can still cost time
The painter has a large-scatter geometry cache. An unchanged batch may reuse some CPU geometry, but the runtime still needs to determine what changed and assemble the frame. A pan or axis-range change can move many vertices, even if the underlying values have not changed.
The native renderer also manages a GPU buffer. Its source allocates storage and can update a changed range:
glBufferData(GL_ARRAY_BUFFER, static_cast<GLsizeiptr>(bytes), nullptr, GL_DYNAMIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, static_cast<GLintptr>(first), static_cast<GLsizeiptr>(bytes),
scene_.vertices.data() + uploadPlan.firstVertex * FLOATS_PER_VERTEX);
These calls sit inside the renderer's upload-plan checks. Allocation, CPU-side copying, upload and drawing are different operations. Buffer capacity may be retained for reuse; that capacity is not the number of points currently visible. Fewer uploaded bytes do not automatically translate to a fixed number of milliseconds saved.
Check the data identity after zoom
For a full source array passed directly to the series and filtered by dataZoom, the runtime keeps the original input index for a clicked point. If the application first slices a new array and passes only that slice, the index belongs to that new input. Keep the corresponding device ID and timestamp alongside the array submitted in each update.
Marker clicks are separate from series clicks. A marker's dataIndex refers to the marker list. If an alarm marker opens a business event, maintain the matching event mapping and update it whenever the marker list changes.
Measure the operation your user performs
Record the device model, system and component build, chart dimensions, data count, visible window, number of series, animation and update frequency. Test first display, repeated drag, data update, background/foreground and page return. Note whether the measurement covers data loading, model construction, frame generation, upload or actual user-visible completion.
If the user first needs an overview, consider fetching a bounded summary and requesting raw points for a selected interval. For monitoring data, an average alone can hide a short spike; decide whether each bucket must retain its minimum and maximum. Also handle late responses when the user changes devices or windows.
The point of this architecture is not that every chart should send 100,000 points to a phone. It is to make the cost visible, keep data and interaction correct, and choose the amount of work the target device actually needs to perform.