Hi <@UBXMWAA69> the order of the series is simply ...
# data2viz
p
Hi @Joffrey the order of the series is simply the order of the given items in your list, check this very simple example: https://play.data2viz.io/sketches/XYNkyJ/edit/, if you change the way
SplitProfit
are mapped, then the series will be drawn in a different order.
j
Ah I see, for some reason I didn't think of changing that part, because the series could technically be intertwined. So, if I understand correctly, the series order is determined by the order of appearance of a series's first item in the general data list, right?
👍 1
p
I'm interested in your feedback about this, if you think that some kind of sort-option is needed or if you can manage all your needs with the actual features.
j
I think technically this gives enough freedom to sort as desired, at least in my case which is similar to the example (I explode a data class into a list of N items, one for each of the desired series). Because I could do any preprocessing and decide on the order based on that. I wonder if options would be necessary for cases that are not like this, and where the data is intertwined in a way that is less controlled by the dev configuring the chart.
p
You actually have the
IndexOfSeries
in the
Datum
object, may be we can have some sort of additionnal property like :
seriesOrder: (Datum<DOMAIN>) -> Int
with a default value
{ Datum.indexOfSeries }
Thanks for your feedback, I'll create an open point on our issue tracker about this
j
For reference, in MUI X Charts, they have a few options to decide how to stack the series: https://mui.com/x/react-charts/stacking/#stack-order But in their case the series are provided as separate data lists (not a single list of domain items, where one property decide the series), so saying things like "Respect the order the series are provided in" doesn't make sense for Charts.kt.
👀 1
To be frank I wish we could define the series as a list of dimensions in charts.kt. In the example that you linked, you also had to go through the trouble of flat-mapping your nice data class into a new class with (x, y, type) properties. Imagine if you could write instead:
Copy code
vc.chart(profits) {
    title = "Profits by categories"

    val year = discrete( { domain.year } )

    val series = listOf(
       series("Corporate", { domain.corporate }),
       series("Domestic", { domain.domestic }),
       series("Financial", { domain.financial }),
       series("Non-financial", { domain.nonFinancial }),
    )

    stackedArea(year, series) {
        stacking = Stacking.Standard
    }
}
p
Right, this is another way and perfectly legit....
j
I noticed a
stack<>()
top-level function that might make the flatmapping easier, though. Maybe that's a better way to play nice with the current API surface. Is this something you intend to document/use in examples?
p
The "series" dimension is currently under reworking, as everyone has his own way to visualize it (this thread proves it), thanks for the tips we'll try to think on the best and most intuitive way to use it in our API.
❤️ 1
j
Thanks, that's good to know! And thanks for the help as well
👍 1