David Vegh commited on
Commit
2783aa5
1 Parent(s): 2becd32

Update ipyvizzu_demo.ipynb

Browse files
Files changed (1) hide show
  1. ipyvizzu_demo.ipynb +45 -7
ipyvizzu_demo.ipynb CHANGED
@@ -26,7 +26,9 @@
26
  "metadata": {},
27
  "outputs": [],
28
  "source": [
29
- "gender = 'male'"
 
 
30
  ]
31
  },
32
  {
@@ -36,23 +38,57 @@
36
  "metadata": {},
37
  "outputs": [],
38
  "source": [
 
 
39
  "import pandas as pd\n",
40
  "from ipyvizzu import Chart, Data, Config\n",
41
  "\n",
42
  "\n",
43
- "data_frame = pd.read_csv('./titanic.csv')\n",
 
 
 
 
 
 
 
 
 
 
 
44
  "data = Data()\n",
 
45
  "data.add_data_frame(data_frame)\n",
46
  "\n",
47
- "chart = Chart(width=\"640px\", height=\"360px\")\n",
48
- "\n",
49
- "chart.animate(data)\n",
 
 
 
 
 
 
 
 
50
  "\n",
51
  "chart.animate(Config({\"x\": \"Count\", \"y\": \"Sex\", \"label\": \"Count\",\"title\":\"Passengers of the Titanic\"}))\n",
52
  "chart.animate(Config({\"x\": [\"Count\",\"Survived\"], \"label\": [\"Count\",\"Survived\"], \"color\": \"Survived\"}))\n",
53
  "chart.animate(Config({\"x\": \"Count\", \"y\": [\"Sex\",\"Survived\"]}))"
54
  ]
55
  },
 
 
 
 
 
 
 
 
 
 
 
 
56
  {
57
  "cell_type": "code",
58
  "execution_count": null,
@@ -60,8 +96,10 @@
60
  "metadata": {},
61
  "outputs": [],
62
  "source": [
63
- "datafilter = Data.filter(f\"record['Sex'] == '{gender}'\")\n",
64
- "chart.animate(datafilter)"
 
 
65
  ]
66
  }
67
  ],
 
26
  "metadata": {},
27
  "outputs": [],
28
  "source": [
29
+ "# configure default value\n",
30
+ "\n",
31
+ "gender = 'male'\n"
32
  ]
33
  },
34
  {
 
38
  "metadata": {},
39
  "outputs": [],
40
  "source": [
41
+ "# import pandas and ipyvizzu and initialize chart\n",
42
+ "\n",
43
  "import pandas as pd\n",
44
  "from ipyvizzu import Chart, Data, Config\n",
45
  "\n",
46
  "\n",
47
+ "chart = Chart(width=\"640px\", height=\"360px\")\n"
48
+ ]
49
+ },
50
+ {
51
+ "cell_type": "code",
52
+ "execution_count": null,
53
+ "id": "1a26e2e9",
54
+ "metadata": {},
55
+ "outputs": [],
56
+ "source": [
57
+ "# add data\n",
58
+ "\n",
59
  "data = Data()\n",
60
+ "data_frame = pd.read_csv(\"https://github.com/vizzuhq/ipyvizzu/raw/main/docs/examples/stories/titanic/titanic.csv\")\n",
61
  "data.add_data_frame(data_frame)\n",
62
  "\n",
63
+ "chart.animate(data)\n"
64
+ ]
65
+ },
66
+ {
67
+ "cell_type": "code",
68
+ "execution_count": null,
69
+ "id": "1ab7ece9",
70
+ "metadata": {},
71
+ "outputs": [],
72
+ "source": [
73
+ "# add config\n",
74
  "\n",
75
  "chart.animate(Config({\"x\": \"Count\", \"y\": \"Sex\", \"label\": \"Count\",\"title\":\"Passengers of the Titanic\"}))\n",
76
  "chart.animate(Config({\"x\": [\"Count\",\"Survived\"], \"label\": [\"Count\",\"Survived\"], \"color\": \"Survived\"}))\n",
77
  "chart.animate(Config({\"x\": \"Count\", \"y\": [\"Sex\",\"Survived\"]}))"
78
  ]
79
  },
80
+ {
81
+ "cell_type": "code",
82
+ "execution_count": null,
83
+ "id": "9ab1ecf9",
84
+ "metadata": {},
85
+ "outputs": [],
86
+ "source": [
87
+ "# add style\n",
88
+ "\n",
89
+ "chart.animate(Style({\"title\": {\"fontSize\": 35}}))\n"
90
+ ]
91
+ },
92
  {
93
  "cell_type": "code",
94
  "execution_count": null,
 
96
  "metadata": {},
97
  "outputs": [],
98
  "source": [
99
+ "# filter data by gender\n",
100
+ "\n",
101
+ "data_filter = Data.filter(f\"record['Sex'] == '{gender}'\")\n",
102
+ "chart.animate(data_filter)"
103
  ]
104
  }
105
  ],