|
10 | 10 | ### dependencies is very useful to have. |
11 | 11 | ### |
12 | 12 | ### 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. |
14 | 14 | ### Many visualizations will infer the X column as the "first" column and the Y column as the second column. |
15 | 15 | ### |
16 | 16 | ### Data frame example: |
|
34 | 34 | ### [x] - bar chart |
35 | 35 | ### [x] - area chart |
36 | 36 | ### [x] - horizontal bar charts |
37 | | -### [ ] - multi-bar charts |
| 37 | +### [x] - multi-bar charts |
38 | 38 | ### [ ] - flame graph |
39 | | -### [ ] - packing chart (alternative to pie-charts) |
| 39 | +### [x] - packing chart (treemap, alternative to pie-charts) |
40 | 40 | ### [x] - heat map |
41 | | -### [ ] - more graphics for scatter plots besides rings. |
| 41 | +### [x] - more graphics for scatter plots besides rings. |
42 | 42 | ### [ ] - error bars on line chart |
43 | 43 | ### [ ] - fill between chart |
44 | 44 | ### [ ] - attributed text for captions and annotations |
|
1389 | 1389 | * :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. |
1390 | 1390 |
|
1391 | 1391 | 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 |
1393 | 1393 | * :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. |
1394 | 1394 | * :xs - a list of x columns - these are keys in `data` |
1395 | 1395 | * :ys - (optional) keys into each column - by default this is just (range num-rows-in-data). |
|
1595 | 1595 | {:x xs :y ys}) |
1596 | 1596 |
|
1597 | 1597 | (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 |
1601 | 1601 | for rendering packing charts with hierarchical data." |
1602 | 1602 | [df x-column area-column label-column] |
1603 | 1603 | (def df-columns (sort (keys df))) |
|
1614 | 1614 | (append-row new-df i) |
1615 | 1615 | (let [sub-df (or (get nested-dfs label-category) (set (nested-dfs label-category) (make-new)))] |
1616 | 1616 | (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. |
1618 | 1618 | (eachp [cat-label nested-df] nested-dfs |
1619 | 1619 | (def summed-area (sum (get nested-df area-column))) |
1620 | 1620 | (put nested-df label-column nil) |
|
1630 | 1630 |
|
1631 | 1631 | (defn plot-packing-chart |
1632 | 1632 | ``` |
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 |
1634 | 1634 | they represent. A more versatile and compact alternative to pie charts, especially when there are many categories. |
1635 | 1635 | Returns either a new gfx2d/image or the passed-in :canvas. |
1636 | 1636 |
|
|
1645 | 1645 |
|
1646 | 1646 | Data Frame Input: |
1647 | 1647 | * :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. |
1649 | 1649 | * :y-column - a column name to use for the area quantities. Defaults to the second column |
1650 | 1650 | * :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. |
1652 | 1652 | * :group-column - a column name that contains a label for grouping areas. Optional. |
1653 | 1653 |
|
1654 | 1654 | Layout Parameters: |
1655 | 1655 | * :omega - a number between 0 and 1 used to decide how to split rectangular areas. The default is 0.5 |
1656 | 1656 | * :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. |
1658 | 1658 |
|
1659 | 1659 | Color and Theme: |
1660 | 1660 | * :font - Font to use to draw text inside areas. |
|
1709 | 1709 | # Use zipped data for sorting |
1710 | 1710 | (def zipped-data (map tuple xs ys cs ns)) |
1711 | 1711 |
|
| 1712 | + # Nesting with labeled sub-groups |
1712 | 1713 | (defn- do-subgroup |
1713 | 1714 | [x y w h lab children] |
1714 | 1715 | (def text (string lab)) |
|
0 commit comments