To build a chart with Vizzu, you have to add data series to the channels.
The first step is to create a simple column chart, adding one of the dimensions (Genre) to the x-axis and the measure (Popularity) to the y-axis using the set property.
In the next step, the chart is rearranged by putting both series on the y-axis using once again the set property, resulting in a single column chart. Vizzu automatically animates between the initial state and this one.
Or instead of set, you can use attach and detach to add or remove series to/from the channels.
Using attach & detach makes it easier to build your animated charts step-by-step, however you either have to keep in mind what you had on which channel in the previous step or add the following code to access the actual configuration of the chart.
from ipyvizzu import Chart, Data, Config
data = Data()
data.add_dimension('Genres', [ 'Pop', 'Rock', 'Jazz', 'Metal'])
data.add_dimension('Types', [ 'Hard', 'Smooth', 'Experimental' ])
data.add_measure(
'Popularity',
[
[114, 96, 78, 52],
[56, 36, 174, 121],
[127, 83, 94, 58],
]
)
chart = Chart()
chart.animate(data)
chart.animate(Config({"channels": {"y": {"set": "Popularity"}, "x": {"set": "Genres"}}}))
chart.animate(Config({"channels": {"y": {"set": ["Popularity", "Genres"]}, "x": {"set": None}}}))
chart.animate(Config({"channels": {"y": {"detach": "Popularity"}, "x": {"attach": "Popularity"}}}))
chart.show()
Setting the chart title with the title command.
from ipyvizzu import Chart, Data, Config
data = Data()
data.add_dimension('Genres', [ 'Pop', 'Rock', 'Jazz', 'Metal'])
data.add_dimension('Types', [ 'Hard', 'Smooth', 'Experimental' ])
data.add_measure(
'Popularity',
[
[114, 96, 78, 52],
[56, 36, 174, 121],
[127, 83, 94, 58],
]
)
chart = Chart()
chart.animate(data)
chart.animate(Config({"channels": {"y": {"set": "Popularity"}, "x": {"set": "Genres"}}}))
chart.animate(title="My first chart")
chart.show()
Switching on the tooltips that appear on the chart elements when the user hovers over them with their mouse by adding the (tooltip, true) parameters to the chart.feature method.
from ipyvizzu import Chart, Data, Config
data = Data()
data.add_dimension('Genres', [ 'Pop', 'Rock', 'Jazz', 'Metal'])
data.add_dimension('Types', [ 'Hard', 'Smooth', 'Experimental' ])
data.add_measure(
'Popularity',
[
[114, 96, 78, 52],
[56, 36, 174, 121],
[127, 83, 94, 58],
]
)
chart = Chart()
chart.animate(data)
chart.animate(Config({"channels": {"y": {"set": "Popularity"}, "x": {"set": "Genres"}}}))
chart.feature("tooltip", True)
chart.show()
In Vizzu you can set the geometric elements used to represent your data by the geometry property within the config object.
from ipyvizzu import Chart, Data, Config
data = Data()
data.add_dimension('Genres', [ 'Pop', 'Rock', 'Jazz', 'Metal'])
data.add_dimension('Types', [ 'Hard', 'Smooth', 'Experimental' ])
data.add_measure(
'Popularity',
[
[114, 96, 78, 52],
[56, 36, 174, 121],
[127, 83, 94, 58],
]
)
chart = Chart()
chart.animate(data)
chart.animate(Config({"channels": {"y": {"set": "Popularity"}, "x": {"set": "Genres"}}}))
chart.animate(Config({"geometry": "area"}))
chart.animate(Config({"geometry": "line"}))
chart.animate(Config({"geometry": "circle"}))
chart.animate(Config({"geometry": "rectangle"}))
chart.show()