Skip to content

Stream 2

Info - How to setup Chart
import pandas as pd
from ipyvizzu import Chart, Data, Config, Style

data_frame = pd.read_csv(
    "https://ipyvizzu.vizzuhq.com/0.15/assets/data/music_industry_history_1.csv",
    dtype={"Year": str, "Timeseries": str},
)
data = Data()
data.add_data_frame(data_frame)

chart = Chart()
chart.animate(data)
  • fix the X-axis-range
  • filter the Diemsion data series on the Y-axis step-by-step
method = """
      let year = parseFloat(event.data.text);
      if (!event.data.text.includes("$") && !isNaN(year) && year % 5 != 0)
        event.preventDefault();
    """
handler = chart.on("plot-axis-label-draw", method)

chart.animate(
    Config(
        {
            "channels": {
                "x": {"set": "Year", "range": {"max": "48"}},
                "y": ["Revenue [$]", "Format"],
                "color": "Format",
            },
            "geometry": "area",
            "align": "center",
        }
    ),
    Style(
        {"plot": {"yAxis": {"label": {"numberScale": "K, M, B, T"}}}}
    ),
)

chart.animate(
    data.filter(
        """
  (record) =>
  record.Format == "Tapes" || record.Format == "Vinyl"
  """
    ),
    Config({}),
)

chart.animate(
    data.filter(
        """
  (record) =>
  record.Format == "Tapes" ||
  record.Format == "Cassette" ||
  record.Format == "Vinyl"
  """
    ),
    Config({}),
)

chart.animate(
    data.filter(
        """
  (record) =>
  record.Format == "DVD" ||
  record.Format == "Tapes" ||
  record.Format == "Cassette" ||
  record.Format == "Vinyl" ||
  record.Format == "CD"
  """
    ),
    Config({}),
)

chart.animate(
    data.filter(
        """
  (record) =>
  record.Format == "DVD" ||
  record.Format == "Other" ||
  record.Format == "Tapes" ||
  record.Format == "Cassette" ||
  record.Format == "Vinyl" ||
  record.Format == "CD"
  """
    ),
    Config({}),
)

chart.animate(
    data.filter(
        """
  (record) =>
  record.Format == "DVD" ||
  record.Format == "Other" ||
  record.Format == "Tapes" ||
  record.Format == "Download" ||
  record.Format == "Cassette" ||
  record.Format == "Vinyl" ||
  record.Format == "CD"
  """
    ),
    Config({}),
)

chart.animate(
    data.filter(
        """
  (record) =>
  record.Format == "DVD" ||
  record.Format == "Other" ||
  record.Format == "Tapes" ||
  record.Format == "Download" ||
  record.Format == "Streaming" ||
  record.Format == "Cassette" ||
  record.Format == "Vinyl" ||
  record.Format == "CD"
  """
    ),
    Config({}),
)

chart.feature("tooltip", True)