Skip to content

Commit 2bd686c

Browse files
committed
Tutorial section added for chart presets.
1 parent cc0b39e commit 2bd686c

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
## Chart presets
2+
3+
In this tutorial, we have shown how you can create charts with Vizzu
4+
using a chart type-agnostic, uniform way, without being limited to a predefined
5+
set of available charts. But sometimes, we know exactly the chart type we
6+
would like to use, and it is easier to start with that, skipping all the
7+
necessary configurations to build it from scratch. For this reason, Vizzu
8+
provides preset configurations for many known chart types
9+
(for all available presets, see the [preset galery](#chart-presets)).
10+
11+
Presets are available through methods of the 'presets' static property of the Vizzu class.
12+
These methods are returning chart configuration objects which can be passed to
13+
the 'animate' method. Let's create a Stacked Bubble chart.
14+
15+
```javascript { "title": "Using a preset" }
16+
chart.animate(Vizzu.presets.stackedBubble({
17+
size: 'Popularity',
18+
color: 'Kinds',
19+
stackedBy: 'Genres'
20+
}));
21+
```
22+
23+
Presets will override all the channels, so previously set series will be
24+
removed from the chart. They will also explicitly set most of the chart
25+
configuration parameters since these will effectively result in the selected
26+
chart type. Exceptions are the 'legend', 'title', 'reverse', and 'sort' properties
27+
which can be set along with the preset. Let's sort the next preset chart by values.
28+
29+
```javascript { "title": "Setting sorting for a preset" }
30+
chart.animate(Vizzu.presets.radialStackedBar({
31+
angle: 'Popularity',
32+
radius: 'Genres',
33+
stackedBy: 'Kinds',
34+
sort: 'byValue'
35+
}));
36+
```
37+
38+
Presets will affect only the chart configuration. If you need to set the styles
39+
or the underlying data, you can use the more verbose syntax below, explicitly
40+
pass the preset to the 'config' property of the animate method's parameter.
41+
42+
```javascript { "title": "Setting style for a preset" }
43+
chart.animate({
44+
config: Vizzu.presets.radialBar({
45+
angle: 'Popularity',
46+
radius: 'Genres',
47+
}),
48+
style: {
49+
'plot.xAxis.interlacing.color': '#ffffff00'
50+
}
51+
});
52+
```
53+
54+
As you can see, the preset won't override the previously configured sorting,
55+
and it won't affect the rest of the chart config parameters mentioned above,
56+
which can be set along with the preset.

0 commit comments

Comments
 (0)