Skip to content

feat: use ECharts to have faster charts#2234

Open
Ahmad-Wahid wants to merge 31 commits into
mainfrom
feat/better-and-fast-asset-charts
Open

feat: use ECharts to have faster charts#2234
Ahmad-Wahid wants to merge 31 commits into
mainfrom
feat/better-and-fast-asset-charts

Conversation

@Ahmad-Wahid

@Ahmad-Wahid Ahmad-Wahid commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Description

Adds an optional Fast chart mode (Apache ECharts, canvas-based) alongside the existing Vega-Lite charts. A toggle in the chart header switches between them, and the choice is remembered per browser. The fast chart renders and interacts far faster on dense time series while staying visually and functionally equivalent to the Vega-Lite charts.

What's included

  • Canvas rendering with mouse-wheel zoom, drag-to-pan, and a shared ruler + nearest-point tooltip synced across subplots

  • Parity with Vega-Lite: subplot layout, colors, legends (including the Source line-style key), titles/axes/fonts, annotations, replay, and step-vs-linear interpolation based on each sensor's resolution

  • All chart types: line, bar, histogram, heatmap, and charge-point sessions

  • PNG / SVG / CSV export

  • Added changelog item in documentation/changelog.rst

Look & Feel

Vega-Lite:
image

ECharts:
image

EChart will show the legends of those sensors that has data. Although, they are not dropped from the sensors_to_show list.

How to test

Switch between Vega-Lite and ECharts using this toogle button.
image

Further Improvements

Vega-Lite ECharts
Asset page (vconcat line chart)
Sensor page (bar chart)
Sensor page (annotations)
Sensor page (histogram)
Sensor page (heat map)
Speed 🟡 🟢
Interactivity 🟡 🟢
Replay
Toggle legend position
Tooltip
Export (CSV)
Export (PNG)
Export (SVG)
  • 🟡 Good
  • 🟢 Great
  • ✅ Supported
  • ❌ Not supported
  • ⬜ Support unknown

Related Items

  • Drop the report widget after everything is confirmed
image

Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
@Ahmad-Wahid Ahmad-Wahid self-assigned this Jun 12, 2026
@Flix6x Flix6x added the UI label Jun 12, 2026
…ing charts

Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>

@Flix6x Flix6x left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No code review, just observations from testing. Improvements I observe are:

  • Speed
  • Panning
  • Zooming
  • Hover effect to focus on a single trace (line)
  • Heat map interactivity (select a value range to see)

Missing:

  • Asset page shows misaligned x-axis on vertically concatenated subcharts (tip: try the replay on asset 77) (✅ )
  • Bar chart of a year of 15-minute prices has missing data
  • SVG export on large heatmaps has missing data
  • No annotations visible on sensor bar chart (tip: select a time period on sensor 14 covering some Dutch public holidays) (✅ )
  • SVG export should exclude buttons (✅ )
  • Double click to reset
  • Font size too small (✅ )
  • Tooltip hover on nearest data point (this can be discussed)

Ahmad-Wahid and others added 8 commits June 12, 2026 20:09
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…mps, fonts)

- show hover annotations on the sensor page, matching the Vega-Lite
  SHADE_LAYER/TEXT_LAYER (gray bands, highlight + label on hover)
- use tableau10 colors and zero-based y-axis like Vega-Lite
- use linear interpolation for instantaneous sensors so ramps are visible
- match Poppins font and Vega-Lite font sizes
- always show the legend below on the sensor page
- mixed date/time x-axis labels and extra inter-subplot spacing
@Ahmad-Wahid

Ahmad-Wahid commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

No code review, just observations from testing. Improvements I observe are:

  • Speed
  • Panning
  • Zooming
  • Hover effect to focus on a single trace (line)
  • Heat map interactivity (select a value range to see)

Missing:

  • Asset page shows misaligned x-axis on vertically concatenated subcharts (tip: try the replay on asset 77)
  • Bar chart of a year of 15-minute prices has missing data (✅ )
  • SVG export on large heatmaps has missing data
  • No annotations visible on sensor bar chart (tip: select a time period on sensor 14 covering some Dutch public holidays) (✅ )
  • SVG export should exclude buttons (✅ )
  • Double click to reset
  • Font size too small (✅ )
  • Tooltip hover on nearest data point (this can be discussed)

Let's discuss the rest of the items in a call.

- dataZoom realtime:false + throttle:80 so a slider drag coalesces into a
  single redraw on release instead of one per tick (removes mid-drag jank)
- large mode on line series for batched canvas drawing
- measured on asset 77 (7,728 rows): initial render 134ms -> 71ms,
  slider drag 25 re-renders -> 1
@Flix6x

Flix6x commented Jun 26, 2026

Copy link
Copy Markdown
Member

Updated list of observations

Sensor page:

  • Reorder buttons: please move the SVG button to between Reset Zoom and PNG. ✅

  • PNG and SVG for 1 year of sensor 14 is still missing data. CSV probably, too, please check. ✅

  • Reset Zoom is very peculiar at the moment. It only does something when the Zoom button function has been used, and whatever window had been selected at that time will be the window that it resets to, until you reload the entire page. I see two options going forward:

    1. Always reset to the full period in the URL, or
    2. Reset to the previously selected period (like a back button). ✅

    The first option is probably simplest.

Asset page:

  • Source legend at the bottom. ✅
  • Instantaneous sensors should not have step-before/after viz ✅
  • Tooltip should always show for the nearest data point (nearest vertical trace, in case of multiple traces, nearest horizontally on the left or right, I don't mind that much; the vega-lite uses the nearest on the left).
  • Subplots should have same x-axis when the play-button is pressed. ✅

Export read the canvas/SVG synchronously right after setOption, but
heatmaps render cells progressively across animation frames, so a
year-long heatmap (>5000 cells) lost every cell past the first chunk.
buildExportOption now forces progressive:0 on every series so the full
chart renders in one pass. CSV is unaffected (it serializes the raw
rows).

Also place the SVG export icon between Reset Zoom and PNG on the sensor
page only, leaving the asset-page toolbox order unchanged.
…asset-charts

# Conflicts:
#	documentation/changelog.rst
- Native ECharts Charge Point sessions chart with companion subplots and
  working per-session tooltips; charge-points type switchable in fast mode
- Do not render the Charge Point sessions panel in the default view
- Align companion subplots on a shared time domain
- Remove the always-visible range-slider zoom bar (keep wheel/drag zoom)
- Move the Source line-style key to the bottom, matching Vega-Lite: a
  vertical column at the bottom-left with side legends, or a second column
  beside the Sensor legend in the legends-below layout
Drop the Arrival/Plug-in/Charging key from the sessions chart along with the
now-unused buildChargePointKey helper and CHARGEPOINT_KEY_ROWS constant.
Vega uses linear interpolation for a subplot row when any of its sensors is
instantaneous (event_resolution 0), and step-after otherwise. The fast chart
had to guess resolution from event spacing because the chart data never carried
the real event_resolution, which mislabeled instantaneous sensors as interval
data (stepped lines where Vega draws smooth ones).

Serialize event_resolution (seconds) through every chart-data path the UI uses:
Sensor.as_dict, Sensor.search_beliefs, GenericAsset.search_beliefs, and the
fixed-value flex-sensor metadata in GenericAsset.chart_data_json. Carry it
through decompressChartData, then decide interpolation per subplot in
fast-chart.js exactly as chart_for_multiple_sensors does, with a spacing-based
fallback for legacy data.
Use axis-trigger tooltips on the line/bar charts so hovering anywhere over a
subplot reveals the nearest data point (the ruler), as in the Vega-Lite charts,
instead of requiring a direct hit on the thin line. The formatter picks the
single point nearest to the ruler and shows its details, scoped to the hovered
subplot.
@nhoening nhoening added this to the 1.0.0 milestone Jul 6, 2026
Each subplot's time axis auto-scaled to its own data extent, so subplots whose
data spans a wider range (e.g. Site capacity's capacity sensors) rendered at a
different horizontal scale than the rest, most visibly misaligning the replay
ruler. Compute one shared time domain from the union of all subplots' data and
apply it to every time axis, mirroring Vega-Lite's resolve.scale.x = shared.
@read-the-docs-community

read-the-docs-community Bot commented Jul 8, 2026

Copy link
Copy Markdown

Documentation build overview

📚 flexmeasures | 🛠️ Build #33498153 | 📁 Comparing 7acee9d against latest (a737210)

  🔍 Preview build  

2 files changed
± changelog.html
± api/v3_0.html

Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
This reverts commit 130ba83.
@Ahmad-Wahid

Copy link
Copy Markdown
Contributor Author
  • Tooltip should always show for the nearest data point (nearest vertical trace, in case of multiple traces, nearest horizontally on the left or right, I don't mind that much; the vega-lite uses the nearest on the left).

@Flix6x I have already worked on this point but I'm not sure if it works as you expect. Could you please look into it?

@Ahmad-Wahid Ahmad-Wahid marked this pull request as ready for review July 8, 2026 14:01
@Ahmad-Wahid Ahmad-Wahid requested a review from Flix6x July 8, 2026 14:55
Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants