|
46 | 46 | (defdyn *background-color* "Default background color for chart rendering") |
47 | 47 | (defdyn *grid-color* "Default color for grid lines") |
48 | 48 | (defdyn *padding* "Default padding for charts") |
49 | | -(defdyn *color-seed* "Random seed to use when picking psuedo-random colors for charts") |
| 49 | +(defdyn *color-seed* "Random seed to use when picking pseudo-random colors for charts") |
50 | 50 |
|
51 | 51 | # Default defaults |
52 | 52 | (def- default-font :olive) |
|
405 | 405 |
|
406 | 406 | (defn- draw-color-map |
407 | 407 | ``` |
408 | | - Draw a rectable that describes a color-map. Will draw the gradient |
| 408 | + Draw a rectangle that describes a color-map. Will draw the gradient |
409 | 409 | horizontally by default, but layout can be one of :h, :v, :horizontal, or :vertical. |
410 | 410 | ``` |
411 | 411 | [canvas color-map x y w h &opt layout] |
|
1070 | 1070 | * :num-rows - Number of rows to draw. |
1071 | 1071 | * :box-gap - Number of pixels between boxes on the heat map |
1072 | 1072 | * :font - font used to draw optional text in cells |
1073 | | - * :cell-text-color - color of text, defaults to black |
| 1073 | + * :cell-text-color - color of text, defaults to black or white depending on the cell color |
1074 | 1074 |
|
1075 | 1075 | Returns the modified original canvas. |
1076 | 1076 | ``` |
|
1091 | 1091 | (def {:width canvas-width :height canvas-height} (g/unpack canvas)) |
1092 | 1092 | (default box-gap 0) |
1093 | 1093 | (default font (dyn *font* default-font)) |
1094 | | - (default cell-text-color nil) # (dyn *text-color* default-text-color)) |
1095 | 1094 |
|
1096 | 1095 | # Calculate box sizes - not always integers! |
1097 | 1096 | (def box-width (- (/ (- canvas-width box-gap) num-columns) box-gap)) |
|
1109 | 1108 | (g/fill-rect canvas pixel-x pixel-y (- next-pixel-x pixel-x) (- next-pixel-y pixel-y) color) |
1110 | 1109 |
|
1111 | 1110 | # Per cell text |
1112 | | - # TODO - get text color by inverting cell color? |
1113 | 1111 | (when-let [text (and cell-text-fn (cell-text-fn x y))] |
1114 | 1112 | (def [w h] (text-measure text font 1 0)) |
1115 | 1113 | (def text-x (math/floor (- (mean [pixel-x next-pixel-x]) (/ w 2)))) |
|
1140 | 1138 | Data Frame Input |
1141 | 1139 | * :data - a dataframe table that contains a grid of cell |
1142 | 1140 | * :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. |
1143 | | - and maximum values in data to 0 and 1 respectively. |
1144 | 1141 | * :xs - a list of x columns - these are keys in `data` |
1145 | 1142 | * :ys - (optional) keys into each column - by default this is just (range num-rows-in-data). |
1146 | 1143 |
|
|
0 commit comments