playbook_ui 13.12.0.pre.alpha.play1051highchartstest1567 → 13.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (23) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +32 -36
  3. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +63 -68
  4. data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.ts +3 -257
  5. data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +47 -59
  6. data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +34 -40
  7. data/app/pb_kits/playbook/pb_section_separator/docs/example.yml +0 -8
  8. data/app/pb_kits/playbook/pb_textarea/docs/example.yml +0 -5
  9. data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +102 -107
  10. data/app/pb_kits/playbook/playbook-doc.js +4 -4
  11. data/app/pb_kits/playbook/playbook-rails-react-bindings.js +4 -4
  12. data/dist/playbook-rails.js +7 -7
  13. data/lib/playbook/version.rb +2 -2
  14. metadata +7 -16
  15. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_children_swift.md +0 -14
  16. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_dashed_swift.md +0 -7
  17. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_line_swift.md +0 -8
  18. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_props_swift.md +0 -8
  19. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_text_swift.md +0 -7
  20. data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_vertical_swift.md +0 -18
  21. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_default_swift.md +0 -27
  22. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_error_swift.md +0 -11
  23. data/app/pb_kits/playbook/pb_textarea/docs/_textarea_props_swift.md +0 -9
@@ -1,7 +1,7 @@
1
- /* eslint-disable */
2
1
  import React, { useState, useEffect } from "react";
3
2
  import classnames from "classnames";
4
3
  import HighchartsReact from "highcharts-react-official";
4
+ import Highcharts from "highcharts";
5
5
  import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
6
6
  import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
7
7
  import mapColors from "../pb_dashboard/pbChartsColorsHelper";
@@ -14,26 +14,26 @@ import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
14
14
  import { globalProps } from "../utilities/globalProps";
15
15
 
16
16
  type GaugeProps = {
17
- aria: { [key: string]: string },
18
- className?: string,
19
- chartData?: { name: string, value: number[] | number }[],
20
- dark?: boolean,
21
- data?: { [key: string]: string },
22
- disableAnimation?: boolean,
23
- fullCircle?: boolean,
24
- height?: string,
25
- id?: string,
26
- max?: number,
27
- min?: number,
28
- prefix?: string,
29
- showLabels?: boolean,
30
- style?: string,
31
- suffix?: string,
32
- title?: string,
33
- tooltipHtml?: string,
34
- colors: string[],
35
- minorTickInterval: any,
36
- circumference: number[],
17
+ aria: { [key: string]: string };
18
+ className?: string;
19
+ chartData?: { name: string; value: number[] | number }[];
20
+ dark?: Boolean;
21
+ data?: { [key: string]: string };
22
+ disableAnimation?: boolean;
23
+ fullCircle?: boolean;
24
+ height?: string;
25
+ id?: string;
26
+ max?: number;
27
+ min?: number;
28
+ prefix?: string;
29
+ showLabels?: boolean;
30
+ style?: string;
31
+ suffix?: string;
32
+ title?: string;
33
+ tooltipHtml?: string;
34
+ colors: string[];
35
+ minorTickInterval: any;
36
+ circumference: number[];
37
37
  };
38
38
 
39
39
  const Gauge = ({
@@ -54,7 +54,7 @@ const Gauge = ({
54
54
  suffix = "",
55
55
  title = "",
56
56
  tooltipHtml = '<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: ' +
57
- "<b>{point.y}</b>",
57
+ "<b>{point.y}</b>",
58
58
  colors = [],
59
59
  minorTickInterval = null,
60
60
  circumference = fullCircle ? [0, 360] : [-100, 100],
@@ -62,13 +62,28 @@ const Gauge = ({
62
62
  }: GaugeProps) => {
63
63
  const ariaProps = buildAriaProps(aria);
64
64
  const dataProps = buildDataProps(data);
65
+ highchartsMore(Highcharts);
66
+ solidGauge(Highcharts);
67
+ const setupTheme = () => {
68
+ dark
69
+ ? Highcharts.setOptions(highchartsDarkTheme)
70
+ : Highcharts.setOptions(highchartsTheme);
71
+ };
72
+ setupTheme();
73
+
74
+ //set tooltip directly to prevent being overriden by Highcharts defaults
75
+ Highcharts.setOptions({
76
+ tooltip: {
77
+ pointFormat: tooltipHtml,
78
+ followPointer: true,
79
+ },
80
+ });
65
81
 
66
82
  const css = buildCss({
67
83
  pb_gauge_kit: true,
68
84
  });
69
85
 
70
86
  const [options, setOptions] = useState({});
71
- const [isHighchartsLoaded, setIsHighchartsLoaded] = useState(false);
72
87
 
73
88
  useEffect(() => {
74
89
  const formattedChartData = chartData.map((obj: any) => {
@@ -159,45 +174,18 @@ const Gauge = ({
159
174
 
160
175
  setOptions({ ...staticOptions });
161
176
 
162
- const interval = setInterval(() => {
163
- if (window.Highcharts) {
164
- clearInterval(interval)
165
-
166
- const gaugeInterval = setInterval(() => {
167
- if (document.querySelector(".prefix")) {
168
- clearInterval(gaugeInterval)
169
- document.querySelectorAll(".prefix").forEach((prefix) => {
170
- prefix.setAttribute("y", "28");
171
- });
172
- document
173
- .querySelectorAll(".fix")
174
- .forEach((fix) => fix.setAttribute("y", "38"));
175
- }
176
- }, 0)
177
-
178
- dark
179
- ? window.Highcharts.setOptions(highchartsDarkTheme(window.Highcharts))
180
- : window.Highcharts.setOptions(highchartsTheme)
181
-
182
- highchartsMore(window.Highcharts);
183
- solidGauge(window.Highcharts);
184
-
185
- //set tooltip directly to prevent being overriden by window.Highcharts defaults
186
- window.Highcharts.setOptions({
187
- tooltip: {
188
- pointFormat: tooltipHtml,
189
- followPointer: true,
190
- },
191
- });
192
-
193
- setIsHighchartsLoaded(true)
194
- }
195
- }, 0)
177
+ if (document.querySelector(".prefix")) {
178
+ document.querySelectorAll(".prefix").forEach((prefix) => {
179
+ prefix.setAttribute("y", "28");
180
+ });
181
+ document
182
+ .querySelectorAll(".fix")
183
+ .forEach((fix) => fix.setAttribute("y", "38"));
184
+ }
196
185
 
197
186
  }, [chartData]);
198
187
 
199
188
  return (
200
- isHighchartsLoaded &&
201
189
  <HighchartsReact
202
190
  containerProps={{
203
191
  className: classnames(css, globalProps(props)),
@@ -205,7 +193,7 @@ const Gauge = ({
205
193
  ...ariaProps,
206
194
  ...dataProps,
207
195
  }}
208
- highcharts={window.Highcharts}
196
+ highcharts={Highcharts}
209
197
  options={options}
210
198
  />
211
199
  );
@@ -1,42 +1,42 @@
1
- /* eslint-disable */
2
1
  import React, { useState, useEffect } from "react";
3
2
  import classnames from "classnames";
4
3
  import { globalProps } from "../utilities/globalProps";
5
4
  import { buildAriaProps, buildDataProps } from "../utilities/props";
6
5
 
7
6
  import HighchartsReact from "highcharts-react-official";
7
+ import Highcharts from "highcharts";
8
8
  import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
9
9
  import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
10
10
  import mapColors from "../pb_dashboard/pbChartsColorsHelper";
11
11
 
12
12
  type LineGraphProps = {
13
- align?: "left" | "right" | "center",
14
- axisTitle?: string,
15
- dark?: boolean,
16
- xAxisCategories: [],
17
- yAxisMin: number,
18
- yAxisMax: number,
19
- className?: string,
13
+ align?: "left" | "right" | "center";
14
+ axisTitle?: string;
15
+ dark?: Boolean;
16
+ xAxisCategories: [];
17
+ yAxisMin: number;
18
+ yAxisMax: number;
19
+ className?: string;
20
20
  chartData: {
21
- name: string,
22
- data: number[],
23
- }[],
24
- gradient?: boolean,
25
- id: string,
26
- pointStart: number,
27
- subTitle?: string,
28
- title: string,
29
- type?: string,
30
- legend?: boolean,
31
- toggleLegendClick?: boolean,
32
- height?: string,
33
- colors: string[],
34
- layout?: "horizontal" | "vertical" | "proximate",
35
- verticalAlign?: "top" | "middle" | "bottom",
36
- x?: number,
37
- y?: number,
38
- aria?: { [key: string]: string },
39
- data?: { [key: string]: string },
21
+ name: string;
22
+ data: number[];
23
+ }[];
24
+ gradient?: boolean;
25
+ id: string;
26
+ pointStart: number;
27
+ subTitle?: string;
28
+ title: string;
29
+ type?: string;
30
+ legend?: boolean;
31
+ toggleLegendClick?: boolean;
32
+ height?: string;
33
+ colors: string[];
34
+ layout?: "horizontal" | "vertical" | "proximate";
35
+ verticalAlign?: "top" | "middle" | "bottom";
36
+ x?: number;
37
+ y?: number;
38
+ aria?: { [key: string]: string };
39
+ data?: { [key: string]: string };
40
40
  };
41
41
 
42
42
  const LineGraph = ({
@@ -68,6 +68,12 @@ const LineGraph = ({
68
68
  }: LineGraphProps) => {
69
69
  const ariaProps = buildAriaProps(aria);
70
70
  const dataProps = buildDataProps(data);
71
+ const setupTheme = () => {
72
+ dark
73
+ ? Highcharts.setOptions(highchartsDarkTheme)
74
+ : Highcharts.setOptions(highchartsTheme);
75
+ };
76
+ setupTheme();
71
77
 
72
78
  const staticOptions = {
73
79
  title: {
@@ -120,24 +126,12 @@ const LineGraph = ({
120
126
  }
121
127
 
122
128
  const [options, setOptions] = useState({});
123
- const [isHighchartsLoaded, setIsHighchartsLoaded] = useState(false);
124
129
 
125
130
  useEffect(() => {
126
131
  setOptions({ ...staticOptions });
127
-
128
- const interval = setInterval(() => {
129
- if (window.Highcharts) {
130
- clearInterval(interval)
131
- dark
132
- ? window.Highcharts.setOptions(highchartsDarkTheme(window.Highcharts))
133
- : window.Highcharts.setOptions(highchartsTheme)
134
- setIsHighchartsLoaded(true)
135
- }
136
- }, 0)
137
132
  }, [chartData]);
138
133
 
139
134
  return (
140
- isHighchartsLoaded &&
141
135
  <HighchartsReact
142
136
  containerProps={{
143
137
  className: classnames(globalProps(props), className),
@@ -145,7 +139,7 @@ const LineGraph = ({
145
139
  ...ariaProps,
146
140
  ...dataProps,
147
141
  }}
148
- highcharts={window.Highcharts}
142
+ highcharts={Highcharts}
149
143
  options={options}
150
144
  />
151
145
  );
@@ -13,11 +13,3 @@ examples:
13
13
  - section_separator_text: Text Separator
14
14
  - section_separator_vertical: Vertical
15
15
  - section_separator_children: Children
16
-
17
- swift:
18
- - section_separator_line_swift: Line Separator
19
- - section_separator_dashed_swift: Dashed Separator
20
- - section_separator_text_swift: Text Separator
21
- - section_separator_vertical_swift: Vertical
22
- - section_separator_children_swift: Children
23
- - section_separator_props_swift: ""
@@ -15,8 +15,3 @@ examples:
15
15
  - textarea_error: Textarea w/ Error
16
16
  - textarea_character_counter: Character Counter
17
17
  - textarea_inline: Inline
18
-
19
- swift:
20
- - textarea_default_swift: Default
21
- - textarea_error_swift: Textarea w/ Error
22
- - textarea_props_swift: ""
@@ -1,116 +1,111 @@
1
- // import React, { useState, useEffect } from "react";
2
- // import classnames from "classnames";
1
+ import React, { useState, useEffect } from "react";
2
+ import classnames from "classnames";
3
3
 
4
- // import { globalProps } from "../utilities/globalProps";
5
- // import { buildAriaProps, buildDataProps } from "../utilities/props";
4
+ import { globalProps } from "../utilities/globalProps";
5
+ import { buildAriaProps, buildDataProps } from "../utilities/props";
6
6
 
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'
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'
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);
53
+ const setupTheme = () => {
54
+ dark
55
+ ? Highcharts.setOptions(highchartsDarkTheme)
56
+ : Highcharts.setOptions(highchartsTheme);
57
+ };
58
+ treemap(Highcharts)
59
+ setupTheme();
52
60
 
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
- // };
61
+ const staticOptions = {
62
+ title: {
63
+ text: title,
64
+ },
65
+ chart: {
66
+ height: height,
67
+ type: type,
68
+ },
69
+ credits: false,
70
+ series: [
71
+ {
72
+ data: chartData,
73
+ },
74
+ ],
75
+ plotOptions: {
76
+ treemap: {
77
+ tooltip: {
78
+ pointFormat: tooltipHtml,
79
+ },
80
+ allowTraversingTree: drillable,
81
+ colorByPoint: !grouped,
82
+ colors:
83
+ colors !== undefined && colors.length > 0
84
+ ? mapColors(colors)
85
+ : highchartsTheme.colors,
86
+ },
87
+ },
88
+ };
81
89
 
82
- // const [options, setOptions] = useState({});
83
- // const [isHighchartsLoaded, setIsHighchartsLoaded] = useState(false);
90
+ const [options, setOptions] = useState({});
84
91
 
85
- // useEffect(() => {
86
- // setOptions({ ...staticOptions });
92
+ useEffect(() => {
93
+
94
+ setOptions({ ...staticOptions });
95
+ }, [chartData]);
87
96
 
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)
94
-
95
- // treemap(window.Highcharts)
96
- // setIsHighchartsLoaded(true)
97
- // }
98
- // }, 0)
99
- // }, [chartData]);
97
+ return (
98
+ <HighchartsReact
99
+ containerProps={{
100
+ className: classnames(globalProps(props), "pb_treemap_chart"),
101
+ id: id,
102
+ ...ariaProps,
103
+ ...dataProps,
104
+ }}
105
+ highcharts={Highcharts}
106
+ options={options}
107
+ />
108
+ );
109
+ };
100
110
 
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
- // };
115
-
116
- // export default TreemapChart;
111
+ 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