Commit b0a39e6
committed
Significant Painter API and SVG rendering changes
Changes put together because both required significant changes to the SVG validation in tests. These changes were carefully examined to make sure there were no negative visual issues.
**Painter API changes**:
The Painter API can be confusing, with some functions depending on the state of the painter.
This changes the Painter API (internal and external) so that style attributes (ie FillColor, StrokeColor, StrokeWidth, etc) are not stateful. Instead the relevant style values are accepted as arguments to the draw action.
This creates an easier to use API. It also addresses a complexity if multiple Child painters are used together with different drawing state.
Additionally the Painter configuration has changed. A default theme and default font is still available to set in the Painter, however the `ValueFormatter` was removed. Instead this config field only exists in charts options which make use of a set formatter.
Test SVG's resulted from two primary aspects of this change:
* Measuring text not representing the actual text size due to the font style not set correctly in the Painter
* A fill style attribute being specified when it has no effect (since style was set due to prior operations)
In general the exposed functions were general examined to ensure all exposed functions are both useful, and easy to use. This resulted in a number of argument changes, which should be detailed in the go docs.
**vector_renderer (SVG) improvements**:
This change minimizes and simplifies the SVG output through the following:
* If stroke width is zero, or the color is transparent only `stroke:none` will be set, instead of the prior `stroke-width:0;stroke:none` value
* Colors will be specified by name if possible, otherwise an RGB or RGBA string will still be used
* If the text or path is empty, nothing will be inserted into the svg.
These three changes reduce the SVG size. Specifying the color names could potentially allow color shade changes using CSS.
As a bonus, additional colors are now specified in the `drawing` package.
----
SVG changes are always painful, these were careful evaluated to ensure this is an improvement in both the Painter functionality and SVG results.1 parent 6420826 commit b0a39e6
File tree
40 files changed
+1019
-926
lines changed- chartdraw
- drawing
- examples/chinese
40 files changed
+1019
-926
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | 6 | | |
9 | 7 | | |
10 | 8 | | |
| |||
97 | 95 | | |
98 | 96 | | |
99 | 97 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 98 | + | |
117 | 99 | | |
118 | 100 | | |
119 | 101 | | |
| |||
227 | 209 | | |
228 | 210 | | |
229 | 211 | | |
| 212 | + | |
230 | 213 | | |
231 | 214 | | |
232 | 215 | | |
233 | 216 | | |
234 | 217 | | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
241 | 226 | | |
242 | 227 | | |
243 | 228 | | |
244 | 229 | | |
245 | | - | |
| 230 | + | |
246 | 231 | | |
247 | 232 | | |
248 | 233 | | |
| |||
254 | 239 | | |
255 | 240 | | |
256 | 241 | | |
| 242 | + | |
257 | 243 | | |
258 | 244 | | |
259 | 245 | | |
| |||
264 | 250 | | |
265 | 251 | | |
266 | 252 | | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | 253 | | |
271 | 254 | | |
272 | 255 | | |
| |||
280 | 263 | | |
281 | 264 | | |
282 | 265 | | |
283 | | - | |
| 266 | + | |
284 | 267 | | |
285 | 268 | | |
286 | 269 | | |
| |||
293 | 276 | | |
294 | 277 | | |
295 | 278 | | |
296 | | - | |
| 279 | + | |
297 | 280 | | |
298 | 281 | | |
299 | 282 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
| |||
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
| 44 | + | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
111 | | - | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | 114 | | |
118 | 115 | | |
119 | 116 | | |
120 | 117 | | |
121 | 118 | | |
122 | 119 | | |
123 | 120 | | |
124 | | - | |
| 121 | + | |
| 122 | + | |
125 | 123 | | |
126 | 124 | | |
127 | 125 | | |
128 | 126 | | |
129 | 127 | | |
130 | 128 | | |
131 | 129 | | |
132 | | - | |
| 130 | + | |
133 | 131 | | |
134 | 132 | | |
135 | 133 | | |
| |||
147 | 145 | | |
148 | 146 | | |
149 | 147 | | |
150 | | - | |
| 148 | + | |
151 | 149 | | |
152 | 150 | | |
153 | 151 | | |
| |||
196 | 194 | | |
197 | 195 | | |
198 | 196 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
206 | 205 | | |
207 | 206 | | |
208 | 207 | | |
| |||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | | - | |
| 23 | + | |
22 | 24 | | |
23 | | - | |
| 25 | + | |
24 | 26 | | |
25 | | - | |
| 27 | + | |
26 | 28 | | |
27 | | - | |
| 29 | + | |
28 | 30 | | |
29 | | - | |
| 31 | + | |
30 | 32 | | |
31 | | - | |
| 33 | + | |
32 | 34 | | |
33 | | - | |
| 35 | + | |
34 | 36 | | |
35 | | - | |
| 37 | + | |
36 | 38 | | |
37 | | - | |
| 39 | + | |
38 | 40 | | |
39 | | - | |
| 41 | + | |
40 | 42 | | |
41 | | - | |
| 43 | + | |
42 | 44 | | |
43 | | - | |
| 45 | + | |
44 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
45 | 80 | | |
46 | 81 | | |
47 | 82 | | |
| |||
129 | 164 | | |
130 | 165 | | |
131 | 166 | | |
| 167 | + | |
| 168 | + | |
132 | 169 | | |
133 | 170 | | |
134 | 171 | | |
| |||
153 | 190 | | |
154 | 191 | | |
155 | 192 | | |
156 | | - | |
| 193 | + | |
157 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
158 | 225 | | |
159 | 226 | | |
160 | 227 | | |
| |||
235 | 302 | | |
236 | 303 | | |
237 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
238 | 352 | | |
239 | 353 | | |
240 | 354 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
153 | 156 | | |
154 | 157 | | |
155 | 158 | | |
| |||
0 commit comments