playbook_ui 13.22.0 → 13.23.0.pre.alpha.PLAY1284investigation2657
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/CustomCell.tsx +8 -4
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_collapsible_trail.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.jsx +6 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_expanded_control.md +2 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_loading.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_subrow_headers.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_options.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_mock_data.json +278 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +1 -6
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +28 -7
- data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +2 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_secondary_y_axis.html.erb +26 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_secondary_y_axis.jsx +36 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_secondary_y_axis.md +3 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_body/_body.scss +3 -3
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.html.erb +0 -7
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.jsx +0 -7
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range.html.erb +7 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range.jsx +7 -0
- data/app/pb_kits/playbook/pb_date_picker/docs/example.yml +2 -2
- data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +1 -1
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +2 -2
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.html.erb +2 -0
- data/app/pb_kits/playbook/pb_form_group/_form_group.scss +34 -0
- data/app/pb_kits/playbook/pb_form_group/docs/_form_group_select.html.erb +17 -1
- data/app/pb_kits/playbook/pb_form_group/docs/_form_group_select.jsx +18 -2
- data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.scss +14 -0
- data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.tsx +1 -1
- data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_sizes.html.erb +5 -0
- data/app/pb_kits/playbook/pb_icon_circle/docs/_icon_circle_sizes.jsx +6 -0
- data/app/pb_kits/playbook/pb_icon_circle/icon_circle.rb +1 -1
- data/app/pb_kits/playbook/pb_icon_circle/icon_circle.test.js +1 -0
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.rb +0 -2
- data/app/pb_kits/playbook/pb_list/list.rb +0 -2
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids.md +2 -2
- data/app/pb_kits/playbook/pb_multi_level_select/docs/{_multi_level_select_selected_ids.jsx → _multi_level_select_selected_ids_react.jsx} +2 -2
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids_react.md +5 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -1
- data/app/pb_kits/playbook/pb_online_status/_online_status.scss +1 -10
- data/app/pb_kits/playbook/pb_online_status/_online_status.tsx +1 -1
- data/app/pb_kits/playbook/pb_online_status/_online_status_mixins.scss +7 -13
- data/app/pb_kits/playbook/pb_online_status/docs/_online_status_default.html.erb +6 -9
- data/app/pb_kits/playbook/pb_online_status/docs/_online_status_default.jsx +18 -7
- data/app/pb_kits/playbook/pb_online_status/online_status.rb +1 -1
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default.html.erb +2 -1
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.html.erb +2 -2
- data/app/pb_kits/playbook/pb_toggle/_toggle.scss +39 -6
- data/app/pb_kits/playbook/pb_toggle/_toggle.tsx +17 -12
- data/app/pb_kits/playbook/pb_toggle/docs/_toggle_disabled.html.erb +11 -0
- data/app/pb_kits/playbook/pb_toggle/docs/_toggle_disabled.jsx +21 -0
- data/app/pb_kits/playbook/pb_toggle/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_toggle/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_toggle/toggle.rb +2 -1
- data/app/pb_kits/playbook/pb_toggle/toggle.test.js +7 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +27 -19
- data/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx +4 -2
- data/app/pb_kits/playbook/pb_typeahead/components/index.tsx +19 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx +51 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_highlight.jsx +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- data/app/pb_kits/playbook/utilities/_positioning.scss +23 -10
- data/app/pb_kits/playbook/utilities/globalProps.ts +26 -8
- data/dist/menu.yml +4 -0
- data/dist/playbook-rails.js +7 -7
- data/lib/playbook/bottom.rb +6 -3
- data/lib/playbook/kit_base.rb +21 -1
- data/lib/playbook/left.rb +6 -3
- data/lib/playbook/pb_doc_helper.rb +1 -1
- data/lib/playbook/position_props_css.rb +17 -0
- data/lib/playbook/props/percentage.rb +2 -2
- data/lib/playbook/right.rb +6 -3
- data/lib/playbook/top.rb +6 -3
- data/lib/playbook/version.rb +2 -2
- metadata +22 -41
- data/app/pb_kits/playbook/pb_advanced_table/docs/_mock_data.js +0 -278
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f32666e4b2500b014dc2554c3ebf3f5f4e3695cc726a3fc1d53bf5b332455a5
|
4
|
+
data.tar.gz: ff93821e0818cfbf57b09ece3fe03ce0c5459e4d29161f896d5771a3e8eb3761
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93c9e3de45864e757c047b19dd7eeed12610d97f234a160183143155ab0dbb88ea6087414e212ffd1037eff4064b239ba7eecfbb30627753f4b4ab1bfcacf1a9
|
7
|
+
data.tar.gz: a5264af573a6eac322795be8739d2a3974a72085e3d5d163b79f4b1882899483b5e82f5205c1ced23c85d1dcc10f53d67570c3067645169fe9cf41f08062eca6
|
@@ -24,12 +24,16 @@ export const CustomCell = ({
|
|
24
24
|
row,
|
25
25
|
value,
|
26
26
|
}: CustomCellProps & GlobalProps) => {
|
27
|
-
const { setExpanded, expanded, inlineRowLoading } = useContext(AdvancedTableContext)
|
27
|
+
const { setExpanded, expanded, expandedControl, inlineRowLoading } = useContext(AdvancedTableContext);
|
28
28
|
|
29
29
|
const handleOnExpand = (row: Row<GenericObject>) => {
|
30
|
-
onRowToggleClick && onRowToggleClick(row)
|
31
|
-
|
32
|
-
|
30
|
+
onRowToggleClick && onRowToggleClick(row);
|
31
|
+
|
32
|
+
if (!expandedControl) {
|
33
|
+
setExpanded({ ...expanded, [row.id]: !row.getIsExpanded() });
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
33
37
|
const RowHasChildren = row.original.children ? true : false
|
34
38
|
const renderButton = inlineRowLoading ? RowHasChildren : row.getCanExpand()
|
35
39
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useState } from "react"
|
2
2
|
import { AdvancedTable } from "../../"
|
3
|
-
import
|
3
|
+
import MOCK_DATA from "./advanced_table_mock_data.json"
|
4
4
|
|
5
5
|
const AdvancedTableExpandedControl = (props) => {
|
6
6
|
const columnDefinitions = [
|
@@ -44,11 +44,16 @@ const AdvancedTableExpandedControl = (props) => {
|
|
44
44
|
onChange: setExpanded,
|
45
45
|
}
|
46
46
|
|
47
|
+
const onRowToggleClick = (row) => {
|
48
|
+
setExpanded({ ...expanded, [row.id]: !expanded[row.id] })
|
49
|
+
}
|
50
|
+
|
47
51
|
return (
|
48
52
|
<div>
|
49
53
|
<AdvancedTable
|
50
54
|
columnDefinitions={columnDefinitions}
|
51
55
|
expandedControl={expandedControl}
|
56
|
+
onRowToggleClick={onRowToggleClick}
|
52
57
|
tableData={MOCK_DATA}
|
53
58
|
{...props}
|
54
59
|
/>
|
@@ -1,3 +1,5 @@
|
|
1
|
+
**NOTE**: If using `expandedControl` the dev is expected to manage the row level expansion state themselves, the kit itself will NOT do it by default.
|
2
|
+
|
1
3
|
`expandedControl` is an optional prop that can be used to gain greater control over the expansion state of the Advanced Table. Tanstack handles expansion itself, however it does provide for a way to handle the state manually if needed. Usecases for this include needing to store the expansion state so it persists on page reload, set an initial expansion state, etc.
|
2
4
|
|
3
5
|
In this example we are showing that if initial expansion state is set, it will render the table expanded according to that state.
|
@@ -0,0 +1,278 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"year": "2021",
|
4
|
+
"quarter": null,
|
5
|
+
"month": null,
|
6
|
+
"day": null,
|
7
|
+
"newEnrollments": "20",
|
8
|
+
"scheduledMeetings": "10",
|
9
|
+
"attendanceRate": "51%",
|
10
|
+
"completedClasses": "3",
|
11
|
+
"classCompletionRate": "33%",
|
12
|
+
"graduatedStudents": "19",
|
13
|
+
"children": [
|
14
|
+
{
|
15
|
+
"year": "2021",
|
16
|
+
"quarter": "Q1",
|
17
|
+
"month": null,
|
18
|
+
"day": null,
|
19
|
+
"newEnrollments": "2",
|
20
|
+
"scheduledMeetings": "35",
|
21
|
+
"attendanceRate": "32%",
|
22
|
+
"completedClasses": "15",
|
23
|
+
"classCompletionRate": "52%",
|
24
|
+
"graduatedStudents": "36",
|
25
|
+
"children": [
|
26
|
+
{
|
27
|
+
"year": "2021",
|
28
|
+
"quarter": "Q1",
|
29
|
+
"month": "January",
|
30
|
+
"day": null,
|
31
|
+
"newEnrollments": "16",
|
32
|
+
"scheduledMeetings": "20",
|
33
|
+
"attendanceRate": "11%",
|
34
|
+
"completedClasses": "13",
|
35
|
+
"classCompletionRate": "47%",
|
36
|
+
"graduatedStudents": "28",
|
37
|
+
"children": [
|
38
|
+
{
|
39
|
+
"year": "2021",
|
40
|
+
"quarter": "Q1",
|
41
|
+
"month": "January",
|
42
|
+
"day": "10",
|
43
|
+
"newEnrollments": "34",
|
44
|
+
"scheduledMeetings": "28",
|
45
|
+
"attendanceRate": "97%",
|
46
|
+
"completedClasses": "20",
|
47
|
+
"classCompletionRate": "15%",
|
48
|
+
"graduatedStudents": "17"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"year": "2021",
|
52
|
+
"quarter": "Q1",
|
53
|
+
"month": "January",
|
54
|
+
"day": "20",
|
55
|
+
"newEnrollments": "43",
|
56
|
+
"scheduledMeetings": "23",
|
57
|
+
"attendanceRate": "66%",
|
58
|
+
"completedClasses": "26",
|
59
|
+
"classCompletionRate": "47%",
|
60
|
+
"graduatedStudents": "9"
|
61
|
+
}
|
62
|
+
]
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"year": "2021",
|
66
|
+
"quarter": "Q1",
|
67
|
+
"month": "February",
|
68
|
+
"day": null,
|
69
|
+
"newEnrollments": "20",
|
70
|
+
"scheduledMeetings": "41",
|
71
|
+
"attendanceRate": "95%",
|
72
|
+
"completedClasses": "26",
|
73
|
+
"classCompletionRate": "83%",
|
74
|
+
"graduatedStudents": "43",
|
75
|
+
"children": [
|
76
|
+
{
|
77
|
+
"year": "2021",
|
78
|
+
"quarter": "Q1",
|
79
|
+
"month": "February",
|
80
|
+
"day": "15",
|
81
|
+
"newEnrollments": "19",
|
82
|
+
"scheduledMeetings": "35",
|
83
|
+
"attendanceRate": "69%",
|
84
|
+
"completedClasses": "8",
|
85
|
+
"classCompletionRate": "75%",
|
86
|
+
"graduatedStudents": "23"
|
87
|
+
}
|
88
|
+
]
|
89
|
+
}
|
90
|
+
]
|
91
|
+
}
|
92
|
+
]
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"year": "2022",
|
96
|
+
"quarter": null,
|
97
|
+
"month": null,
|
98
|
+
"day": null,
|
99
|
+
"newEnrollments": "25",
|
100
|
+
"scheduledMeetings": "17",
|
101
|
+
"attendanceRate": "75%",
|
102
|
+
"completedClasses": "5",
|
103
|
+
"classCompletionRate": "45%",
|
104
|
+
"graduatedStudents": "32",
|
105
|
+
"children": [
|
106
|
+
{
|
107
|
+
"year": "2022",
|
108
|
+
"quarter": "Q1",
|
109
|
+
"month": null,
|
110
|
+
"day": null,
|
111
|
+
"newEnrollments": "2",
|
112
|
+
"scheduledMeetings": "35",
|
113
|
+
"attendanceRate": "32%",
|
114
|
+
"completedClasses": "15",
|
115
|
+
"classCompletionRate": "52%",
|
116
|
+
"graduatedStudents": "36",
|
117
|
+
"children": [
|
118
|
+
{
|
119
|
+
"year": "2022",
|
120
|
+
"quarter": "Q1",
|
121
|
+
"month": "January",
|
122
|
+
"day": null,
|
123
|
+
"newEnrollments": "16",
|
124
|
+
"scheduledMeetings": "20",
|
125
|
+
"attendanceRate": "11%",
|
126
|
+
"completedClasses": "13",
|
127
|
+
"classCompletionRate": "47%",
|
128
|
+
"graduatedStudents": "28",
|
129
|
+
"children": [
|
130
|
+
{
|
131
|
+
"year": "2022",
|
132
|
+
"quarter": "Q1",
|
133
|
+
"month": "January",
|
134
|
+
"day": "15",
|
135
|
+
"newEnrollments": "34",
|
136
|
+
"scheduledMeetings": "28",
|
137
|
+
"attendanceRate": "97%",
|
138
|
+
"completedClasses": "20",
|
139
|
+
"classCompletionRate": "15%",
|
140
|
+
"graduatedStudents": "17"
|
141
|
+
},
|
142
|
+
{
|
143
|
+
"year": "2022",
|
144
|
+
"quarter": "Q1",
|
145
|
+
"month": "January",
|
146
|
+
"day": "25",
|
147
|
+
"newEnrollments": "43",
|
148
|
+
"scheduledMeetings": "23",
|
149
|
+
"attendanceRate": "66%",
|
150
|
+
"completedClasses": "26",
|
151
|
+
"classCompletionRate": "47%",
|
152
|
+
"graduatedStudents": "9"
|
153
|
+
}
|
154
|
+
]
|
155
|
+
},
|
156
|
+
{
|
157
|
+
"year": "2022",
|
158
|
+
"quarter": "Q1",
|
159
|
+
"month": "May",
|
160
|
+
"day": null,
|
161
|
+
"newEnrollments": "20",
|
162
|
+
"scheduledMeetings": "41",
|
163
|
+
"attendanceRate": "95%",
|
164
|
+
"completedClasses": "26",
|
165
|
+
"classCompletionRate": "83%",
|
166
|
+
"graduatedStudents": "43",
|
167
|
+
"children": [
|
168
|
+
{
|
169
|
+
"year": "2022",
|
170
|
+
"quarter": "Q1",
|
171
|
+
"month": "May",
|
172
|
+
"day": "2",
|
173
|
+
"newEnrollments": "19",
|
174
|
+
"scheduledMeetings": "35",
|
175
|
+
"attendanceRate": "69%",
|
176
|
+
"completedClasses": "8",
|
177
|
+
"classCompletionRate": "75%",
|
178
|
+
"graduatedStudents": "23"
|
179
|
+
}
|
180
|
+
]
|
181
|
+
}
|
182
|
+
]
|
183
|
+
}
|
184
|
+
]
|
185
|
+
},
|
186
|
+
{
|
187
|
+
"year": "2023",
|
188
|
+
"quarter": null,
|
189
|
+
"month": null,
|
190
|
+
"day": null,
|
191
|
+
"newEnrollments": "10",
|
192
|
+
"scheduledMeetings": "15",
|
193
|
+
"attendanceRate": "65%",
|
194
|
+
"completedClasses": "4",
|
195
|
+
"classCompletionRate": "49%",
|
196
|
+
"graduatedStudents": "29",
|
197
|
+
"children": [
|
198
|
+
{
|
199
|
+
"year": "2023",
|
200
|
+
"quarter": "Q1",
|
201
|
+
"month": null,
|
202
|
+
"day": null,
|
203
|
+
"newEnrollments": "2",
|
204
|
+
"scheduledMeetings": "35",
|
205
|
+
"attendanceRate": "32%",
|
206
|
+
"completedClasses": "15",
|
207
|
+
"classCompletionRate": "52%",
|
208
|
+
"graduatedStudents": "36",
|
209
|
+
"children": [
|
210
|
+
{
|
211
|
+
"year": "2023",
|
212
|
+
"quarter": "Q1",
|
213
|
+
"month": "March",
|
214
|
+
"day": null,
|
215
|
+
"newEnrollments": "16",
|
216
|
+
"scheduledMeetings": "20",
|
217
|
+
"attendanceRate": "11%",
|
218
|
+
"completedClasses": "13",
|
219
|
+
"classCompletionRate": "47%",
|
220
|
+
"graduatedStudents": "28",
|
221
|
+
"children": [
|
222
|
+
{
|
223
|
+
"year": "2023",
|
224
|
+
"quarter": "Q1",
|
225
|
+
"month": "March",
|
226
|
+
"day": "10",
|
227
|
+
"newEnrollments": "34",
|
228
|
+
"scheduledMeetings": "28",
|
229
|
+
"attendanceRate": "97%",
|
230
|
+
"completedClasses": "20",
|
231
|
+
"classCompletionRate": "15%",
|
232
|
+
"graduatedStudents": "17"
|
233
|
+
},
|
234
|
+
{
|
235
|
+
"year": "2023",
|
236
|
+
"quarter": "Q1",
|
237
|
+
"month": "March",
|
238
|
+
"day": "11",
|
239
|
+
"newEnrollments": "43",
|
240
|
+
"scheduledMeetings": "23",
|
241
|
+
"attendanceRate": "66%",
|
242
|
+
"completedClasses": "26",
|
243
|
+
"classCompletionRate": "47%",
|
244
|
+
"graduatedStudents": "9"
|
245
|
+
}
|
246
|
+
]
|
247
|
+
},
|
248
|
+
{
|
249
|
+
"year": "2023",
|
250
|
+
"quarter": "Q1",
|
251
|
+
"month": "April",
|
252
|
+
"day": null,
|
253
|
+
"newEnrollments": "20",
|
254
|
+
"scheduledMeetings": "41",
|
255
|
+
"attendanceRate": "95%",
|
256
|
+
"completedClasses": "26",
|
257
|
+
"classCompletionRate": "83%",
|
258
|
+
"graduatedStudents": "43",
|
259
|
+
"children": [
|
260
|
+
{
|
261
|
+
"year": "2023",
|
262
|
+
"quarter": "Q1",
|
263
|
+
"month": "April",
|
264
|
+
"day": "15",
|
265
|
+
"newEnrollments": "19",
|
266
|
+
"scheduledMeetings": "35",
|
267
|
+
"attendanceRate": "69%",
|
268
|
+
"completedClasses": "8",
|
269
|
+
"classCompletionRate": "75%",
|
270
|
+
"graduatedStudents": "23"
|
271
|
+
}
|
272
|
+
]
|
273
|
+
}
|
274
|
+
]
|
275
|
+
}
|
276
|
+
]
|
277
|
+
}
|
278
|
+
]
|
@@ -1,9 +1,4 @@
|
|
1
|
-
<%=
|
2
|
-
id: object.id,
|
3
|
-
data: object.data.merge(initials: object.initials),
|
4
|
-
class: object.classname,
|
5
|
-
aria: object.aria,
|
6
|
-
**combined_html_options) do %>
|
1
|
+
<%= object.pb_content_tag(:div, data: object.data.merge(initials: object.initials)) do %>
|
7
2
|
<%= content_tag(:div, data: { initials: object.initials }, class: "avatar_wrapper") do %>
|
8
3
|
<%= pb_rails("image", props: { alt: object.alt_text, url: object.image_url, on_error: object.handle_img_error }) if object.image_url.present? %>
|
9
4
|
<% end %>
|
@@ -13,12 +13,12 @@ import classnames from "classnames";
|
|
13
13
|
|
14
14
|
type BarGraphProps = {
|
15
15
|
align?: "left" | "right" | "center";
|
16
|
-
axisTitle: string;
|
16
|
+
axisTitle: { name: string; }[] | string;
|
17
17
|
dark?: boolean;
|
18
18
|
xAxisCategories: [];
|
19
19
|
yAxisMin: number;
|
20
20
|
yAxisMax: number;
|
21
|
-
chartData: { name: string; data: number[] }[];
|
21
|
+
chartData: { name: string; data: number[], yAxis: number }[];
|
22
22
|
className?: string;
|
23
23
|
customOptions?: Partial<Highcharts.Options>;
|
24
24
|
id: string;
|
@@ -37,6 +37,7 @@ type BarGraphProps = {
|
|
37
37
|
y?: number;
|
38
38
|
aria?: { [key: string]: string };
|
39
39
|
data?: { [key: string]: string };
|
40
|
+
axisFormat?: { format: string; }[] | string;
|
40
41
|
};
|
41
42
|
|
42
43
|
|
@@ -51,6 +52,7 @@ const BarGraph = ({
|
|
51
52
|
colors,
|
52
53
|
htmlOptions = {},
|
53
54
|
customOptions = {},
|
55
|
+
axisFormat,
|
54
56
|
id,
|
55
57
|
pointStart,
|
56
58
|
subTitle,
|
@@ -67,7 +69,7 @@ const BarGraph = ({
|
|
67
69
|
x = 0,
|
68
70
|
y = 0,
|
69
71
|
...props
|
70
|
-
}: BarGraphProps): React.ReactElement => {
|
72
|
+
}: BarGraphProps): React.ReactElement => {
|
71
73
|
const ariaProps = buildAriaProps(aria);
|
72
74
|
const dataProps = buildDataProps(data)
|
73
75
|
const htmlProps = buildHtmlProps(htmlOptions);
|
@@ -89,13 +91,18 @@ const BarGraph = ({
|
|
89
91
|
subtitle: {
|
90
92
|
text: subTitle,
|
91
93
|
},
|
92
|
-
yAxis: {
|
94
|
+
yAxis: [{
|
95
|
+
labels: {
|
96
|
+
format: typeof axisFormat === 'string' ? axisFormat : (axisFormat && axisFormat[0] ? axisFormat[0].format : "")
|
97
|
+
|
98
|
+
},
|
93
99
|
min: yAxisMin,
|
94
100
|
max: yAxisMax,
|
101
|
+
opposite: false,
|
95
102
|
title: {
|
96
|
-
text: axisTitle,
|
97
|
-
}
|
98
|
-
},
|
103
|
+
text: typeof axisTitle === 'string' ? axisTitle : axisTitle[0].name,
|
104
|
+
}
|
105
|
+
}],
|
99
106
|
xAxis: {
|
100
107
|
categories: xAxisCategories,
|
101
108
|
},
|
@@ -124,6 +131,20 @@ const BarGraph = ({
|
|
124
131
|
credits: false,
|
125
132
|
};
|
126
133
|
|
134
|
+
if (Array.isArray(axisTitle) && axisTitle.length > 1 && axisTitle[1].name) {
|
135
|
+
staticOptions.yAxis.push({
|
136
|
+
labels: {
|
137
|
+
format: typeof axisFormat === 'string' ? axisFormat : axisFormat[1].format,
|
138
|
+
},
|
139
|
+
min: yAxisMin,
|
140
|
+
max: yAxisMax,
|
141
|
+
opposite: true,
|
142
|
+
title: {
|
143
|
+
text: axisTitle[1].name,
|
144
|
+
}
|
145
|
+
});
|
146
|
+
}
|
147
|
+
|
127
148
|
if (!toggleLegendClick) {
|
128
149
|
staticOptions.plotOptions.series.events = { legendItemClick: () => false };
|
129
150
|
}
|
@@ -7,6 +7,7 @@ module Playbook
|
|
7
7
|
values: %w[left right center],
|
8
8
|
default: "center"
|
9
9
|
prop :axis_title
|
10
|
+
prop :axis_format
|
10
11
|
prop :chart_data, type: Playbook::Props::Array,
|
11
12
|
default: []
|
12
13
|
prop :custom_options, default: {}
|
@@ -51,6 +52,7 @@ module Playbook
|
|
51
52
|
title: title,
|
52
53
|
subTitle: subtitle,
|
53
54
|
axisTitle: axis_title,
|
55
|
+
axisFormat: axis_format,
|
54
56
|
pointStart: point_start,
|
55
57
|
xAxisCategories: x_axis_categories,
|
56
58
|
yAxisMin: y_axis_min,
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<% data = [{
|
2
|
+
name: 'Number of Installations',
|
3
|
+
data: [1475,200,3000,654,656]
|
4
|
+
}, {
|
5
|
+
type: 'spline',
|
6
|
+
name: 'Percentage',
|
7
|
+
data: [48, 70, 25, 55, 72],
|
8
|
+
color: '#F9BB00',
|
9
|
+
yAxis: 1
|
10
|
+
}] %>
|
11
|
+
|
12
|
+
<% axis_titles = [{name: "Number of Installations"}, {name: "Percentage"}] %>
|
13
|
+
|
14
|
+
<% axis_formats = [{format: ""}, {format: "{value}%"}] %>
|
15
|
+
|
16
|
+
<%= pb_rails("bar_graph", props: {
|
17
|
+
axis_format: axis_formats,
|
18
|
+
axis_title: axis_titles,
|
19
|
+
chart_data: data,
|
20
|
+
id: "bar-spline",
|
21
|
+
y_axis_min: 0,
|
22
|
+
x_axis_categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
|
23
|
+
subtitle: 'Source: thesolarfoundation.com',
|
24
|
+
title: 'Bar Graph with Secondary Y-axis',
|
25
|
+
legend: true,
|
26
|
+
}) %>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import BarGraph from '../_bar_graph'
|
4
|
+
|
5
|
+
const chartData = [{
|
6
|
+
name: 'Number of Installations',
|
7
|
+
data: [1475, 200, 3000, 654, 656],
|
8
|
+
}, {
|
9
|
+
type: 'spline',
|
10
|
+
name: 'Percentage',
|
11
|
+
data: [48, 70, 25, 55, 72],
|
12
|
+
color: '#F9BB00',
|
13
|
+
yAxis: 1
|
14
|
+
}]
|
15
|
+
|
16
|
+
const axisTitles = [ {name: "Number of Installations"}, {name: "Percentage"}]
|
17
|
+
|
18
|
+
const axisFormats = [{format: ""}, {format: "{value}%"}]
|
19
|
+
|
20
|
+
const BarGraphSecondaryYAxis= (props) => (
|
21
|
+
<div>
|
22
|
+
<BarGraph
|
23
|
+
axisFormat={axisFormats}
|
24
|
+
axisTitle={axisTitles}
|
25
|
+
chartData={chartData}
|
26
|
+
id="bar-spline"
|
27
|
+
legend
|
28
|
+
title="Bar Graph with Secondary Y-axis"
|
29
|
+
xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May']}
|
30
|
+
yAxisMin={0}
|
31
|
+
{...props}
|
32
|
+
/>
|
33
|
+
</div>
|
34
|
+
)
|
35
|
+
|
36
|
+
export default BarGraphSecondaryYAxis
|
@@ -0,0 +1,3 @@
|
|
1
|
+
Optionally add a second yAxis to support secondary datasets (e.x., a spline) by passing` yAxis: 1` to the second node of your `chartData` array.
|
2
|
+
|
3
|
+
To customize the format and/or title of your secondary yAxis, pass your desired values as arrays through the `axisFormat` and `axisTitle` props, respectively.
|
@@ -9,6 +9,7 @@ examples:
|
|
9
9
|
- bar_graph_spline: Spline
|
10
10
|
- bar_graph_colors: Color Overrides
|
11
11
|
- bar_graph_custom: Custom Overrides
|
12
|
+
- bar_graph_secondary_y_axis: Secondary Y-Axis
|
12
13
|
|
13
14
|
|
14
15
|
react:
|
@@ -20,3 +21,4 @@ examples:
|
|
20
21
|
- bar_graph_spline: Spline
|
21
22
|
- bar_graph_colors: Color Overrides
|
22
23
|
- bar_graph_custom: Custom Overrides
|
24
|
+
- bar_graph_secondary_y_axis: Secondary Y-Axis
|
@@ -6,3 +6,4 @@ export { default as BarGraphHeight } from './_bar_graph_height.jsx'
|
|
6
6
|
export { default as BarGraphSpline } from './_bar_graph_spline.jsx'
|
7
7
|
export { default as BarGraphColors } from './_bar_graph_colors.jsx'
|
8
8
|
export { default as BarGraphCustom } from './_bar_graph_custom.jsx'
|
9
|
+
export { default as BarGraphSecondaryYAxis } from './_bar_graph_secondary_y_axis.jsx'
|