-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html.eex
186 lines (166 loc) · 5.9 KB
/
index.html.eex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<h2>Chartkick-ex</h2>
<p class="lead">Create beautiful Javascript charts with one line of Elixir.</p>
<div class="alert alert-warning">
Also available in <a href="https://github.com/ankane/chartkick">Ruby</a>, <a href="https://github.com/mher/chartkick.py">Python</a> and pure <a href="https://github.com/ankane/chartkick.js">JavaScript</a>.
</div>
<% datetime_data = Poison.encode!(%{
"2013-02-10 00:00:00 -0800": 11,
"2013-02-11 00:00:00 -0800": 6,
"2013-02-12 00:00:00 -0800": 3,
"2013-02-13 00:00:00 -0800": 2,
"2013-02-14 00:00:00 -0800": 5,
"2013-02-15 00:00:00 -0800": 3,
"2013-02-16 00:00:00 -0800": 8,
"2013-02-17 00:00:00 -0800": 6,
"2013-02-18 00:00:00 -0800": 6,
"2013-02-19 00:00:00 -0800": 12,
"2013-02-20 00:00:00 -0800": 5,
"2013-02-21 00:00:00 -0800": 5,
"2013-02-22 00:00:00 -0800": 3,
"2013-02-23 00:00:00 -0800": 1,
"2013-02-24 00:00:00 -0800": 10,
"2013-02-25 00:00:00 -0800": 1,
"2013-02-26 00:00:00 -0800": 3,
"2013-02-27 00:00:00 -0800": 2,
"2013-02-28 00:00:00 -0800": 3,
"2013-03-01 00:00:00 -0800": 2,
"2013-03-02 00:00:00 -0800": 8
}) %>
<p>Line chart</p>
<%= raw Chartkick.line_chart datetime_data %>
<br><br>
<pre style="text-align:left">
<%= "\<% datetime_data = Poison.encode!(%{\"2013-02-10 00:00:00 -0800\": 11, ... }) %\>" %>
<%= "\<%= raw Chartkick.line_chart datetime_data %\>" %>
</pre>
<p>Pie chart</p>
<% pie_data = Poison.encode!([["Blueberry",44],["Strawberry",23],["Banana",22],["Apple",21],["Grape",13]]) %>
<%= raw Chartkick.pie_chart pie_data %>
<pre style="text-align:left">
<%= "\<% fruit_data = Poison.encode!([[\"Blueberry\",44], ...]) %\>" %>
<%= "\<%= raw Chartkick.pie_chart fruit_data %\>" %>
</pre>
<p>Column chart</p>
<% col_data = Poison.encode!([[0, 32], [1, 46], [2, 28], [3, 21], [4, 20], [5, 13], [6, 27]]) %>
<%= raw Chartkick.column_chart col_data %>
<pre style="text-align:left">
<%= "\<% col_data = Poison.encode!([[0, 32], [1, 46], ...]) %\>" %>
<%= "\<%= raw Chartkick.column_chart col_data %\>" %>
</pre>
<p>Bar chart</p>
<% bar_data = Poison.encode!([["X-Small", 5], ["Small", 27], ["Medium", 10], ["Large", 14], ["X-Large", 10]]) %>
<%= raw Chartkick.bar_chart col_data %>
<pre style="text-align:left">
<%= "\<% bar_data = Poison.encode!([[\"X-Small\", 5], ...]) %\>" %>
<%= "\<%= raw Chartkick.bar_chart bar_data %\>" %>
</pre>
<p>Area chart</p>
<% area_data = Poison.encode!(%{
"2013-07-27 07:00:00 UTC": 2,
"2013-07-27 07:01:00 UTC": 5,
"2013-07-27 07:02:00 UTC": 3,
"2013-07-27 07:03:00 UTC": 3,
"2013-07-27 07:04:00 UTC": 2,
"2013-07-27 07:05:00 UTC": 5,
"2013-07-27 07:06:00 UTC": 1,
"2013-07-27 07:07:00 UTC": 3,
"2013-07-27 07:08:00 UTC": 4,
"2013-07-27 07:09:00 UTC": 3,
"2013-07-27 07:10:00 UTC": 2
}) %>
<%= raw Chartkick.area_chart area_data %>
<pre style="text-align:left">
<%= "\<% area_data = Poison.encode!(%{\"2013-07-27 07:00:00 UTC\": 2, ... }) %\>" %>
<%= "\<%= raw Chartkick.bar_chart area_data %\>" %>
</pre>
<p>Geo chart</p>
<% geo_data = Poison.encode!([["United States", 101], ["Russia", 63], ["Germany", 65], ["China", 50], ["France", 37], ["Italy", 35], ["Australia", 41]]) %>
<%= raw Chartkick.geo_chart geo_data %>
<pre style="text-align:left">
<%= "\<% geo_data = Poison.encode!([[\"United States\", 101], [\"Russia\", 63], ...]) %\>" %>
<%= "\<%= raw Chartkick.bar_chart geo_data %\>" %>
</pre>
<p>Timeline</p>
<% timeline_data = Poison.encode!([
["Washington", "1789-04-29", "1797-03-03"],
["Adams", "1797-03-03", "1801-03-03"],
["Jefferson", "1801-03-03", "1809-03-03"]
]) %>
<%= raw Chartkick.timeline timeline_data, height: "200px" %>
<pre style="text-align:left">
<%= "\<% timeline_data = Poison.encode!([[\"Washington\", \"1789-04-29\", \"1797-03-03\"]], ...]) %\>" %>
<%= "\<%= raw Chartkick.timeline timeline_data %\>" %>
</pre>
<p>Multi line series</p>
<% multi_series_data = Poison.encode!([%{
"name": "Workout",
"data": %{
"2013-02-10 00:00:00 -0800": 3,
"2013-02-17 00:00:00 -0800": 3,
"2013-02-24 00:00:00 -0800": 3,
"2013-03-03 00:00:00 -0800": 1,
"2013-03-10 00:00:00 -0800": 4,
"2013-03-17 00:00:00 -0700": 3,
"2013-03-24 00:00:00 -0700": 2,
"2013-03-31 00:00:00 -0700": 3
}
},
%{
"name": "Go to concert",
"data": %{
"2013-02-10 00:00:00 -0800": 0,
"2013-02-17 00:00:00 -0800": 0,
"2013-02-24 00:00:00 -0800": 0,
"2013-03-03 00:00:00 -0800": 0,
"2013-03-10 00:00:00 -0800": 2,
"2013-03-17 00:00:00 -0700": 1,
"2013-03-24 00:00:00 -0700": 0,
"2013-03-31 00:00:00 -0700": 0
}
},
%{
"name": "Wash face",
"data": %{
"2013-02-10 00:00:00 -0800": 0,
"2013-02-17 00:00:00 -0800": 1,
"2013-02-24 00:00:00 -0800": 0,
"2013-03-03 00:00:00 -0800": 0,
"2013-03-10 00:00:00 -0800": 0,
"2013-03-17 00:00:00 -0700": 1,
"2013-03-24 00:00:00 -0700": 0,
"2013-03-31 00:00:00 -0700": 1
}
},
%{
"name": "Call parents",
"data": %{
"2013-02-10 00:00:00 -0800": 5,
"2013-02-17 00:00:00 -0800": 3,
"2013-02-24 00:00:00 -0800": 2,
"2013-03-03 00:00:00 -0800": 0,
"2013-03-10 00:00:00 -0800": 0,
"2013-03-17 00:00:00 -0700": 1,
"2013-03-24 00:00:00 -0700": 1,
"2013-03-31 00:00:00 -0700": 0
}
},
%{
"name": "Eat breakfast",
"data": %{
"2013-02-10 00:00:00 -0800": 3,
"2013-02-17 00:00:00 -0800": 2,
"2013-02-24 00:00:00 -0800": 1,
"2013-03-03 00:00:00 -0800": 0,
"2013-03-10 00:00:00 -0800": 2,
"2013-03-17 00:00:00 -0700": 2,
"2013-03-24 00:00:00 -0700": 3,
"2013-03-31 00:00:00 -0700": 0
}
}]) %>
<%= raw Chartkick.line_chart multi_series_data %>
<pre style="text-align:left">
<%= "\<% first_line_data = %{\"name\": \"Eat breakfast\", \"data\": %{ \"2013-02-10 00:00:00 -0800\": 3, ... }} %\>" %>
<%= "\<% second_line_data = %{\"name\": \"Call parents\", \"data\": %{ \"2013-02-10 00:00:00 -0800\": 5, ... }} %\>" %>
<%= "\<% series_data = Poison.encode!(%{[first_line_data, second_line_data]}) %\>" %>
<%= "\<%= raw Chartkick.line_chart series_data %\>" %>
</pre>