reveal

Docs: https://vlaaad.github.io/reveal/ Source: https://github.com/vlaaad/reveal
wilkerlucio 2020-09-21T17:15:15.012300Z

hello, Im using the bar chart to try a chart with multiple series, my data looks like this:

{:impl-a {0 25.299999862909317,
           7 19.39000003039837,
           1 21.464999997988343,
           4 20.795000018551946,
           15 20.76500002294779,
           13 21.65500004775822,
           6 19.154999870806932,
           17 20.804999861866236,
           3 19.88500007428229,
           12 23.38000014424324,
           2 21.63999993354082,
           19 23.924999870359898,
           11 22.635000059381127,
           9 25.545000098645687,
           5 24.910000152885914,
           14 19.585000118240714,
           16 20.885000005364418,
           10 20.819999976083636,
           18 20.195000106468797,
           8 19.580000080168247},
 :impl-b {0 4.239999921992421,
         7 17.385000130161643,
         1 6.2200000975281,
         4 9.77999996393919,
         15 29.254999943077564,
         13 25.88499989360571,
         6 12.69999984651804,
         17 38.07000000961125,
         3 7.009999826550484,
         12 24.105000076815486,
         2 5.545000080019236,
         19 41.569999884814024,
         11 23.08499999344349,
         9 24.960000067949295,
         5 12.189999921247363,
         14 29.519999865442514,
         16 35.47999984584749,
         10 20.249999826774,
         18 40.43000005185604,
         8 22.23999984562397}}

wilkerlucio 2020-09-21T17:15:52.012600Z

so when I plot it looks like this:

wilkerlucio 2020-09-21T17:16:34.013800Z

but in this chart, the order of the groups is important (I want it to go from 0 to 18, in order), is there any way to control the order of the series?

vlaaad 2020-09-21T17:46:09.014100Z

Hmm, sorted maps worked for me:

{:a (into (sorted-map) (map #(vector % (rand-int 100))) (range 10))
 :b (into (sorted-map) (map #(vector % (rand-int 100))) (range 10))}

vlaaad 2020-09-21T17:47:32.014300Z

@wilkerlucio ^

wilkerlucio 2020-09-21T17:49:45.015900Z

@vlaaad the problem to me is that I'm generating the data in CLJS and just copying over to a Reveal window (since I can't use cljs directly), and if I remember correctly, sorted-maps will sort based on values, not on keys, or I'm confusing things?

wilkerlucio 2020-09-21T17:50:21.016600Z

what you think about having some extra data to control the order? so it could be made explicit on the data itself

vlaaad 2020-09-21T17:50:39.017Z

Also, if the order matters, wouldn't it make more sense to use lists with line chart instead of maps?

vlaaad 2020-09-21T17:50:43.017200Z

e.g.

{:a (repeatedly 18 #(rand-int 100))
 :b (repeatedly 18 #(rand-int 100))}

wilkerlucio 2020-09-21T17:51:00.017600Z

maybe, I didn't knew about this option, let me try 🙂

seancorfield 2020-09-21T17:51:17.018200Z

sorted-map works on the keys, not values (I just tried it in a REPL)

😄 1
vlaaad 2020-09-21T17:51:24.018400Z

sorted-map sorts on keys!

😄 1
seancorfield 2020-09-21T17:51:40.018700Z

jinx 🙂

vlaaad 2020-09-21T17:52:01.019Z

😄

wilkerlucio 2020-09-21T17:54:16.019400Z

@vlaaad yup, using as a vector there works great!

👍 1
vlaaad 2020-09-21T17:58:40.019900Z

hmm, I think sorting chart series/keys makes sense anyway.. I'll think about that, thank you for input!