Skip to content

Commit 6f98771

Browse files
committed
Add testing for horizontal charts.
Bar and area charts have slightly different drawing logic when horizontal. Other charts should fine just by transforming the mapping from metric-space -> pixel-space.
1 parent 72fc85d commit 6f98771

5 files changed

Lines changed: 23 additions & 1 deletion

File tree

spork/charts.janet

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
### [x] - stippled grid lines
3131
### [x] - bar chart
3232
### [x] - area chart
33-
### [ ] - horizontal bar charts
33+
### [x] - horizontal bar charts
3434
### [ ] - multi-bar charts
3535
### [ ] - flame graph
3636
### [ ] - packing chart
@@ -41,6 +41,7 @@
4141
### [x] - handle nils in y-columns for sparse data
4242
### [x] - easier custom chart annotations in the metric space (horizontal lines, vertical lines, etc.)
4343
### [ ] - captions and sub-titles
44+
### [ ] - labeling data points
4445

4546
(import spork/gfx2d :as g)
4647

25.8 KB
Loading

test/gold/horizontal_bar_chart.png

20.5 KB
Loading
43.9 KB
Loading

test/suite-gfx2d.janet

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,4 +484,25 @@
484484

485485
(test-super-minimal-chart)
486486

487+
(defn test-horizontal-chart
488+
[line-style]
489+
(def c
490+
(charts/line-chart
491+
:title (string "H " line-style " Chart (sine waves)")
492+
:data {:x (range 101)
493+
:y (seq [x :range [0 100]] (math/cos (* x 0.2)))
494+
:z (seq [x :range [0 100]] (math/sin (* x 0.2)))}
495+
:line-style line-style
496+
:color-map {:y blue :z red}
497+
:super-sample 4
498+
:transpose true
499+
:bar-padding 2
500+
:width 500
501+
:height 500))
502+
(check-image c (string "horizontal_" line-style "_chart.png")))
503+
504+
(test-horizontal-chart :area)
505+
(test-horizontal-chart :bar)
506+
(test-horizontal-chart :stroke)
507+
487508
(end-suite)

0 commit comments

Comments
 (0)