|
80 | 80 | let position = layer.at("position", default: "identity") |
81 | 81 | let ymin-col = mapping.at("ymin", default: none) |
82 | 82 | let ymax-col = mapping.at("ymax", default: none) |
83 | | - let use-minmax = (position == "stack" or position == "fill") and ymin-col != none and ymax-col != none |
| 83 | + let use-minmax = ( |
| 84 | + (position == "stack" or position == "fill") |
| 85 | + and ymin-col != none |
| 86 | + and ymax-col != none |
| 87 | + ) |
84 | 88 |
|
85 | 89 | let fill-col = mapping.at("fill", default: none) |
86 | 90 | let fill-trained = ctx.trained.at("fill", default: none) |
87 | | - let default-fill = if layer.params.fill != auto and layer.params.fill != none { |
| 91 | + let default-fill = if ( |
| 92 | + layer.params.fill != auto and layer.params.fill != none |
| 93 | + ) { |
88 | 94 | layer.params.fill |
89 | 95 | } else { |
90 | 96 | rgb("#4c78a8") |
|
97 | 103 | ) |
98 | 104 |
|
99 | 105 | let (px-lo, px-hi) = ctx.px-range |
100 | | - let category-width = if x-trained.type == "discrete" and x-trained.domain.len() > 0 { |
| 106 | + let category-width = if ( |
| 107 | + x-trained.type == "discrete" and x-trained.domain.len() > 0 |
| 108 | + ) { |
101 | 109 | (px-hi - px-lo) / x-trained.domain.len() |
102 | 110 | } else { |
103 | 111 | // Continuous x: infer from minimum gap between unique values. |
104 | | - let xs = data.map(r => parse-number(r.at(mapping.x, default: none))).filter(v => v != none) |
| 112 | + let xs = data |
| 113 | + .map(r => parse-number(r.at(mapping.x, default: none))) |
| 114 | + .filter(v => v != none) |
105 | 115 | let (d-lo, d-hi) = x-trained.domain |
106 | 116 | if xs.len() < 2 or d-hi == d-lo { |
107 | 117 | (px-hi - px-lo) / 10 |
108 | 118 | } else { |
109 | 119 | let sorted = xs.dedup().sorted() |
110 | | - let gaps = range(sorted.len() - 1).map(i => sorted.at(i + 1) - sorted.at(i)) |
| 120 | + let gaps = range(sorted.len() - 1).map(i => ( |
| 121 | + sorted.at(i + 1) - sorted.at(i) |
| 122 | + )) |
111 | 123 | let min-gap = calc.min(..gaps) |
112 | 124 | min-gap * (px-hi - px-lo) / (d-hi - d-lo) |
113 | 125 | } |
|
116 | 128 | let half = category-width * bar-width-fraction / 2 |
117 | 129 |
|
118 | 130 | for row in data { |
119 | | - let cx = map-position(x-trained, row.at(mapping.x, default: none), ctx.px-range) |
| 131 | + let cx = map-position( |
| 132 | + x-trained, |
| 133 | + row.at(mapping.x, default: none), |
| 134 | + ctx.px-range, |
| 135 | + ) |
120 | 136 | if cx == none { continue } |
121 | 137 |
|
122 | 138 | let (y-lo-cy, y-hi-cy) = if use-minmax { |
|
144 | 160 | } |
145 | 161 |
|
146 | 162 | let colour = if fill-col != none and fill-trained != none { |
147 | | - (ctx.resolve-colour)(fill-trained, row.at(fill-col, default: none), ctx.palette) |
| 163 | + (ctx.resolve-colour)( |
| 164 | + fill-trained, |
| 165 | + row.at(fill-col, default: none), |
| 166 | + ctx.palette, |
| 167 | + ) |
148 | 168 | } else { default-fill } |
149 | 169 | let alpha = layer.params.alpha |
150 | | - let final-fill = if alpha < 1 { colour.transparentize((1 - alpha) * 100%) } else { colour } |
| 170 | + let final-fill = if alpha < 1 { |
| 171 | + colour.transparentize((1 - alpha) * 100%) |
| 172 | + } else { colour } |
151 | 173 |
|
152 | 174 | cetz.draw.rect( |
153 | 175 | (centre - bar-half, y-lo-cy), |
154 | 176 | (centre + bar-half, y-hi-cy), |
155 | 177 | fill: final-fill, |
156 | | - stroke: if layer.params.stroke == none { none } else { layer.params.stroke }, |
| 178 | + stroke: if layer.params.stroke == none { none } else { |
| 179 | + layer.params.stroke |
| 180 | + }, |
157 | 181 | ) |
158 | 182 | } |
159 | 183 | } |
0 commit comments