playbook_ui 13.12.0.pre.alpha.play1051highchartstest1558 → 13.12.0.pre.alpha.play1051testhighcharts1574

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,116 +1,117 @@
1
- // import React, { useState, useEffect } from "react";
2
- // import classnames from "classnames";
1
+ /* eslint-disable */
2
+ import React, { useState, useEffect } from "react";
3
+ import classnames from "classnames";
3
4
 
4
- // import { globalProps } from "../utilities/globalProps";
5
- // import { buildAriaProps, buildDataProps } from "../utilities/props";
5
+ import { globalProps } from "../utilities/globalProps";
6
+ import { buildAriaProps, buildDataProps } from "../utilities/props";
6
7
 
7
- // import HighchartsReact from "highcharts-react-official";
8
- // import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
9
- // import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
10
- // import mapColors from "../pb_dashboard/pbChartsColorsHelper";
11
- // import treemap from 'highcharts/modules/treemap'
8
+ import HighchartsReact from "highcharts-react-official";
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'
12
13
 
13
- // type TreemapChartProps = {
14
- // chartData: {
15
- // name: string,
16
- // parent?: string | number,
17
- // value: number,
18
- // color?: string,
19
- // id?: string | number,
20
- // }[],
21
- // className?: string,
22
- // colors: string[],
23
- // dark?: boolean,
24
- // drillable: boolean,
25
- // grouped: boolean,
26
- // height?: string,
27
- // id: number | string,
28
- // title?: string,
29
- // tooltipHtml: string,
30
- // type?: string,
31
- // aria?: { [key: string]: string },
32
- // data?: { [key: string]: string },
33
- // };
14
+ type TreemapChartProps = {
15
+ chartData: {
16
+ name: string,
17
+ parent?: string | number,
18
+ value: number,
19
+ color?: string,
20
+ id?: string | number,
21
+ }[],
22
+ className?: string,
23
+ colors: string[],
24
+ dark?: boolean,
25
+ drillable: boolean,
26
+ grouped: boolean,
27
+ height?: string,
28
+ id: number | string,
29
+ title?: string,
30
+ tooltipHtml: string,
31
+ type?: string,
32
+ aria?: { [key: string]: string },
33
+ data?: { [key: string]: string },
34
+ };
34
35
 
35
- // const TreemapChart = ({
36
- // aria = {},
37
- // data = {},
38
- // chartData,
39
- // colors,
40
- // dark = false,
41
- // drillable = false,
42
- // grouped = false,
43
- // height,
44
- // id,
45
- // title = "",
46
- // tooltipHtml = '<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.value}</b>',
47
- // type = "treemap",
48
- // ...props
49
- // }: TreemapChartProps) => {
50
- // const ariaProps = buildAriaProps(aria);
51
- // const dataProps = buildDataProps(data);
36
+ const TreemapChart = ({
37
+ aria = {},
38
+ data = {},
39
+ chartData,
40
+ colors,
41
+ dark = false,
42
+ drillable = false,
43
+ grouped = false,
44
+ height,
45
+ id,
46
+ title = "",
47
+ tooltipHtml = '<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.value}</b>',
48
+ type = "treemap",
49
+ ...props
50
+ }: TreemapChartProps) => {
51
+ const ariaProps = buildAriaProps(aria);
52
+ const dataProps = buildDataProps(data);
52
53
 
53
- // const staticOptions = {
54
- // title: {
55
- // text: title,
56
- // },
57
- // chart: {
58
- // height: height,
59
- // type: type,
60
- // },
61
- // credits: false,
62
- // series: [
63
- // {
64
- // data: chartData,
65
- // },
66
- // ],
67
- // plotOptions: {
68
- // treemap: {
69
- // tooltip: {
70
- // pointFormat: tooltipHtml,
71
- // },
72
- // allowTraversingTree: drillable,
73
- // colorByPoint: !grouped,
74
- // colors:
75
- // colors !== undefined && colors.length > 0
76
- // ? mapColors(colors)
77
- // : highchartsTheme.colors,
78
- // },
79
- // },
80
- // };
54
+ const staticOptions = {
55
+ title: {
56
+ text: title,
57
+ },
58
+ chart: {
59
+ height: height,
60
+ type: type,
61
+ },
62
+ credits: false,
63
+ series: [
64
+ {
65
+ data: chartData,
66
+ },
67
+ ],
68
+ plotOptions: {
69
+ treemap: {
70
+ tooltip: {
71
+ pointFormat: tooltipHtml,
72
+ },
73
+ allowTraversingTree: drillable,
74
+ colorByPoint: !grouped,
75
+ colors:
76
+ colors !== undefined && colors.length > 0
77
+ ? mapColors(colors)
78
+ : highchartsTheme(window.Highcharts).colors,
79
+ },
80
+ },
81
+ };
81
82
 
82
- // const [options, setOptions] = useState({});
83
- // const [isHighchartsLoaded, setIsHighchartsLoaded] = useState(false);
83
+ const [options, setOptions] = useState({});
84
+ const [isHighchartsLoaded, setIsHighchartsLoaded] = useState(false);
84
85
 
85
- // useEffect(() => {
86
- // setOptions({ ...staticOptions });
86
+ useEffect(() => {
87
+ setOptions({ ...staticOptions });
87
88
 
88
- // const interval = setInterval(() => {
89
- // if (window.Highcharts) {
90
- // clearInterval(interval)
91
- // dark
92
- // ? window.Highcharts.setOptions(highchartsDarkTheme(window.Highcharts))
93
- // : window.Highcharts.setOptions(highchartsTheme)
89
+ const interval = setInterval(() => {
90
+ if (window.Highcharts) {
91
+ clearInterval(interval)
92
+ dark
93
+ ? window.Highcharts.setOptions(highchartsDarkTheme(window.Highcharts))
94
+ : window.Highcharts.setOptions(highchartsTheme(window.Highcharts))
94
95
 
95
- // treemap(window.Highcharts)
96
- // setIsHighchartsLoaded(true)
97
- // }
98
- // }, 0)
99
- // }, [chartData]);
96
+ treemap(window.Highcharts)
97
+ setIsHighchartsLoaded(true)
98
+ }
99
+ }, 0)
100
+ }, [chartData]);
100
101
 
101
- // return (
102
- // isHighchartsLoaded &&
103
- // <HighchartsReact
104
- // containerProps={{
105
- // className: classnames(globalProps(props), "pb_treemap_chart"),
106
- // id: id,
107
- // ...ariaProps,
108
- // ...dataProps,
109
- // }}
110
- // highcharts={window.Highcharts}
111
- // options={options}
112
- // />
113
- // );
114
- // };
102
+ return (
103
+ isHighchartsLoaded &&
104
+ <HighchartsReact
105
+ containerProps={{
106
+ className: classnames(globalProps(props), "pb_treemap_chart"),
107
+ id: id,
108
+ ...ariaProps,
109
+ ...dataProps,
110
+ }}
111
+ highcharts={window.Highcharts}
112
+ options={options}
113
+ />
114
+ );
115
+ };
115
116
 
116
- // export default TreemapChart;
117
+ export default TreemapChart;
@@ -39,7 +39,7 @@ import * as FixedConfirmationToast from 'pb_fixed_confirmation_toast/docs'
39
39
  import * as Flex from 'pb_flex/docs'
40
40
  import * as FormGroup from 'pb_form_group/docs'
41
41
  import * as FormPill from 'pb_form_pill/docs'
42
- //import * as Gauge from 'pb_gauge/docs'
42
+ import * as Gauge from 'pb_gauge/docs'
43
43
  import * as Hashtag from 'pb_hashtag/docs'
44
44
  import * as Highlight from 'pb_highlight/docs'
45
45
  import * as HomeAddressStreet from 'pb_home_address_street/docs'
@@ -97,7 +97,7 @@ import * as TitleCount from 'pb_title_count/docs'
97
97
  import * as TitleDetail from 'pb_title_detail/docs'
98
98
  import * as Toggle from 'pb_toggle/docs'
99
99
  import * as Tooltip from 'pb_tooltip/docs'
100
- //import * as TreemapChart from 'pb_treemap_chart/docs'
100
+ import * as TreemapChart from 'pb_treemap_chart/docs'
101
101
  import * as Typeahead from 'pb_typeahead/docs'
102
102
  import * as User from 'pb_user/docs'
103
103
  import * as UserBadge from 'pb_user_badge/docs'
@@ -140,7 +140,7 @@ WebpackerReact.registerComponents({
140
140
  ...Flex,
141
141
  ...FormGroup,
142
142
  ...FormPill,
143
- //...Gauge,
143
+ ...Gauge,
144
144
  ...Hashtag,
145
145
  ...Highlight,
146
146
  ...HomeAddressStreet,
@@ -198,7 +198,7 @@ WebpackerReact.registerComponents({
198
198
  ...TitleDetail,
199
199
  ...Toggle,
200
200
  ...Tooltip,
201
- //...TreemapChart,
201
+ ...TreemapChart,
202
202
  ...Typeahead,
203
203
  ...User,
204
204
  ...UserBadge,
@@ -10,13 +10,13 @@ import DialogBody from './pb_dialog/child_kits/_dialog_body'
10
10
  import DialogFooter from './pb_dialog/child_kits/_dialog_footer'
11
11
  import DialogHeader from './pb_dialog/child_kits/_dialog_header'
12
12
  import DistributionBar from './pb_distribution_bar/_distribution_bar'
13
- //import Gauge from './pb_gauge/_gauge'
13
+ import Gauge from './pb_gauge/_gauge'
14
14
  import Legend from './pb_legend/_legend'
15
15
  import LineGraph from './pb_line_graph/_line_graph'
16
16
  import MultiLevelSelect from './pb_multi_level_select/_multi_level_select'
17
17
  import Passphrase from './pb_passphrase/_passphrase'
18
18
  import RichTextEditor from './pb_rich_text_editor/_rich_text_editor'
19
- //import TreemapChart from './pb_treemap_chart/_treemap_chart'
19
+ import TreemapChart from './pb_treemap_chart/_treemap_chart'
20
20
  import Typeahead from './pb_typeahead/_typeahead'
21
21
  import PhoneNumberInput from './pb_phone_number_input/_phone_number_input'
22
22
 
@@ -33,9 +33,9 @@ WebpackerReact.registerComponents({
33
33
  LineGraph,
34
34
  Passphrase,
35
35
  RichTextEditor,
36
- //TreemapChart,
36
+ TreemapChart,
37
37
  Typeahead,
38
- //Gauge,
38
+ Gauge,
39
39
  PhoneNumberInput
40
40
  })
41
41