Previews

No matching results.

x
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
<div class="p-8">
<figure class="midwest-chart chart-type-line legend-alignment-center" data-controller="midwest-chart" data-midwest-chart-tooltip-enabled-value="true">
<svg
viewBox="0 0 600 320"
width="600"
height="320"
role="img"
aria-label=""
class="chart-svg"
data-midwest-chart-target="svg">
<title></title>
<desc>2 series: Series A, Series B; 8 data points</desc>
<g class="chart-grid" aria-hidden="true">
<line x1="60.0" y1="284.0"
x2="580.0" y2="284.0" />
<line x1="60.0" y1="196.0"
x2="580.0" y2="196.0" />
<line x1="60.0" y1="108.0"
x2="580.0" y2="108.0" />
<line x1="60.0" y1="20.0"
x2="580.0" y2="20.0" />
</g>
<g class="chart-axis chart-axis-x" aria-hidden="true">
<line x1="92.5" y1="284.0"
x2="92.5" y2="288.0" />
<text x="92.5" y="300.0"
text-anchor="middle"
transform="">
Jan
</text>
<line x1="157.5" y1="284.0"
x2="157.5" y2="288.0" />
<text x="157.5" y="300.0"
text-anchor="middle"
transform="">
Feb
</text>
<line x1="222.5" y1="284.0"
x2="222.5" y2="288.0" />
<text x="222.5" y="300.0"
text-anchor="middle"
transform="">
Mar
</text>
<line x1="287.5" y1="284.0"
x2="287.5" y2="288.0" />
<text x="287.5" y="300.0"
text-anchor="middle"
transform="">
Apr
</text>
<line x1="352.5" y1="284.0"
x2="352.5" y2="288.0" />
<text x="352.5" y="300.0"
text-anchor="middle"
transform="">
May
</text>
<line x1="417.5" y1="284.0"
x2="417.5" y2="288.0" />
<text x="417.5" y="300.0"
text-anchor="middle"
transform="">
Jun
</text>
<line x1="482.5" y1="284.0"
x2="482.5" y2="288.0" />
<text x="482.5" y="300.0"
text-anchor="middle"
transform="">
Jul
</text>
<line x1="547.5" y1="284.0"
x2="547.5" y2="288.0" />
<text x="547.5" y="300.0"
text-anchor="middle"
transform="">
Aug
</text>
</g>
<g class="chart-axis chart-axis-y" aria-hidden="true">
<line x1="56.0" y1="284.0"
x2="60.0" y2="284.0" />
<text x="52.0" y="288.0"
text-anchor="end">20</text>
<line x1="56.0" y1="196.0"
x2="60.0" y2="196.0" />
<text x="52.0" y="200.0"
text-anchor="end">40</text>
<line x1="56.0" y1="108.0"
x2="60.0" y2="108.0" />
<text x="52.0" y="112.0"
text-anchor="end">60</text>
<line x1="56.0" y1="20.0"
x2="60.0" y2="20.0" />
<text x="52.0" y="24.0"
text-anchor="end">80</text>
</g>
<g class="chart-lines">
<g class="chart-series">
<path d="M 92.5,187.2 L 157.5,130 M 287.5,103.6 L 352.5,46.4 L 417.5,130 L 482.5,72.8 L 547.5,20" stroke="var(--theme-6)" fill="none" stroke-width="2" class="chart-line" style="--i: 0; --path-length: 582.05" />
</g>
<g class="chart-series">
<path d="M 92.5,248.8 L 157.5,226.8 L 222.5,174 L 287.5,209.2 L 352.5,143.2 L 417.5,160.8 L 482.5,108 L 547.5,174" stroke="var(--complement-6)" fill="none" stroke-width="2" class="chart-line" style="--i: 1; --path-length: 562.63" />
</g>
</g>
</svg>
<div id="midwest-chart-63008-tooltip"
class="midwest-chart-tooltip"
data-midwest-chart-target="tooltip"
role="tooltip"></div>
<ul class="chart-legend" aria-label="Chart legend">
<li class="chart-legend-item">
<span class="chart-legend-swatch" style="background: var(--theme-6)"></span>
Series A
</li>
<li class="chart-legend-item">
<span class="chart-legend-swatch" style="background: var(--complement-6)"></span>
Series B
</li>
</ul>
</figure>
</div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<div class="p-8">
<% chart_type = params[:type]&.to_sym || :line %>
<%= midwest_chart(
chart_type,
title: params[:title].presence,
animated: params[:animated] == true,
smooth: params[:smooth] == true,
show_markers: params[:show_markers] == true,
connect_nulls: params[:connect_nulls] == true,
data_labels: params[:data_labels] == true,
fill_opacity: params[:fill_opacity]&.to_f,
tension: params[:tension]&.to_f,
x_axis: { categories: %w[Jan Feb Mar Apr May Jun Jul Aug] },
series: [
{ name: "Series A", data: [42, 55, nil, 61, 74, 55, 68, 80] },
{ name: "Series B", data: [28, 33, 45, 37, 52, 48, 60, 45] }
]
) %>
</div>
Param Description Input

Chart title

Chart type

Animate lines on load

Smooth curves (cubic Bézier)

Show dot markers at each data point

Bridge over nil (gap) values

Show value labels at each data point

Area fill opacity (area type only, 0.0–1.0)

Bézier tension when smooth is on (0.0–1.0)

No assets to display.
Add a .js or .css file alongside the component to see it here.

Accessibility

Figma embed for Chart/line_playground

Annotate a preview to embed its Figma design here:

@figma "https://figma.com/..."