leeoniya / leeoniya/uPlot

Question and suggestion: get scale's data min/max and calculate average and sum of series data

Open
#678 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.5k
Forks
463
PR merge metrics
No merged PRs in 30d

Description

Hi!

As I understand, currently I can get the whole scale's data min and max only in range function. After the options will be set, in uplot.series.min/max will appear visual min/max of scale but not a real min/max of data. Also I can get min and max of series after the options will be set.

For the last months of creating plugins for uPlot I faced (a lot of times) with necessity to access to data min/max per scale, also manually calculated average of series and so on. I suppose that it's a pretty common necessity for chart development.

So my question: am I right in my previous assumptions? Also I prepared an example in JSFiddle, and I've found that I can't modify series in init hook, to assign sum and avg so I need to precalc them outside of uPlot lifecycle somehow (look line 45). Why does it work in that way?

Suggestion:

  • Store and expose real scale's data min/max in scales object
  • Also calculate sum and average value of each series and per scale

Rationale:

  • It could be useful for implementing plugins such as legend, tooltips, axes where there is a necessity to show average, sum and other values
  • I think that it should be done in uPlot because of uPlot is already calculates series min and max and it would be very easy to add average and sum, and store scale's data average and sum

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the JSFiddle example and reading the range function, scales and series option behavior described in the issue. Trace when scale data min/max and series min/max become available, including the init hook lifecycle. Done means the requested data statistics are exposed consistently and the example can access them at the intended lifecycle point.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.