playbook_ui 14.24.0.pre.alpha.play23649503 → 14.24.0.pre.alpha.testingfa9512
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +175 -26
- data/app/pb_kits/playbook/pb_bar_graph/barGraph.test.js +2 -1
- data/app/pb_kits/playbook/pb_bar_graph/bar_graph.html.erb +1 -1
- data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +78 -12
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_default.html.erb +9 -21
- data/dist/chunks/_line_graph-D7DgMqnT.js +1 -0
- data/dist/chunks/{_typeahead-CKvqSXWH.js → _typeahead-BzYZCpJO.js} +2 -2
- data/dist/chunks/{_weekday_stacked-tedYzlIq.js → _weekday_stacked-CitcNYFp.js} +1 -1
- data/dist/chunks/{lib-BplzvaaY.js → lib-CY5ZPzic.js} +2 -2
- data/dist/chunks/{pb_form_validation-CA_noofR.js → pb_form_validation-D3b0JKHH.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +7 -7
- data/dist/chunks/_line_graph-BsZ3DcJo.js +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f4869f7e502273fc71ea5f7b53c860991c43cb12fe59a806d397c03cda10d2d
|
4
|
+
data.tar.gz: 4e9f278ae61820ecfafc37ae3ecef361c3f5681fd4ae07369d5b2dffa1a7ebdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32a456b43a9e918fa8f1557bf459622cb67ea95b5b755edad7acc2e4dcb36c8085ac29c695a1f61479bce4afc48bb3bbe3b379a6f766aede9334a1e30ea636eb
|
7
|
+
data.tar.gz: 682d9e6e24f97b67160d9abb75e79a7af2d23a51f6f3c6f2d9b1231337410c611fbcc07da24309e2a6397419e99fa18a36ce91e65906a40e3dd0695120b091cc
|
@@ -1,41 +1,190 @@
|
|
1
|
-
import React, {
|
1
|
+
import React, { useState, useEffect } from "react";
|
2
|
+
import { globalProps } from "../utilities/globalProps";
|
2
3
|
import { buildAriaProps, buildDataProps, buildHtmlProps } from "../utilities/props";
|
3
|
-
import Highcharts from "highcharts"
|
4
|
-
import HighchartsReact from "highcharts-react-official"
|
5
4
|
|
6
|
-
import
|
5
|
+
import HighchartsReact from "highcharts-react-official";
|
6
|
+
import Highcharts from "highcharts";
|
7
|
+
import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
8
|
+
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
9
|
+
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
10
|
+
import { merge } from '../utilities/object'
|
11
|
+
|
12
|
+
import classnames from "classnames";
|
7
13
|
|
8
14
|
type BarGraphProps = {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
15
|
+
align?: "left" | "right" | "center";
|
16
|
+
axisTitle: { name: string; }[] | string;
|
17
|
+
dark?: boolean;
|
18
|
+
xAxisCategories: [];
|
19
|
+
yAxisMin: number;
|
20
|
+
yAxisMax: number;
|
21
|
+
chartData: { name: string; data: number[], yAxis: number }[];
|
22
|
+
className?: string;
|
23
|
+
customOptions?: Partial<Highcharts.Options>;
|
24
|
+
id: string;
|
25
|
+
pointStart: number;
|
26
|
+
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
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
|
+
stacking?: "normal" | "percent"
|
41
|
+
axisFormat?: { format: string; }[] | string;
|
42
|
+
};
|
13
43
|
|
14
|
-
const BarGraph = ({
|
15
|
-
options,
|
16
|
-
containerProps = {},
|
17
|
-
data = {}
|
18
|
-
}: BarGraphProps): React.ReactElement => {
|
19
44
|
|
45
|
+
const BarGraph = ({
|
46
|
+
aria = {},
|
47
|
+
data = {},
|
48
|
+
align = "center",
|
49
|
+
axisTitle,
|
50
|
+
dark = false,
|
51
|
+
chartData,
|
52
|
+
className = "pb_bar_graph",
|
53
|
+
colors,
|
54
|
+
htmlOptions = {},
|
55
|
+
customOptions = {},
|
56
|
+
axisFormat,
|
57
|
+
id,
|
58
|
+
pointStart,
|
59
|
+
stacking,
|
60
|
+
subTitle,
|
61
|
+
type = "column",
|
62
|
+
title = "Title",
|
63
|
+
xAxisCategories,
|
64
|
+
yAxisMin,
|
65
|
+
yAxisMax,
|
66
|
+
legend = false,
|
67
|
+
toggleLegendClick = true,
|
68
|
+
height,
|
69
|
+
layout = "horizontal",
|
70
|
+
verticalAlign = "bottom",
|
71
|
+
x = 0,
|
72
|
+
y = 0,
|
73
|
+
...props
|
74
|
+
}: BarGraphProps): React.ReactElement => {
|
75
|
+
const ariaProps = buildAriaProps(aria);
|
20
76
|
const dataProps = buildDataProps(data)
|
77
|
+
const htmlProps = buildHtmlProps(htmlOptions);
|
78
|
+
const setupTheme = () => {
|
79
|
+
dark
|
80
|
+
? Highcharts.setOptions(highchartsDarkTheme)
|
81
|
+
: Highcharts.setOptions(highchartsTheme);
|
82
|
+
};
|
83
|
+
setupTheme();
|
84
|
+
|
85
|
+
const staticOptions = {
|
86
|
+
title: {
|
87
|
+
text: title,
|
88
|
+
},
|
89
|
+
chart: {
|
90
|
+
height: height,
|
91
|
+
type: type,
|
92
|
+
},
|
93
|
+
subtitle: {
|
94
|
+
text: subTitle,
|
95
|
+
},
|
96
|
+
yAxis: [{
|
97
|
+
labels: {
|
98
|
+
format: typeof axisFormat === 'string' ? axisFormat : (axisFormat && axisFormat[0] ? axisFormat[0].format : "")
|
21
99
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
100
|
+
},
|
101
|
+
min: yAxisMin,
|
102
|
+
max: yAxisMax,
|
103
|
+
opposite: false,
|
104
|
+
title: {
|
105
|
+
text: Array.isArray(axisTitle) ? (axisTitle.length > 0 ? axisTitle[0].name : null) : axisTitle,
|
106
|
+
},
|
107
|
+
plotLines: typeof yAxisMin !== 'undefined' && yAxisMin !== null ? [] : [{
|
108
|
+
value: 0,
|
109
|
+
zIndex: 10,
|
110
|
+
color: "#E4E8F0"
|
111
|
+
}],
|
112
|
+
}],
|
113
|
+
xAxis: {
|
114
|
+
categories: xAxisCategories,
|
115
|
+
},
|
116
|
+
legend: {
|
117
|
+
enabled: legend,
|
118
|
+
align: align,
|
119
|
+
verticalAlign: verticalAlign,
|
120
|
+
layout: layout,
|
121
|
+
x: x,
|
122
|
+
y: y,
|
123
|
+
},
|
124
|
+
colors:
|
125
|
+
colors !== undefined && colors.length > 0
|
126
|
+
? mapColors(colors)
|
127
|
+
: highchartsTheme.colors,
|
128
|
+
plotOptions: {
|
129
|
+
series: {
|
130
|
+
stacking: stacking,
|
131
|
+
pointStart: pointStart,
|
132
|
+
borderWidth: stacking ? 0 : "",
|
133
|
+
events: {},
|
134
|
+
dataLabels: {
|
135
|
+
enabled: false,
|
136
|
+
},
|
137
|
+
},
|
138
|
+
},
|
139
|
+
series: chartData,
|
140
|
+
credits: false,
|
141
|
+
};
|
28
142
|
|
29
|
-
|
30
|
-
|
143
|
+
if (Array.isArray(axisTitle) && axisTitle.length > 1 && axisTitle[1].name) {
|
144
|
+
staticOptions.yAxis.push({
|
145
|
+
labels: {
|
146
|
+
format: typeof axisFormat === 'string' ? axisFormat : axisFormat[1].format,
|
147
|
+
},
|
148
|
+
min: yAxisMin,
|
149
|
+
max: yAxisMax,
|
150
|
+
opposite: true,
|
151
|
+
title: {
|
152
|
+
text: axisTitle[1].name,
|
153
|
+
},
|
154
|
+
plotLines: typeof yAxisMin !== 'undefined' && yAxisMin !== null ? [] : [{
|
155
|
+
value: 0,
|
156
|
+
zIndex: 10,
|
157
|
+
color: "#E4E8F0"
|
158
|
+
}],
|
159
|
+
});
|
160
|
+
}
|
161
|
+
|
162
|
+
if (!toggleLegendClick) {
|
163
|
+
staticOptions.plotOptions.series.events = { legendItemClick: () => false };
|
164
|
+
}
|
165
|
+
|
166
|
+
const filteredProps: any = {...props};
|
167
|
+
delete filteredProps.verticalAlign;
|
168
|
+
|
169
|
+
const [options, setOptions] = useState({});
|
170
|
+
|
171
|
+
useEffect(() => {
|
172
|
+
setOptions(merge(staticOptions, customOptions));
|
173
|
+
}, [chartData]);
|
31
174
|
|
32
175
|
return (
|
33
176
|
<HighchartsReact
|
34
|
-
containerProps={{
|
177
|
+
containerProps={{
|
178
|
+
className: classnames(globalProps(filteredProps), className),
|
179
|
+
id: id,
|
180
|
+
...ariaProps,
|
181
|
+
...dataProps,
|
182
|
+
...htmlProps
|
183
|
+
}}
|
35
184
|
highcharts={Highcharts}
|
36
|
-
options={
|
185
|
+
options={options}
|
37
186
|
/>
|
38
|
-
)
|
39
|
-
}
|
187
|
+
);
|
188
|
+
};
|
40
189
|
|
41
|
-
export default BarGraph
|
190
|
+
export default BarGraph;
|
@@ -20,8 +20,9 @@ const testId = 'bargraph1';
|
|
20
20
|
test('bargraph uses exact classname', () => {
|
21
21
|
render(
|
22
22
|
<BarGraph
|
23
|
-
|
23
|
+
className='super_important_class'
|
24
24
|
data={{ testid: testId }}
|
25
|
+
id='bar-default'
|
25
26
|
/>
|
26
27
|
);
|
27
28
|
|
@@ -1 +1 @@
|
|
1
|
-
<%= react_component('BarGraph', object.
|
1
|
+
<%= react_component('BarGraph', object.chart_options) %>
|
@@ -3,25 +3,91 @@
|
|
3
3
|
module Playbook
|
4
4
|
module PbBarGraph
|
5
5
|
class BarGraph < Playbook::KitBase
|
6
|
-
prop :
|
7
|
-
|
6
|
+
prop :align, type: Playbook::Props::Enum,
|
7
|
+
values: %w[left right center],
|
8
|
+
default: "center"
|
9
|
+
prop :axis_title
|
10
|
+
prop :axis_format
|
11
|
+
prop :chart_data, type: Playbook::Props::Array,
|
12
|
+
default: []
|
13
|
+
prop :custom_options, default: {}
|
14
|
+
prop :orientation, type: Playbook::Props::Enum,
|
15
|
+
values: %w[vertical horizontal],
|
16
|
+
default: "vertical"
|
17
|
+
prop :point_start, type: Playbook::Props::Numeric
|
18
|
+
prop :stacking
|
19
|
+
prop :subtitle
|
20
|
+
prop :title
|
21
|
+
prop :x_axis_categories, type: Playbook::Props::Array,
|
22
|
+
default: []
|
23
|
+
prop :y_axis_min, type: Playbook::Props::Numeric
|
24
|
+
prop :y_axis_max, type: Playbook::Props::Numeric
|
25
|
+
prop :legend, type: Playbook::Props::Boolean,
|
26
|
+
default: false
|
27
|
+
prop :toggle_legend_click, type: Playbook::Props::Boolean,
|
28
|
+
default: true
|
29
|
+
prop :height
|
30
|
+
prop :colors, type: Playbook::Props::Array,
|
31
|
+
default: []
|
32
|
+
prop :layout, type: Playbook::Props::Enum,
|
33
|
+
values: %w[horizontal vertical proximate],
|
34
|
+
default: "horizontal"
|
35
|
+
prop :vertical_align, type: Playbook::Props::Enum,
|
36
|
+
values: %w[top middle bottom],
|
37
|
+
default: "bottom"
|
38
|
+
prop :x, type: Playbook::Props::Numeric
|
39
|
+
prop :y, type: Playbook::Props::Numeric
|
8
40
|
|
9
|
-
def
|
10
|
-
|
41
|
+
def chart_type
|
42
|
+
orientation == "horizontal" ? "bar" : "column"
|
11
43
|
end
|
12
44
|
|
13
|
-
def
|
45
|
+
def standard_options
|
14
46
|
{
|
15
|
-
|
16
|
-
|
47
|
+
align: align,
|
48
|
+
id: id,
|
49
|
+
className: classname,
|
50
|
+
chartData: chart_data,
|
51
|
+
dark: dark ? "dark" : "",
|
52
|
+
type: chart_type,
|
53
|
+
title: title,
|
54
|
+
stacking: stacking,
|
55
|
+
subTitle: subtitle,
|
56
|
+
axisTitle: axis_title,
|
57
|
+
axisFormat: axis_format,
|
58
|
+
pointStart: point_start,
|
59
|
+
xAxisCategories: x_axis_categories,
|
60
|
+
yAxisMin: y_axis_min,
|
61
|
+
yAxisMax: y_axis_max,
|
62
|
+
legend: legend,
|
63
|
+
toggleLegendClick: toggle_legend_click,
|
64
|
+
height: height,
|
65
|
+
colors: colors,
|
66
|
+
layout: layout,
|
67
|
+
verticalAlign: vertical_align,
|
68
|
+
x: x,
|
69
|
+
y: y,
|
17
70
|
}
|
18
71
|
end
|
19
72
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
73
|
+
def chart_options
|
74
|
+
standard_options.deep_merge(custom_options)
|
75
|
+
end
|
76
|
+
|
77
|
+
def vertical_align_props
|
78
|
+
if vertical_align
|
79
|
+
if object.vertical_align
|
80
|
+
original_result = super
|
81
|
+
class_to_remove = "vertical_align_#{object.vertical_align}"
|
82
|
+
|
83
|
+
modified_result = original_result.gsub(class_to_remove, "").strip
|
84
|
+
modified_result.empty? ? nil : modified_result
|
85
|
+
else
|
86
|
+
super
|
87
|
+
end
|
88
|
+
else
|
89
|
+
super
|
90
|
+
end
|
25
91
|
end
|
26
92
|
|
27
93
|
def classname
|
@@ -15,24 +15,12 @@
|
|
15
15
|
data: [1111,677,3245,500,200]
|
16
16
|
}] %>
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
xAxis: {
|
28
|
-
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
|
29
|
-
},
|
30
|
-
yAxis: {
|
31
|
-
title: {
|
32
|
-
text: 'Number of Employees',
|
33
|
-
},
|
34
|
-
},
|
35
|
-
}
|
36
|
-
%>
|
37
|
-
|
38
|
-
<%= pb_rails("bar_graph", props: {options: chart_options}) %>
|
18
|
+
<%= pb_rails("bar_graph", props: {
|
19
|
+
axis_title: 'Number of Employees',
|
20
|
+
chart_data: data,
|
21
|
+
id: "bar-default",
|
22
|
+
y_axis_min: 0,
|
23
|
+
x_axis_categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
|
24
|
+
subtitle: 'Source: thesolarfoundation.com',
|
25
|
+
title: 'Solar Employment Growth by Sector, 2010-2016',
|
26
|
+
}) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
import{jsx,Fragment,jsxs}from"react/jsx-runtime";import{useState,useEffect}from"react";import{b as buildAriaProps,c as buildDataProps,d as buildHtmlProps,H as HighchartsReact,e as Highcharts,f as classnames,g as globalProps,h as HighchartsMore,S as SolidGauge,i as buildCss}from"./_typeahead-BzYZCpJO.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-CY5ZPzic.js";const mapColors=array=>{const regex=/(data)\-[1-8]/;const newArray=array.map((item=>regex.test(item)?`${colors[`data_${item[item.length-1]}`]}`:item));return newArray};const BarGraph=({aria:aria={},data:data={},align:align="center",axisTitle:axisTitle,dark:dark=false,chartData:chartData,className:className="pb_bar_graph",colors:colors2,htmlOptions:htmlOptions={},customOptions:customOptions={},axisFormat:axisFormat,id:id,pointStart:pointStart,stacking:stacking,subTitle:subTitle,type:type="column",title:title="Title",xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,legend:legend=false,toggleLegendClick:toggleLegendClick=true,height:height,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:[{labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat&&axisFormat[0]?axisFormat[0].format:""},min:yAxisMin,max:yAxisMax,opposite:false,title:{text:Array.isArray(axisTitle)?axisTitle.length>0?axisTitle[0].name:null:axisTitle},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]}],xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{stacking:stacking,pointStart:pointStart,borderWidth:stacking?0:"",events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(Array.isArray(axisTitle)&&axisTitle.length>1&&axisTitle[1].name){staticOptions.yAxis.push({labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat[1].format},min:yAxisMin,max:yAxisMax,opposite:true,title:{text:axisTitle[1].name},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]})}if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const alignBlockElement=event=>{const itemToMove=document.querySelector(`#wrapper-circle-chart-${event.target.renderTo.id} .pb-circle-chart-block`);const chartContainer=document.querySelector(`#${event.target.renderTo.id}`);if(itemToMove!==null&&chartContainer!==null){itemToMove.style.height=`${event.target.chartHeight}px`;itemToMove.style.width=`${event.target.chartWidth}px`;if(chartContainer.firstChild!==null){chartContainer.firstChild.before(itemToMove)}}};const CircleChart=({align:align="center",aria:aria={},rounded:rounded=false,borderColor:borderColor=(rounded?null:""),borderWidth:borderWidth=(rounded?20:null),chartData:chartData,children:children,className:className,colors:colors2=[],customOptions:customOptions={},dark:dark=false,data:data={},dataLabelHtml:dataLabelHtml="<div>{point.name}</div>",dataLabels:dataLabels=false,height:height,htmlOptions:htmlOptions={},id:id,innerSize:innerSize="md",legend:legend=false,maxPointSize:maxPointSize=null,minPointSize:minPointSize=null,startAngle:startAngle=null,style:style="pie",title:title,tooltipHtml:tooltipHtml,useHtml:useHtml=false,zMin:zMin=null,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{headerFormat:null,pointFormat:tooltipHtml?tooltipHtml:'<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',useHTML:useHtml}});const innerSizes={sm:"35%",md:"50%",lg:"85%",none:"0%"};const innerSizeFormat=size=>innerSizes[size];const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={title:{text:title},chart:{height:height,type:style,events:{render:event=>alignBlockElement(event),redraw:event=>alignBlockElement(event)}},legend:{align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},plotOptions:{pie:{colors:colors2.length>0?mapColors(colors2):highchartsTheme.colors,dataLabels:{enabled:dataLabels,connectorShape:"straight",connectorWidth:3,format:dataLabelHtml},showInLegend:legend}},series:[{minPointSize:minPointSize,maxPointSize:maxPointSize,innerSize:borderWidth==20?"100%":innerSizeFormat(innerSize),data:formattedChartData,zMin:zMin,startAngle:startAngle,borderWidth:borderWidth,borderColor:borderColor}],credits:false};setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(Fragment,{children:children?jsxs("div",{id:`wrapper-circle-chart-${id}`,children:[jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options}),jsx("div",{className:"pb-circle-chart-block",children:children})]}):jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})})};const Gauge=({aria:aria={},chartData:chartData,customOptions:customOptions={},dark:dark=false,data:data={},disableAnimation:disableAnimation=false,fullCircle:fullCircle=false,height:height=null,htmlOptions:htmlOptions={},id:id,max:max=100,min:min=0,prefix:prefix="",showLabels:showLabels=false,style:style="solidgauge",suffix:suffix="",title:title="",tooltipHtml:tooltipHtml='<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',colors:colors$1=[],minorTickInterval:minorTickInterval=null,circumference:circumference=(fullCircle?[0,360]:[-100,100]),...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);SolidGauge(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{pointFormat:tooltipHtml,followPointer:true}});const css=buildCss({pb_gauge_kit:true});const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={chart:{events:{load(){setTimeout(this.reflow.bind(this),0)}},type:style,height:height},title:{text:title},yAxis:{min:min,max:max,lineWidth:0,tickWidth:0,minorTickInterval:minorTickInterval,tickAmount:2,tickPositions:[min,max],labels:{y:26,enabled:showLabels}},credits:false,series:[{data:formattedChartData}],pane:{center:["50%","50%"],size:"90%",startAngle:circumference[0],endAngle:circumference[1],background:{borderWidth:20,innerRadius:"90%",outerRadius:"90%",shape:"arc",className:"gauge-pane"}},colors:colors$1!==void 0&&colors$1.length>0?mapColors(colors$1):highchartsTheme.colors,plotOptions:{series:{animation:!disableAnimation},solidgauge:{borderColor:colors$1!==void 0&&colors$1.length===1?mapColors(colors$1).join():highchartsTheme.colors[0],borderWidth:20,radius:90,innerRadius:"90%",dataLabels:{borderWidth:0,color:colors.text_lt_default,enabled:true,format:`<span class="prefix${dark?" dark":""}">${prefix}</span><span class="fix${dark?" dark":""}">{y:,f}</span><span class="suffix${dark?" dark":""}">${suffix}</span>`,style:{fontFamily:typography.font_family_base,fontWeight:typography.regular,fontSize:typography.heading_2},y:-26}}}};setOptions(merge(staticOptions,customOptions));if(document.querySelector(".prefix")){document.querySelectorAll(".prefix").forEach((prefix2=>{prefix2.setAttribute("y","28")}));document.querySelectorAll(".fix").forEach((fix=>fix.setAttribute("y","38")))}}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(css,globalProps(props)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const LineGraph=({aria:aria={},data:data={},align:align="center",className:className="pb_bar_graph",customOptions:customOptions={},dark:dark=false,gradient:gradient=false,type:type="line",htmlOptions:htmlOptions={},id:id,legend:legend=false,toggleLegendClick:toggleLegendClick=true,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,axisTitle:axisTitle,xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,chartData:chartData,pointStart:pointStart,subTitle:subTitle,title:title,height:height,colors:colors2=[],...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:{min:yAxisMin,max:yAxisMax,title:{text:axisTitle}},xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{pointStart:pointStart,events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};export{BarGraph as B,CircleChart as C,Gauge as G,LineGraph as L};
|