Skip to content

Commit af563c6

Browse files
committed
Update documentation for the charts.
1 parent 25783a4 commit af563c6

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

spork/charts.janet

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
### dependencies is very useful to have.
1111
###
1212
### Data is passed to most charts as a "data-frame", which is a table mapping keyword (or any Janet value) column names
13-
### to arrays of data points, usually numbers. The columns of a dataframe are considered to be the sorted keys of table or struct.
13+
### to arrays of data points, usually numbers. The columns of a data-frame are considered to be the sorted keys of table or struct.
1414
### Many visualizations will infer the X column as the "first" column and the Y column as the second column.
1515
###
1616
### Data frame example:
@@ -34,11 +34,11 @@
3434
### [x] - bar chart
3535
### [x] - area chart
3636
### [x] - horizontal bar charts
37-
### [ ] - multi-bar charts
37+
### [x] - multi-bar charts
3838
### [ ] - flame graph
39-
### [ ] - packing chart (alternative to pie-charts)
39+
### [x] - packing chart (treemap, alternative to pie-charts)
4040
### [x] - heat map
41-
### [ ] - more graphics for scatter plots besides rings.
41+
### [x] - more graphics for scatter plots besides rings.
4242
### [ ] - error bars on line chart
4343
### [ ] - fill between chart
4444
### [ ] - attributed text for captions and annotations
@@ -1389,7 +1389,7 @@
13891389
* :cell-text-fn - Function `(cell-text-fn x y)` that returns an optional string to render for each cell. If the function evaluates to nil, no text will be drawn for that cell.
13901390
13911391
Data Frame Input
1392-
* :data - a dataframe table that contains a grid of cell
1392+
* :data - a data-frame table that contains a grid of cell
13931393
* :data-scale - map numeric data to a [0.0, 1.0] range with a scale factor or function. Is the constant 1.0 by default.
13941394
* :xs - a list of x columns - these are keys in `data`
13951395
* :ys - (optional) keys into each column - by default this is just (range num-rows-in-data).
@@ -1595,9 +1595,9 @@
15951595
{:x xs :y ys})
15961596

15971597
(defn- convert-to-nested
1598-
"Convert the dataframes to a nested representation, such that the label-column
1599-
is used to group rows. The grouped rows will be combined into a sub-dataframe that lives
1600-
inside another cell in the main dataframe. This is an unnatural representation but is convenient
1598+
"Convert the data-frames to a nested representation, such that the label-column
1599+
is used to group rows. The grouped rows will be combined into a sub-data-frame that lives
1600+
inside another cell in the main data-frame. This is an unnatural representation but is convenient
16011601
for rendering packing charts with hierarchical data."
16021602
[df x-column area-column label-column]
16031603
(def df-columns (sort (keys df)))
@@ -1614,7 +1614,7 @@
16141614
(append-row new-df i)
16151615
(let [sub-df (or (get nested-dfs label-category) (set (nested-dfs label-category) (make-new)))]
16161616
(append-row sub-df i))))
1617-
# Add the nested dataframes back to our copy of the original data-frame with the groupings removed.
1617+
# Add the nested data-frames back to our copy of the original data-frame with the groupings removed.
16181618
(eachp [cat-label nested-df] nested-dfs
16191619
(def summed-area (sum (get nested-df area-column)))
16201620
(put nested-df label-column nil)
@@ -1630,7 +1630,7 @@
16301630

16311631
(defn plot-packing-chart
16321632
```
1633-
Draw a packing chart (relative area chart). Plot boxes for each value who sizes are proportianal to the value
1633+
Draw a packing chart (a.k.a relative area chart or treemap). Plot boxes for each value who sizes are proportional to the value
16341634
they represent. A more versatile and compact alternative to pie charts, especially when there are many categories.
16351635
Returns either a new gfx2d/image or the passed-in :canvas.
16361636
@@ -1645,16 +1645,16 @@
16451645
16461646
Data Frame Input:
16471647
* :data - a data-frame table that contains a grid of cell
1648-
* :x-column - a column name to use a the category identifiers. Defaults to the first column.
1648+
* :x-column - a column name to use the category identifiers. Defaults to the first column.
16491649
* :y-column - a column name to use for the area quantities. Defaults to the second column
16501650
* :c-column - a column name to use for color grading. Defaults to the same as the y-column, but mapped to a range from 0 to 1, such that
1651-
the minimum value is a color paramter of 0 and the maximum has a color parameter of 1.
1651+
the minimum value is a color parameter of 0 and the maximum has a color parameter of 1.
16521652
* :group-column - a column name that contains a label for grouping areas. Optional.
16531653
16541654
Layout Parameters:
16551655
* :omega - a number between 0 and 1 used to decide how to split rectangular areas. The default is 0.5
16561656
* :sort-bins - If true, will sort bins from largest to smallest before layout. This usually results in better-looking charts. Default is true.
1657-
For custom bin ordering before layout, use a dataframe input, set sort-bins to false, and order the rows as desired.
1657+
For custom bin ordering before layout, use a data-frame input, set sort-bins to false, and order the rows as desired.
16581658
16591659
Color and Theme:
16601660
* :font - Font to use to draw text inside areas.
@@ -1709,6 +1709,7 @@
17091709
# Use zipped data for sorting
17101710
(def zipped-data (map tuple xs ys cs ns))
17111711

1712+
# Nesting with labeled sub-groups
17121713
(defn- do-subgroup
17131714
[x y w h lab children]
17141715
(def text (string lab))

0 commit comments

Comments
 (0)