Replies: 1 comment
|
Two of these are now open:
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'm new to contributing here. Using Superset with a real dataset for the first
time, I ran into a wall trying to style individual series, and I think the wall
is smaller than it looks. Two small PRs to offer, and one question I'd like
opinions on before writing anything.
What I'm trying to build
Grey for previous years, dark for actual, hatched for forecast, outline for
plan. A common convention in business reporting, recently formalised as ISO
24896. The point is that the fill carries the meaning, so the chart reads
without the legend and colour stays free for something else.
The screenshot is from the plugin I made, see links below. My goal would be to get closer to achieving this by adding the necessary features.
Where it stands
ECharts does all of this natively, and Superset ships it. The two properties I
need are
itemStyle.borderColor+borderWidthfor the outline, anditemStyle.decalfor the hatching.Neither has a control, so the only way to set them is Customize → ECharts
Options (JS object literals), the free-text box where you can hand-write ECharts
options that get merged over the ones Superset computed. What you write there is
checked against an allowlist schema first, and anything not on it is dropped.
decalis the only member ofitemStylemissing fromitemStyleSchema, which looks accidental.But neither is actually reachable, for a reason that has nothing to do with the
allowlist: both are per-series properties, so setting one means writing a
serieskey.mergeCustomEChartOptionsreplaces arrays instead of mergingthem:
So supplying
seriesdiscards the series Superset just computed, dataincluded. The replacement can't carry its own data either, since
dataisn't inseriesSchema(deliberately, and rightly).So that box works well for top-level objects like
xAxisandyAxis, which domerge, and cannot express anything per series at all.
Two PRs I'd like to offer
Both small, additive, and useful on their own:
decalin the options schema. One property onitemStyleSchema,mirroring ECharts'
DecalObject.borderColorandlineStyle.typearealready allowed and a decal is the same kind of value, so this mostly closes
an inconsistency. On its own it changes nothing that renders, see the
question below.
colour and width. Currently hardcoded as
splitLine: { show: !isSmallChart }in the transform. Useful well beyond my use case; the sparse look in the
chart above isn't reachable today without hand-written JSON.
The question
Neither of those makes per-series styling work. That needs the array problem
solved, and I can see two ways:
a) Merge
serieselement-wise instead of replacing it. Then{ series: [{ itemStyle: { decal: {...} } }] }would decorate the first serieswithout destroying its data, and both outline and hatching become usable
immediately through a control that already exists. This looks small, and ECharts
itself merges by index or id in
setOption. The obvious risk is that it changesbehaviour for anyone currently relying on replacement, and series indices are
positional, so it may be fragile when the series count changes.
b) A real control for per-series styling, rather than routing it through
JSON. More work, better UX, and it raises a design question I don't want to
answer alone: how should a series be addressed? Matching on the rendered series
name is the obvious answer and I'd argue against it. Names are composed from
the metric and groupby values, so a rule silently stops matching the moment
someone adds a dimension.
Is either direction something Superset wants? I'm happy to do the work, but I'd
rather find out now than arrive with a large PR. And if the answer is "this
belongs in a plugin", that's useful to know too.
Working code
All of the above is running in a fork as a self-contained plugin:
All reactions