playbook_ui 14.4.0.pre.alpha.PLAY1486highchartscssdrivenPOC3923 → 14.4.0.pre.alpha.PLAY1529removefaeasy3876
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/_playbook.scss +0 -2
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +1 -1
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.scss +0 -21
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +184 -5
- data/app/pb_kits/playbook/pb_bar_graph/barGraph.test.js +1 -1
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +216 -5
- data/app/pb_kits/playbook/pb_circle_chart/circleChart.test.js +1 -1
- data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.ts +6 -2
- data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.ts +7 -2
- data/app/pb_kits/playbook/pb_gantt_chart/_gantt_chart.tsx +64 -3
- data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +203 -5
- data/app/pb_kits/playbook/pb_gauge/gauge.test.js +1 -1
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +154 -5
- data/app/pb_kits/playbook/pb_line_graph/lineGraph.test.js +1 -1
- data/app/pb_kits/playbook/pb_popover/docs/_popover_list.html.erb +2 -2
- data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.html.erb +0 -2
- data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.jsx +2 -5
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +113 -5
- data/app/pb_kits/playbook/pb_treemap_chart/treemapChart.test.js +1 -1
- data/dist/chunks/_typeahead-DnWoIeq6.js +22 -0
- data/dist/chunks/_weekday_stacked-C5Ls9JLc.js +45 -0
- data/dist/chunks/lib-CEpcaI8y.js +29 -0
- data/dist/chunks/{pb_form_validation-Dna2I7fw.js → pb_form_validation-D9zkwt2b.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +1 -3
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/pagination_renderer.rb +2 -2
- data/lib/playbook/version.rb +1 -1
- metadata +6 -21
- data/app/pb_kits/playbook/pb_drawer/_close_icon.tsx +0 -25
- data/app/pb_kits/playbook/pb_drawer/_drawer.scss +0 -465
- data/app/pb_kits/playbook/pb_drawer/_drawer.tsx +0 -195
- data/app/pb_kits/playbook/pb_drawer/_drawer_context.tsx +0 -3
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +0 -117
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +0 -43
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.html.erb +0 -1
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.jsx +0 -63
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +0 -55
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.jsx +0 -113
- data/app/pb_kits/playbook/pb_drawer/docs/example.yml +0 -12
- data/app/pb_kits/playbook/pb_drawer/docs/index.js +0 -5
- data/app/pb_kits/playbook/pb_drawer/drawer.html.erb +0 -12
- data/app/pb_kits/playbook/pb_drawer/drawer.rb +0 -8
- data/app/pb_kits/playbook/pb_drawer/drawer.test.jsx +0 -77
- data/dist/chunks/_typeahead-BywvWGAm.js +0 -22
- data/dist/chunks/_weekday_stacked-5OGZKZeo.js +0 -45
- data/dist/chunks/lib-DMOmCoAX.js +0 -29
@@ -1,10 +1,208 @@
|
|
1
|
-
import React from
|
1
|
+
import React, { useState, useEffect } from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
import HighchartsReact from "highcharts-react-official";
|
4
|
+
import Highcharts from "highcharts";
|
5
|
+
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
6
|
+
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
7
|
+
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
8
|
+
import highchartsMore from "highcharts/highcharts-more";
|
9
|
+
import solidGauge from "highcharts/modules/solid-gauge";
|
10
|
+
import defaultColors from "../tokens/exports/_colors.module.scss";
|
11
|
+
import typography from "../tokens/exports/_typography.module.scss";
|
12
|
+
|
13
|
+
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
|
14
|
+
import { globalProps } from "../utilities/globalProps";
|
15
|
+
import { GenericObject } from "../types";
|
16
|
+
import { merge } from 'lodash'
|
17
|
+
|
18
|
+
type GaugeProps = {
|
19
|
+
aria: { [key: string]: string };
|
20
|
+
className?: string;
|
21
|
+
chartData?: { name: string; value: number[] | number }[];
|
22
|
+
customOptions?: Partial<Highcharts.Options>;
|
23
|
+
dark?: boolean;
|
24
|
+
data?: { [key: string]: string };
|
25
|
+
disableAnimation?: boolean;
|
26
|
+
fullCircle?: boolean;
|
27
|
+
height?: string;
|
28
|
+
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
29
|
+
id?: string;
|
30
|
+
max?: number;
|
31
|
+
min?: number;
|
32
|
+
prefix?: string;
|
33
|
+
showLabels?: boolean;
|
34
|
+
style?: string;
|
35
|
+
suffix?: string;
|
36
|
+
title?: string;
|
37
|
+
tooltipHtml?: string;
|
38
|
+
colors: string[];
|
39
|
+
minorTickInterval?: number;
|
40
|
+
circumference: number[];
|
41
|
+
};
|
42
|
+
|
43
|
+
const Gauge = ({
|
44
|
+
aria = {},
|
45
|
+
chartData,
|
46
|
+
customOptions = {},
|
47
|
+
dark = false,
|
48
|
+
data = {},
|
49
|
+
disableAnimation = false,
|
50
|
+
fullCircle = false,
|
51
|
+
height = null,
|
52
|
+
htmlOptions = {},
|
53
|
+
id,
|
54
|
+
max = 100,
|
55
|
+
min = 0,
|
56
|
+
prefix = "",
|
57
|
+
showLabels = false,
|
58
|
+
style = "solidgauge",
|
59
|
+
suffix = "",
|
60
|
+
title = "",
|
61
|
+
tooltipHtml = '<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: ' +
|
62
|
+
"<b>{point.y}</b>",
|
63
|
+
colors = [],
|
64
|
+
minorTickInterval = null,
|
65
|
+
circumference = fullCircle ? [0, 360] : [-100, 100],
|
66
|
+
...props
|
67
|
+
}: GaugeProps): React.ReactElement => {
|
68
|
+
const ariaProps = buildAriaProps(aria);
|
69
|
+
const dataProps = buildDataProps(data)
|
70
|
+
const htmlProps = buildHtmlProps(htmlOptions);
|
71
|
+
highchartsMore(Highcharts);
|
72
|
+
solidGauge(Highcharts);
|
73
|
+
const setupTheme = () => {
|
74
|
+
dark
|
75
|
+
? Highcharts.setOptions(highchartsDarkTheme)
|
76
|
+
: Highcharts.setOptions(highchartsTheme);
|
77
|
+
};
|
78
|
+
setupTheme();
|
79
|
+
|
80
|
+
//set tooltip directly to prevent being overriden by Highcharts defaults
|
81
|
+
Highcharts.setOptions({
|
82
|
+
tooltip: {
|
83
|
+
pointFormat: tooltipHtml,
|
84
|
+
followPointer: true,
|
85
|
+
},
|
86
|
+
});
|
87
|
+
|
88
|
+
const css = buildCss({
|
89
|
+
pb_gauge_kit: true,
|
90
|
+
});
|
91
|
+
|
92
|
+
const [options, setOptions] = useState({});
|
93
|
+
|
94
|
+
useEffect(() => {
|
95
|
+
const formattedChartData = chartData.map((obj: GenericObject) => {
|
96
|
+
obj.y = obj.value;
|
97
|
+
delete obj.value;
|
98
|
+
return obj;
|
99
|
+
});
|
100
|
+
|
101
|
+
const staticOptions = {
|
102
|
+
chart: {
|
103
|
+
events: {
|
104
|
+
load() {
|
105
|
+
setTimeout(this.reflow.bind(this), 0);
|
106
|
+
},
|
107
|
+
},
|
108
|
+
type: style,
|
109
|
+
height: height,
|
110
|
+
},
|
111
|
+
title: {
|
112
|
+
text: title,
|
113
|
+
},
|
114
|
+
yAxis: {
|
115
|
+
min: min,
|
116
|
+
max: max,
|
117
|
+
lineWidth: 0,
|
118
|
+
tickWidth: 0,
|
119
|
+
minorTickInterval: minorTickInterval,
|
120
|
+
tickAmount: 2,
|
121
|
+
tickPositions: [min, max],
|
122
|
+
labels: {
|
123
|
+
y: 26,
|
124
|
+
enabled: showLabels,
|
125
|
+
},
|
126
|
+
},
|
127
|
+
credits: false,
|
128
|
+
series: [
|
129
|
+
{
|
130
|
+
data: formattedChartData,
|
131
|
+
},
|
132
|
+
],
|
133
|
+
pane: {
|
134
|
+
center: ["50%", "50%"],
|
135
|
+
size: "90%",
|
136
|
+
startAngle: circumference[0],
|
137
|
+
endAngle: circumference[1],
|
138
|
+
background: {
|
139
|
+
borderWidth: 20,
|
140
|
+
innerRadius: "90%",
|
141
|
+
outerRadius: "90%",
|
142
|
+
shape: "arc",
|
143
|
+
className: "gauge-pane",
|
144
|
+
},
|
145
|
+
},
|
146
|
+
colors:
|
147
|
+
colors !== undefined && colors.length > 0
|
148
|
+
? mapColors(colors)
|
149
|
+
: highchartsTheme.colors,
|
150
|
+
plotOptions: {
|
151
|
+
series: {
|
152
|
+
animation: !disableAnimation,
|
153
|
+
},
|
154
|
+
solidgauge: {
|
155
|
+
borderColor:
|
156
|
+
colors !== undefined && colors.length === 1
|
157
|
+
? mapColors(colors).join()
|
158
|
+
: highchartsTheme.colors[0],
|
159
|
+
borderWidth: 20,
|
160
|
+
radius: 90,
|
161
|
+
innerRadius: "90%",
|
162
|
+
dataLabels: {
|
163
|
+
borderWidth: 0,
|
164
|
+
color: defaultColors.text_lt_default,
|
165
|
+
enabled: true,
|
166
|
+
format:
|
167
|
+
`<span class="prefix">${prefix}</span>` +
|
168
|
+
'<span class="fix">{y:,f}</span>' +
|
169
|
+
`<span class="suffix">${suffix}</span>`,
|
170
|
+
style: {
|
171
|
+
fontFamily: typography.font_family_base,
|
172
|
+
fontWeight: typography.regular,
|
173
|
+
fontSize: typography.heading_2,
|
174
|
+
},
|
175
|
+
y: -26,
|
176
|
+
},
|
177
|
+
},
|
178
|
+
},
|
179
|
+
};
|
180
|
+
|
181
|
+
setOptions(merge(staticOptions, customOptions));
|
182
|
+
|
183
|
+
if (document.querySelector(".prefix")) {
|
184
|
+
document.querySelectorAll(".prefix").forEach((prefix) => {
|
185
|
+
prefix.setAttribute("y", "28");
|
186
|
+
});
|
187
|
+
document
|
188
|
+
.querySelectorAll(".fix")
|
189
|
+
.forEach((fix) => fix.setAttribute("y", "38"));
|
190
|
+
}
|
191
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
192
|
+
}, [chartData]);
|
2
193
|
|
3
|
-
const Gauge: React.FC = () => {
|
4
194
|
return (
|
5
|
-
<
|
6
|
-
|
7
|
-
|
195
|
+
<HighchartsReact
|
196
|
+
containerProps={{
|
197
|
+
className: classnames(css, globalProps(props)),
|
198
|
+
id: id,
|
199
|
+
...ariaProps,
|
200
|
+
...dataProps,
|
201
|
+
...htmlProps,
|
202
|
+
}}
|
203
|
+
highcharts={Highcharts}
|
204
|
+
options={options}
|
205
|
+
/>
|
8
206
|
);
|
9
207
|
};
|
10
208
|
|
@@ -1,10 +1,159 @@
|
|
1
|
-
import React from
|
1
|
+
import React, { useState, useEffect } from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
import { globalProps } from "../utilities/globalProps";
|
4
|
+
import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
|
5
|
+
|
6
|
+
import HighchartsReact from "highcharts-react-official";
|
7
|
+
import Highcharts from "highcharts";
|
8
|
+
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
9
|
+
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
10
|
+
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
11
|
+
import { merge } from 'lodash'
|
12
|
+
|
13
|
+
type LineGraphProps = {
|
14
|
+
align?: "left" | "right" | "center";
|
15
|
+
axisTitle?: string;
|
16
|
+
dark?: boolean;
|
17
|
+
xAxisCategories: [];
|
18
|
+
yAxisMin: number;
|
19
|
+
yAxisMax: number;
|
20
|
+
className?: string;
|
21
|
+
chartData: {
|
22
|
+
name: string;
|
23
|
+
data: number[];
|
24
|
+
}[];
|
25
|
+
customOptions?: Partial<Highcharts.Options>;
|
26
|
+
gradient?: boolean;
|
27
|
+
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
28
|
+
id: string;
|
29
|
+
pointStart: number;
|
30
|
+
subTitle?: string;
|
31
|
+
title: string;
|
32
|
+
type?: string;
|
33
|
+
legend?: boolean;
|
34
|
+
toggleLegendClick?: boolean;
|
35
|
+
height?: string;
|
36
|
+
colors: string[];
|
37
|
+
layout?: "horizontal" | "vertical" | "proximate";
|
38
|
+
verticalAlign?: "top" | "middle" | "bottom";
|
39
|
+
x?: number;
|
40
|
+
y?: number;
|
41
|
+
aria?: { [key: string]: string };
|
42
|
+
data?: { [key: string]: string };
|
43
|
+
};
|
44
|
+
|
45
|
+
const LineGraph = ({
|
46
|
+
aria = {},
|
47
|
+
data = {},
|
48
|
+
align = "center",
|
49
|
+
className = "pb_bar_graph",
|
50
|
+
customOptions = {},
|
51
|
+
dark = false,
|
52
|
+
gradient = false,
|
53
|
+
type = "line",
|
54
|
+
htmlOptions = {},
|
55
|
+
id,
|
56
|
+
legend = false,
|
57
|
+
toggleLegendClick = true,
|
58
|
+
layout = "horizontal",
|
59
|
+
verticalAlign = "bottom",
|
60
|
+
x = 0,
|
61
|
+
y = 0,
|
62
|
+
axisTitle,
|
63
|
+
xAxisCategories,
|
64
|
+
yAxisMin,
|
65
|
+
yAxisMax,
|
66
|
+
chartData,
|
67
|
+
pointStart,
|
68
|
+
subTitle,
|
69
|
+
title,
|
70
|
+
height,
|
71
|
+
colors = [],
|
72
|
+
...props
|
73
|
+
}: LineGraphProps) => {
|
74
|
+
|
75
|
+
const ariaProps = buildAriaProps(aria)
|
76
|
+
const dataProps = buildDataProps(data)
|
77
|
+
const htmlProps = buildHtmlProps(htmlOptions)
|
78
|
+
|
79
|
+
const setupTheme = () => {
|
80
|
+
dark
|
81
|
+
? Highcharts.setOptions(highchartsDarkTheme)
|
82
|
+
: Highcharts.setOptions(highchartsTheme);
|
83
|
+
};
|
84
|
+
setupTheme();
|
85
|
+
|
86
|
+
const staticOptions = {
|
87
|
+
title: {
|
88
|
+
text: title,
|
89
|
+
},
|
90
|
+
chart: {
|
91
|
+
height: height,
|
92
|
+
type: type,
|
93
|
+
},
|
94
|
+
subtitle: {
|
95
|
+
text: subTitle,
|
96
|
+
},
|
97
|
+
yAxis: {
|
98
|
+
min: yAxisMin,
|
99
|
+
max: yAxisMax,
|
100
|
+
title: {
|
101
|
+
text: axisTitle,
|
102
|
+
},
|
103
|
+
},
|
104
|
+
xAxis: {
|
105
|
+
categories: xAxisCategories,
|
106
|
+
},
|
107
|
+
legend: {
|
108
|
+
enabled: legend,
|
109
|
+
align: align,
|
110
|
+
verticalAlign: verticalAlign,
|
111
|
+
layout: layout,
|
112
|
+
x: x,
|
113
|
+
y: y,
|
114
|
+
},
|
115
|
+
colors:
|
116
|
+
colors !== undefined && colors.length > 0
|
117
|
+
? mapColors(colors)
|
118
|
+
: highchartsTheme.colors,
|
119
|
+
plotOptions: {
|
120
|
+
series: {
|
121
|
+
pointStart: pointStart,
|
122
|
+
events: {},
|
123
|
+
dataLabels: {
|
124
|
+
enabled: false,
|
125
|
+
},
|
126
|
+
},
|
127
|
+
},
|
128
|
+
series: chartData,
|
129
|
+
credits: false,
|
130
|
+
};
|
131
|
+
|
132
|
+
if (!toggleLegendClick) {
|
133
|
+
staticOptions.plotOptions.series.events = { legendItemClick: () => false };
|
134
|
+
}
|
135
|
+
|
136
|
+
const filteredProps: any = {...props};
|
137
|
+
delete filteredProps.verticalAlign;
|
138
|
+
|
139
|
+
const [options, setOptions] = useState({});
|
140
|
+
|
141
|
+
useEffect(() => {
|
142
|
+
setOptions(merge(staticOptions, customOptions));
|
143
|
+
}, [chartData]);
|
2
144
|
|
3
|
-
const LineGraph: React.FC = () => {
|
4
145
|
return (
|
5
|
-
<
|
6
|
-
|
7
|
-
|
146
|
+
<HighchartsReact
|
147
|
+
containerProps={{
|
148
|
+
className: classnames(globalProps(filteredProps), className),
|
149
|
+
id: id,
|
150
|
+
...ariaProps,
|
151
|
+
...dataProps,
|
152
|
+
...htmlProps
|
153
|
+
}}
|
154
|
+
highcharts={Highcharts}
|
155
|
+
options={options}
|
156
|
+
/>
|
8
157
|
);
|
9
158
|
};
|
10
159
|
|
@@ -28,9 +28,9 @@
|
|
28
28
|
popoverButton.onclick = () => {
|
29
29
|
buttonClicked = !buttonClicked
|
30
30
|
if (buttonClicked) {
|
31
|
-
arrowDiv.innerHTML = '<
|
31
|
+
arrowDiv.innerHTML = '<i class="far fa-angle-up"></i>'
|
32
32
|
} else {
|
33
|
-
arrowDiv.innerHTML = '<
|
33
|
+
arrowDiv.innerHTML = '<i class="far fa-angle-down"></i>'
|
34
34
|
}
|
35
35
|
}
|
36
36
|
</script>
|
@@ -10,7 +10,6 @@
|
|
10
10
|
<%= pb_rails("radio", props: {
|
11
11
|
custom_children: true,
|
12
12
|
label: "Select",
|
13
|
-
margin_bottom: "sm",
|
14
13
|
name: "Group1",
|
15
14
|
value: "Select",
|
16
15
|
}) do %>
|
@@ -23,7 +22,6 @@
|
|
23
22
|
<%= pb_rails("radio", props: {
|
24
23
|
custom_children: true,
|
25
24
|
label: "Typeahead",
|
26
|
-
margin_bottom: "sm",
|
27
25
|
name: "Group1",
|
28
26
|
value: "Typeahead",
|
29
27
|
}) do %>
|
@@ -19,14 +19,12 @@ const RadioChildren = (props) => {
|
|
19
19
|
<Radio
|
20
20
|
customChildren
|
21
21
|
label="Select"
|
22
|
-
marginBottom="sm"
|
23
22
|
name="Group1"
|
24
23
|
tabIndex={0}
|
25
24
|
value="Select"
|
26
25
|
{...props}
|
27
26
|
>
|
28
|
-
<Select
|
29
|
-
marginBottom="none"
|
27
|
+
<Select
|
30
28
|
minWidth="xs"
|
31
29
|
options={options}
|
32
30
|
/>
|
@@ -34,18 +32,17 @@ const RadioChildren = (props) => {
|
|
34
32
|
<Radio
|
35
33
|
customChildren
|
36
34
|
label="Typeahead"
|
37
|
-
marginBottom="sm"
|
38
35
|
name="Group1"
|
39
36
|
tabIndex={0}
|
40
37
|
value="Typeahead"
|
41
38
|
{...props}
|
42
39
|
>
|
43
40
|
<Typeahead
|
44
|
-
marginBottom="none"
|
45
41
|
minWidth="xs"
|
46
42
|
options={options}
|
47
43
|
/>
|
48
44
|
</Radio>
|
45
|
+
<br />
|
49
46
|
<Radio
|
50
47
|
customChildren
|
51
48
|
defaultChecked={false}
|
@@ -1,10 +1,118 @@
|
|
1
|
-
import React from
|
1
|
+
import React, { useState, useEffect } from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
|
4
|
+
import { globalProps } from "../utilities/globalProps";
|
5
|
+
import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
|
6
|
+
|
7
|
+
import HighchartsReact from "highcharts-react-official";
|
8
|
+
import Highcharts from "highcharts";
|
9
|
+
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
10
|
+
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
11
|
+
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
12
|
+
import treemap from 'highcharts/modules/treemap'
|
13
|
+
import { merge } from 'lodash'
|
14
|
+
|
15
|
+
type TreemapChartProps = {
|
16
|
+
chartData: {
|
17
|
+
name: string;
|
18
|
+
parent?: string | number;
|
19
|
+
value: number;
|
20
|
+
color?: string;
|
21
|
+
id?: string | number;
|
22
|
+
}[];
|
23
|
+
className?: string;
|
24
|
+
colors: string[];
|
25
|
+
customOptions?: Partial<Highcharts.Options>;
|
26
|
+
dark?: boolean;
|
27
|
+
drillable: boolean;
|
28
|
+
grouped: boolean;
|
29
|
+
height?: string;
|
30
|
+
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
31
|
+
id: number | string;
|
32
|
+
title?: string;
|
33
|
+
tooltipHtml: string;
|
34
|
+
type?: string;
|
35
|
+
aria?: { [key: string]: string };
|
36
|
+
data?: { [key: string]: string };
|
37
|
+
};
|
38
|
+
|
39
|
+
const TreemapChart = ({
|
40
|
+
aria = {},
|
41
|
+
data = {},
|
42
|
+
chartData,
|
43
|
+
colors,
|
44
|
+
customOptions = {},
|
45
|
+
dark = false,
|
46
|
+
drillable = false,
|
47
|
+
grouped = false,
|
48
|
+
height,
|
49
|
+
htmlOptions = {},
|
50
|
+
id,
|
51
|
+
title = "",
|
52
|
+
tooltipHtml = '<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.value}</b>',
|
53
|
+
type = "treemap",
|
54
|
+
...props
|
55
|
+
}: TreemapChartProps): React.ReactElement => {
|
56
|
+
|
57
|
+
const ariaProps = buildAriaProps(aria)
|
58
|
+
const dataProps = buildDataProps(data)
|
59
|
+
const htmlProps = buildHtmlProps(htmlOptions)
|
60
|
+
|
61
|
+
const setupTheme = () => {
|
62
|
+
dark
|
63
|
+
? Highcharts.setOptions(highchartsDarkTheme)
|
64
|
+
: Highcharts.setOptions(highchartsTheme);
|
65
|
+
};
|
66
|
+
treemap(Highcharts)
|
67
|
+
setupTheme();
|
68
|
+
|
69
|
+
const staticOptions = {
|
70
|
+
title: {
|
71
|
+
text: title,
|
72
|
+
},
|
73
|
+
chart: {
|
74
|
+
height: height,
|
75
|
+
type: type,
|
76
|
+
},
|
77
|
+
credits: false,
|
78
|
+
series: [
|
79
|
+
{
|
80
|
+
data: chartData,
|
81
|
+
},
|
82
|
+
],
|
83
|
+
plotOptions: {
|
84
|
+
treemap: {
|
85
|
+
tooltip: {
|
86
|
+
pointFormat: tooltipHtml,
|
87
|
+
},
|
88
|
+
allowTraversingTree: drillable,
|
89
|
+
colorByPoint: !grouped,
|
90
|
+
colors:
|
91
|
+
colors !== undefined && colors.length > 0
|
92
|
+
? mapColors(colors)
|
93
|
+
: highchartsTheme.colors,
|
94
|
+
},
|
95
|
+
},
|
96
|
+
};
|
97
|
+
|
98
|
+
const [options, setOptions] = useState({});
|
99
|
+
|
100
|
+
useEffect(() => {
|
101
|
+
setOptions(merge(staticOptions, customOptions));
|
102
|
+
}, [chartData]);
|
2
103
|
|
3
|
-
const TreemapChart: React.FC = () => {
|
4
104
|
return (
|
5
|
-
<
|
6
|
-
|
7
|
-
|
105
|
+
<HighchartsReact
|
106
|
+
containerProps={{
|
107
|
+
className: classnames(globalProps(props), "pb_treemap_chart"),
|
108
|
+
id: id,
|
109
|
+
...ariaProps,
|
110
|
+
...dataProps,
|
111
|
+
...htmlProps
|
112
|
+
}}
|
113
|
+
highcharts={Highcharts}
|
114
|
+
options={options}
|
115
|
+
/>
|
8
116
|
);
|
9
117
|
};
|
10
118
|
|