playbook_ui 11.16.0.pre.alpha.paginationrails1 → 11.16.0.pre.alpha.reactupgrade1
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/_playbook.scss +0 -2
- data/app/pb_kits/playbook/data/menu.yml +0 -1
- data/app/pb_kits/playbook/index.js +2 -2
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +111 -0
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +151 -0
- data/app/pb_kits/playbook/pb_circle_chart/circle_chart.html.erb +21 -9
- data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +47 -7
- data/app/pb_kits/playbook/pb_dashboard/{pbChartsDarkTheme.ts → pbChartsDarkTheme.js} +21 -6
- data/app/pb_kits/playbook/pb_dashboard/{pbChartsLightTheme.ts → pbChartsLightTheme.js} +21 -6
- data/app/pb_kits/playbook/pb_gauge/_gauge.jsx +112 -0
- data/app/pb_kits/playbook/pb_gauge/_gauge.scss +0 -4
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_complex.html.erb +1 -1
- data/app/pb_kits/playbook/pb_gauge/docs/_gauge_complex.jsx +8 -8
- data/app/pb_kits/playbook/pb_gauge/gauge.html.erb +11 -1
- data/app/pb_kits/playbook/pb_gauge/gauge.rb +8 -3
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +113 -0
- data/app/pb_kits/playbook/pb_popover/_popover.jsx +120 -130
- data/app/pb_kits/playbook/pb_popover/docs/_popover_close.jsx +1 -1
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.jsx +79 -0
- data/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_tooltip.jsx +1 -1
- data/app/pb_kits/playbook/playbook-doc.js +0 -2
- data/app/pb_kits/playbook/playbook-rails-react-bindings.js +0 -4
- data/app/pb_kits/playbook/playbook-rails.js +4 -0
- data/app/pb_kits/playbook/plugins/pb_chart.js +322 -0
- data/lib/playbook/kit_base.rb +0 -2
- data/lib/playbook/version.rb +2 -2
- data/lib/playbook.rb +0 -1
- metadata +10 -36
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +0 -145
- data/app/pb_kits/playbook/pb_circle_chart/ChartsTypes.ts +0 -2
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +0 -207
- data/app/pb_kits/playbook/pb_dashboard/pbChartsColorsHelper.ts +0 -16
- data/app/pb_kits/playbook/pb_dashboard/themeTypes.ts +0 -16
- data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +0 -202
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +0 -148
- data/app/pb_kits/playbook/pb_pagination/_pagination.scss +0 -68
- data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +0 -41
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default.html.erb +0 -28
- data/app/pb_kits/playbook/pb_pagination/docs/_pagination_default.jsx +0 -12
- data/app/pb_kits/playbook/pb_pagination/docs/example.yml +0 -9
- data/app/pb_kits/playbook/pb_pagination/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_pagination/pagination.html.erb +0 -7
- data/app/pb_kits/playbook/pb_pagination/pagination.rb +0 -18
- data/app/pb_kits/playbook/pb_pagination/pagination.test.jsx +0 -17
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +0 -111
- data/lib/playbook/pagination_renderer.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d042b0ab3d8b097bd1fcf548916bcf509dbe7d2ba6992997d581dcc37b52f6fd
|
4
|
+
data.tar.gz: 569c342ad86165547fcd18928e2c17c493492f1f32a9dca6644ad60c6ee259f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f767315ad846a1277a8226a025c64c30bf24743657314979117872662eee3c24b9647edd3e7ffb4d4dad6655a748f9832206c08745e62417084e1462863e1a9d
|
7
|
+
data.tar.gz: 3694adfc7dc8c7b49911b8935b308ca67daeb9de57a6b30a45ce806e97c64449cd3d5896a7b10d54c801899cb1bd98863170a269ebe187588ca81aad8052ace2
|
@@ -53,9 +53,9 @@ export { default as LabelPill } from './pb_label_pill/_label_pill'
|
|
53
53
|
export { default as LabelValue } from './pb_label_value/_label_value'
|
54
54
|
export { default as Layout } from './pb_layout/_layout'
|
55
55
|
export { default as Legend } from './pb_legend/_legend'
|
56
|
-
export { default as Lightbox } from './pb_lightbox/_lightbox'
|
57
56
|
export { default as LineGraph } from './pb_line_graph/_line_graph'
|
58
57
|
export { default as List } from './pb_list/_list'
|
58
|
+
export { default as Lightbox } from './pb_lightbox/_lightbox'
|
59
59
|
export { default as ListItem } from './pb_list/_list_item'
|
60
60
|
export { default as LoadingInline } from './pb_loading_inline/_loading_inline'
|
61
61
|
export { default as Message } from './pb_message/_message'
|
@@ -64,7 +64,6 @@ export { default as MultipleUsersStacked } from './pb_multiple_users_stacked/_mu
|
|
64
64
|
export { default as Nav } from './pb_nav/_nav'
|
65
65
|
export { default as NavItem } from './pb_nav/_item'
|
66
66
|
export { default as OnlineStatus } from './pb_online_status/_online_status'
|
67
|
-
export { default as Pagination} from './pb_pagination/_pagination'
|
68
67
|
export { default as Passphrase } from './pb_passphrase/_passphrase'
|
69
68
|
export { default as PbReactPopover } from './pb_popover/_popover'
|
70
69
|
export { default as Person } from './pb_person/_person'
|
@@ -116,6 +115,7 @@ export { default as barGraphSettings } from './pb_bar_graph/barGraphSettings'
|
|
116
115
|
export { default as dashboardValueSettings } from './pb_dashboard_value/dashboardValueSettings'
|
117
116
|
|
118
117
|
// Other JS/Plugins
|
118
|
+
export { default as pbChart } from './plugins/pb_chart.js'
|
119
119
|
export { default as datePickerHelper } from './pb_date_picker/date_picker_helper'
|
120
120
|
export { default as PbPopover } from './pb_popover'
|
121
121
|
export { default as PbTable } from './pb_table'
|
@@ -0,0 +1,111 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React from 'react'
|
4
|
+
import classnames from 'classnames'
|
5
|
+
|
6
|
+
import { globalProps } from '../utilities/globalProps'
|
7
|
+
import pbChart from '../plugins/pb_chart'
|
8
|
+
|
9
|
+
type BarGraphProps = {
|
10
|
+
align?: "left" | "right" | "center",
|
11
|
+
axisTitle: string,
|
12
|
+
dark?: Boolean,
|
13
|
+
xAxisCategories: array,
|
14
|
+
yAxisMin: number,
|
15
|
+
yAxisMax: number,
|
16
|
+
chartData: array<{
|
17
|
+
name: string,
|
18
|
+
data: array<number>,
|
19
|
+
}>,
|
20
|
+
className?: string,
|
21
|
+
id: number,
|
22
|
+
pointStart: number,
|
23
|
+
subTitle?: string,
|
24
|
+
title: string,
|
25
|
+
type?: string,
|
26
|
+
legend?: boolean,
|
27
|
+
toggleLegendClick?: boolean,
|
28
|
+
height?: string,
|
29
|
+
colors: array,
|
30
|
+
layout?: "horizontal" | "vertical" | "proximate",
|
31
|
+
verticalAlign?: "top" | "middle" | "bottom",
|
32
|
+
x?: number,
|
33
|
+
y?: number,
|
34
|
+
}
|
35
|
+
|
36
|
+
export default class BarGraph extends React.Component<BarGraphProps> {
|
37
|
+
static defaultProps = {
|
38
|
+
align: "center",
|
39
|
+
className: 'pb_bar_graph',
|
40
|
+
dark: false,
|
41
|
+
type: 'column',
|
42
|
+
legend: false,
|
43
|
+
toggleLegendClick: true,
|
44
|
+
layout: "horizontal",
|
45
|
+
verticalAlign: "bottom",
|
46
|
+
x: 0,
|
47
|
+
y: 0,
|
48
|
+
}
|
49
|
+
|
50
|
+
componentDidMount() {
|
51
|
+
const {
|
52
|
+
align,
|
53
|
+
axisTitle,
|
54
|
+
dark,
|
55
|
+
xAxisCategories,
|
56
|
+
yAxisMin,
|
57
|
+
yAxisMax,
|
58
|
+
className,
|
59
|
+
chartData,
|
60
|
+
id,
|
61
|
+
pointStart,
|
62
|
+
subTitle,
|
63
|
+
title,
|
64
|
+
type,
|
65
|
+
legend,
|
66
|
+
height,
|
67
|
+
toggleLegendClick,
|
68
|
+
colors = [],
|
69
|
+
layout,
|
70
|
+
verticalAlign,
|
71
|
+
x,
|
72
|
+
y,
|
73
|
+
} = this.props
|
74
|
+
|
75
|
+
new pbChart(`.${className}`, {
|
76
|
+
align,
|
77
|
+
axisTitle: axisTitle,
|
78
|
+
dark,
|
79
|
+
chartData: chartData,
|
80
|
+
colors: colors,
|
81
|
+
id: id,
|
82
|
+
pointStart: pointStart,
|
83
|
+
subtitle: subTitle,
|
84
|
+
type,
|
85
|
+
title: title,
|
86
|
+
xAxisCategories: xAxisCategories,
|
87
|
+
yAxisMin: yAxisMin,
|
88
|
+
yAxisMax: yAxisMax,
|
89
|
+
legend,
|
90
|
+
toggleLegendClick: toggleLegendClick,
|
91
|
+
height: height,
|
92
|
+
layout,
|
93
|
+
verticalAlign,
|
94
|
+
x,
|
95
|
+
y,
|
96
|
+
})
|
97
|
+
}
|
98
|
+
|
99
|
+
props: BarGraphProps
|
100
|
+
|
101
|
+
render() {
|
102
|
+
const { className, id } = this.props
|
103
|
+
|
104
|
+
return (
|
105
|
+
<div
|
106
|
+
className={classnames(globalProps(this.props), className)}
|
107
|
+
id={id}
|
108
|
+
/>
|
109
|
+
)
|
110
|
+
}
|
111
|
+
}
|
@@ -0,0 +1,151 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React, { useEffect, useRef } from 'react'
|
4
|
+
import classnames from 'classnames'
|
5
|
+
import Highcharts from 'highcharts'
|
6
|
+
|
7
|
+
import { globalProps } from '../utilities/globalProps'
|
8
|
+
import { buildAriaProps, buildDataProps } from '../utilities/props'
|
9
|
+
|
10
|
+
import pbChart from '../plugins/pb_chart'
|
11
|
+
type CircleChartProps = {
|
12
|
+
align?: "left" | "right" | "center",
|
13
|
+
aria: Object,
|
14
|
+
chartData?: array,
|
15
|
+
children: Node,
|
16
|
+
className?: string,
|
17
|
+
colors: array,
|
18
|
+
dark?: Boolean,
|
19
|
+
data?: Object,
|
20
|
+
dataLabelHtml: string,
|
21
|
+
dataLabels: boolean,
|
22
|
+
headerFormat: string,
|
23
|
+
height?: string,
|
24
|
+
id?: string,
|
25
|
+
innerSize: "sm" | "md" | "lg" | "none",
|
26
|
+
legend: boolean,
|
27
|
+
maxPointSize: number,
|
28
|
+
minPointSize: number,
|
29
|
+
rounded: boolean,
|
30
|
+
startAngle: number,
|
31
|
+
style: string,
|
32
|
+
title: string,
|
33
|
+
tooltipHtml: string,
|
34
|
+
useHtml: boolean,
|
35
|
+
zMin: number,
|
36
|
+
layout?: "horizontal" | "vertical" | "proximate",
|
37
|
+
verticalAlign?: "top" | "middle" | "bottom",
|
38
|
+
x?: number,
|
39
|
+
y?: number,
|
40
|
+
}
|
41
|
+
|
42
|
+
const CircleChart = (props: CircleChartProps) => {
|
43
|
+
const {
|
44
|
+
align = 'center',
|
45
|
+
aria = {},
|
46
|
+
chartData = [{}],
|
47
|
+
children,
|
48
|
+
className,
|
49
|
+
colors = [],
|
50
|
+
dark = false,
|
51
|
+
data = {},
|
52
|
+
dataLabelHtml = '<div>{point.name}</div>',
|
53
|
+
dataLabels = false,
|
54
|
+
headerFormat = null,
|
55
|
+
height,
|
56
|
+
id,
|
57
|
+
innerSize = 'md',
|
58
|
+
legend = false,
|
59
|
+
maxPointSize = null,
|
60
|
+
minPointSize = null,
|
61
|
+
rounded = false,
|
62
|
+
startAngle = null,
|
63
|
+
style = 'pie',
|
64
|
+
title = '',
|
65
|
+
tooltipHtml = '<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: ' +
|
66
|
+
'<b>{point.y}</b>',
|
67
|
+
useHtml = false,
|
68
|
+
zMin = null,
|
69
|
+
layout = 'horizontal',
|
70
|
+
verticalAlign = 'bottom',
|
71
|
+
x = 0,
|
72
|
+
y = 0,
|
73
|
+
} = props
|
74
|
+
|
75
|
+
const ariaProps = buildAriaProps(aria)
|
76
|
+
const dataProps = buildDataProps(data)
|
77
|
+
const innerSizes = { sm: '35%', md: '50%', lg: '85%', none: '0%' }
|
78
|
+
const innerSizeFormat = (size) => innerSizes[size]
|
79
|
+
const roundedBorderWidth = rounded ? 20 : null
|
80
|
+
const roundedBorderColor = rounded ? null : ''
|
81
|
+
|
82
|
+
// Runs first time component Renders
|
83
|
+
useEffect(() => {
|
84
|
+
const formattedChartData = chartData.map((obj) => {
|
85
|
+
obj.y = obj.value
|
86
|
+
delete obj.value
|
87
|
+
return obj
|
88
|
+
})
|
89
|
+
|
90
|
+
new pbChart('.selector', {
|
91
|
+
align,
|
92
|
+
id,
|
93
|
+
colors,
|
94
|
+
borderColor: roundedBorderColor,
|
95
|
+
borderWidth: roundedBorderWidth,
|
96
|
+
chartData: formattedChartData,
|
97
|
+
dark,
|
98
|
+
title,
|
99
|
+
type: style,
|
100
|
+
showInLegend: legend,
|
101
|
+
dataLabelHtml,
|
102
|
+
dataLabels,
|
103
|
+
headerFormat,
|
104
|
+
height: height,
|
105
|
+
tooltipHtml,
|
106
|
+
useHTML: useHtml,
|
107
|
+
minPointSize,
|
108
|
+
maxPointSize,
|
109
|
+
innerSize: innerSizeFormat(innerSize),
|
110
|
+
zMin,
|
111
|
+
startAngle,
|
112
|
+
layout,
|
113
|
+
verticalAlign,
|
114
|
+
x,
|
115
|
+
y,
|
116
|
+
})
|
117
|
+
}, [])
|
118
|
+
|
119
|
+
const componentDidMount = useRef(false)
|
120
|
+
|
121
|
+
// Doesn't run the first time but runs every subsequent render
|
122
|
+
useEffect(() => {
|
123
|
+
if (componentDidMount.current) {
|
124
|
+
Highcharts.charts.forEach((chart) => {
|
125
|
+
if (chart && chart.renderTo.id === id) {
|
126
|
+
const updatedValueArray = chartData.map((obj) => {
|
127
|
+
return obj.value
|
128
|
+
})
|
129
|
+
chart.series[0].setData(updatedValueArray)
|
130
|
+
}
|
131
|
+
})
|
132
|
+
} else {
|
133
|
+
componentDidMount.current = true
|
134
|
+
}
|
135
|
+
}, [chartData])
|
136
|
+
return (
|
137
|
+
<div id={`wrapper-circle-chart-${id}`}>
|
138
|
+
<div
|
139
|
+
id={id}
|
140
|
+
{...ariaProps}
|
141
|
+
{...dataProps}
|
142
|
+
className={classnames('pb_circle_chart', globalProps(props), className)}
|
143
|
+
/>
|
144
|
+
<If condition={children}>
|
145
|
+
<div className="pb-circle-chart-block">{children}</div>
|
146
|
+
</If>
|
147
|
+
</div>
|
148
|
+
)
|
149
|
+
}
|
150
|
+
|
151
|
+
export default CircleChart
|
@@ -1,10 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
<div id="wrapper-circle-chart-<%= object.id %>">
|
2
|
+
<%= content_tag(:div, "",
|
3
|
+
aria: object.aria,
|
4
|
+
id: object.id,
|
5
|
+
data: object.data,
|
6
|
+
class: object.classname) do %>
|
7
|
+
<% content_for :pb_js do %>
|
8
|
+
<%= javascript_tag do %>
|
9
|
+
window.addEventListener('DOMContentLoaded', function() {
|
10
|
+
new pbChart('.selector', <%= object.chart_options %>)
|
11
|
+
|
12
|
+
});
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<% if content.present? %>
|
18
|
+
<div class="pb-circle-chart-block">
|
19
|
+
<%= content %>
|
7
20
|
</div>
|
8
|
-
<%
|
9
|
-
|
10
|
-
<% end %>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# rubocop:disable Style/HashLikeCase
|
4
|
+
|
3
5
|
module Playbook
|
4
6
|
module PbCircleChart
|
5
7
|
class CircleChart < Playbook::KitBase
|
@@ -11,6 +13,7 @@ module Playbook
|
|
11
13
|
prop :style, type: Playbook::Props::Enum,
|
12
14
|
values: %w[pie],
|
13
15
|
default: "pie"
|
16
|
+
|
14
17
|
prop :data_labels, type: Playbook::Props::Boolean, default: false
|
15
18
|
prop :min_point_size, type: Playbook::Props::Numeric
|
16
19
|
prop :max_point_size, type: Playbook::Props::Numeric
|
@@ -19,8 +22,11 @@ module Playbook
|
|
19
22
|
default: "md"
|
20
23
|
prop :z_min, type: Playbook::Props::Numeric
|
21
24
|
prop :start_angle, type: Playbook::Props::Numeric
|
25
|
+
prop :header_format
|
22
26
|
prop :data_label_html, default: "<div>{point.name}</div>"
|
23
|
-
prop :tooltip_html
|
27
|
+
prop :tooltip_html, default: '<span style="font-weight: bold; color:{point.color};">●</span>
|
28
|
+
{point.name}: ' + '<b>{point.y}
|
29
|
+
</b>'
|
24
30
|
prop :use_html, type: Playbook::Props::Boolean, default: false
|
25
31
|
prop :legend, type: Playbook::Props::Boolean, default: false
|
26
32
|
prop :title, default: ""
|
@@ -37,32 +43,64 @@ module Playbook
|
|
37
43
|
prop :x, type: Playbook::Props::Numeric
|
38
44
|
prop :y, type: Playbook::Props::Numeric
|
39
45
|
|
46
|
+
def chart_type
|
47
|
+
style == "variablepie" ? "variablepie" : "pie"
|
48
|
+
end
|
49
|
+
|
50
|
+
def chart_data_formatted
|
51
|
+
chart_data.map { |hash| hash[:y] = hash.delete :value }
|
52
|
+
chart_data
|
53
|
+
end
|
54
|
+
|
55
|
+
def inner_size_format
|
56
|
+
case inner_size
|
57
|
+
when "lg"
|
58
|
+
"85%"
|
59
|
+
when "sm"
|
60
|
+
"35%"
|
61
|
+
when "none"
|
62
|
+
"0%"
|
63
|
+
when "md"
|
64
|
+
"50%"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def rounded_border_width
|
69
|
+
rounded ? 20 : nil
|
70
|
+
end
|
71
|
+
|
72
|
+
def rounded_border_color
|
73
|
+
rounded == true ? "null" : nil
|
74
|
+
end
|
75
|
+
|
40
76
|
def chart_options
|
41
77
|
{
|
42
78
|
align: align,
|
43
79
|
id: id,
|
44
80
|
colors: colors,
|
45
|
-
|
81
|
+
borderColor: rounded_border_color,
|
82
|
+
borderWidth: rounded_border_width,
|
83
|
+
chartData: chart_data_formatted,
|
46
84
|
dark: dark ? "dark" : "",
|
47
85
|
title: title,
|
48
86
|
height: height,
|
49
|
-
type:
|
50
|
-
|
87
|
+
type: chart_type,
|
88
|
+
showInLegend: legend,
|
51
89
|
dataLabelHtml: data_label_html,
|
52
90
|
dataLabels: data_labels,
|
91
|
+
headerFormat: header_format,
|
53
92
|
tooltipHtml: tooltip_html,
|
54
93
|
useHTML: use_html,
|
55
94
|
minPointSize: min_point_size,
|
56
95
|
maxPointSize: max_point_size,
|
57
|
-
innerSize:
|
96
|
+
innerSize: inner_size_format,
|
58
97
|
zMin: z_min,
|
59
98
|
startAngle: start_angle,
|
60
|
-
rounded: rounded,
|
61
99
|
layout: layout,
|
62
100
|
verticalAlign: vertical_align,
|
63
101
|
x: x,
|
64
102
|
y: y,
|
65
|
-
}
|
103
|
+
}.to_json.html_safe
|
66
104
|
end
|
67
105
|
|
68
106
|
def classname
|
@@ -71,3 +109,5 @@ module Playbook
|
|
71
109
|
end
|
72
110
|
end
|
73
111
|
end
|
112
|
+
|
113
|
+
# rubocop:enable Style/HashLikeCase
|
@@ -1,11 +1,9 @@
|
|
1
1
|
import colors from '../tokens/exports/_colors.scss'
|
2
2
|
import typography from '../tokens/exports/_typography.scss'
|
3
3
|
|
4
|
-
import { ThemeProps } from './themeTypes'
|
5
|
-
|
6
4
|
import Highcharts from 'highcharts'
|
7
5
|
|
8
|
-
const highchartsDarkTheme
|
6
|
+
const highchartsDarkTheme = {
|
9
7
|
lang: {
|
10
8
|
thousandsSep: ',',
|
11
9
|
},
|
@@ -152,6 +150,26 @@ const highchartsDarkTheme: ThemeProps = {
|
|
152
150
|
},
|
153
151
|
threshold: null,
|
154
152
|
},
|
153
|
+
|
154
|
+
// GAUGE STYLES
|
155
|
+
solidgauge: {
|
156
|
+
borderColor: colors.primary,
|
157
|
+
borderWidth: 20,
|
158
|
+
radius: 90,
|
159
|
+
innerRadius: '90%',
|
160
|
+
dataLabels: {
|
161
|
+
borderWidth: 0,
|
162
|
+
color: colors.text_dk_default,
|
163
|
+
enabled: true,
|
164
|
+
style: {
|
165
|
+
fontFamily: typography.font_family_base,
|
166
|
+
fontWeight: typography.regular,
|
167
|
+
fontSize: typography.heading_2,
|
168
|
+
},
|
169
|
+
y: -26,
|
170
|
+
},
|
171
|
+
},
|
172
|
+
|
155
173
|
// PIE STYLES
|
156
174
|
pie: {
|
157
175
|
colors: [
|
@@ -229,9 +247,6 @@ const highchartsDarkTheme: ThemeProps = {
|
|
229
247
|
}
|
230
248
|
},
|
231
249
|
},
|
232
|
-
credits: {
|
233
|
-
enabled: false
|
234
|
-
},
|
235
250
|
}
|
236
251
|
|
237
252
|
export { highchartsDarkTheme }
|
@@ -1,11 +1,9 @@
|
|
1
1
|
import colors from '../tokens/exports/_colors.scss'
|
2
2
|
import typography from '../tokens/exports/_typography.scss'
|
3
3
|
|
4
|
-
import { ThemeProps } from './themeTypes'
|
5
|
-
|
6
4
|
import Highcharts from 'highcharts'
|
7
5
|
|
8
|
-
const highchartsTheme
|
6
|
+
const highchartsTheme = {
|
9
7
|
lang: {
|
10
8
|
thousandsSep: ',',
|
11
9
|
},
|
@@ -152,6 +150,26 @@ const highchartsTheme: ThemeProps = {
|
|
152
150
|
},
|
153
151
|
threshold: null,
|
154
152
|
},
|
153
|
+
|
154
|
+
// GAUGE STYLES
|
155
|
+
solidgauge: {
|
156
|
+
borderColor: colors.primary,
|
157
|
+
borderWidth: 20,
|
158
|
+
radius: 90,
|
159
|
+
innerRadius: '90%',
|
160
|
+
dataLabels: {
|
161
|
+
borderWidth: 0,
|
162
|
+
color: colors.text_lt_default,
|
163
|
+
enabled: true,
|
164
|
+
style: {
|
165
|
+
fontFamily: typography.font_family_base,
|
166
|
+
fontWeight: typography.regular,
|
167
|
+
fontSize: typography.heading_2,
|
168
|
+
},
|
169
|
+
y: -26,
|
170
|
+
},
|
171
|
+
},
|
172
|
+
|
155
173
|
// PIE STYLES
|
156
174
|
pie: {
|
157
175
|
colors: [
|
@@ -229,9 +247,6 @@ const highchartsTheme: ThemeProps = {
|
|
229
247
|
}
|
230
248
|
},
|
231
249
|
},
|
232
|
-
credits: {
|
233
|
-
enabled: false
|
234
|
-
},
|
235
250
|
}
|
236
251
|
|
237
252
|
export { highchartsTheme }
|
@@ -0,0 +1,112 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React, { useEffect, useRef } from 'react'
|
4
|
+
import classnames from 'classnames'
|
5
|
+
import Highcharts from 'highcharts'
|
6
|
+
|
7
|
+
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
8
|
+
import { globalProps } from '../utilities/globalProps'
|
9
|
+
import pbChart from '../plugins/pb_chart'
|
10
|
+
|
11
|
+
type GaugeProps = {
|
12
|
+
aria: Object,
|
13
|
+
className?: string,
|
14
|
+
chartData?: array,
|
15
|
+
dark?: Boolean,
|
16
|
+
data?: Object,
|
17
|
+
disableAnimation: boolean,
|
18
|
+
fullCircle: boolean,
|
19
|
+
height: string,
|
20
|
+
id?: string,
|
21
|
+
max: number,
|
22
|
+
min: number,
|
23
|
+
prefix: string,
|
24
|
+
showLabels: boolean,
|
25
|
+
style: string,
|
26
|
+
suffix: string,
|
27
|
+
title: string,
|
28
|
+
tooltipHtml: string,
|
29
|
+
colors: array,
|
30
|
+
}
|
31
|
+
|
32
|
+
const Gauge = (props: GaugeProps) => {
|
33
|
+
const {
|
34
|
+
aria = {},
|
35
|
+
className,
|
36
|
+
chartData = [{ name: 'Name', value: 0 }],
|
37
|
+
dark = false,
|
38
|
+
data = {},
|
39
|
+
disableAnimation = false,
|
40
|
+
fullCircle = false,
|
41
|
+
height = null,
|
42
|
+
id,
|
43
|
+
max = 100,
|
44
|
+
min = 0,
|
45
|
+
prefix = '',
|
46
|
+
showLabels = false,
|
47
|
+
style = 'solidgauge',
|
48
|
+
suffix = '',
|
49
|
+
title = '',
|
50
|
+
tooltipHtml = '<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: ' + '<b>{point.y}</b>',
|
51
|
+
colors = [],
|
52
|
+
} = props
|
53
|
+
|
54
|
+
const ariaProps = buildAriaProps(aria)
|
55
|
+
const dataProps = buildDataProps(data)
|
56
|
+
|
57
|
+
const css = buildCss({
|
58
|
+
'pb_gauge_kit': true,
|
59
|
+
})
|
60
|
+
// Runs first time component Renders
|
61
|
+
useEffect(() => {
|
62
|
+
const formattedChartData = chartData.map((obj) => {
|
63
|
+
obj.y = obj.value
|
64
|
+
delete obj.value
|
65
|
+
return obj
|
66
|
+
})
|
67
|
+
|
68
|
+
new pbChart('.selector', {
|
69
|
+
id: id,
|
70
|
+
chartData: formattedChartData,
|
71
|
+
circumference: fullCircle ? [0, 360] : [-100, 100],
|
72
|
+
dark,
|
73
|
+
disableAnimation: disableAnimation,
|
74
|
+
height: height,
|
75
|
+
min: min,
|
76
|
+
max: max,
|
77
|
+
prefix: prefix,
|
78
|
+
title: title,
|
79
|
+
suffix: suffix,
|
80
|
+
showLabels: showLabels,
|
81
|
+
style: style,
|
82
|
+
tooltipHtml: tooltipHtml,
|
83
|
+
type: 'gauge',
|
84
|
+
colors: colors,
|
85
|
+
})
|
86
|
+
}, [])
|
87
|
+
|
88
|
+
const componentDidMount = useRef(false)
|
89
|
+
// Doesn't run the first time but runs every subsequent render
|
90
|
+
useEffect(() => {
|
91
|
+
if (componentDidMount.current) {
|
92
|
+
Highcharts.charts.forEach((chart) => {
|
93
|
+
if (chart && chart.renderTo.id === id) {
|
94
|
+
chart.series[0].setData([chartData[0].value])
|
95
|
+
chart.series[0].data[0].name = chartData[0].name
|
96
|
+
}
|
97
|
+
})
|
98
|
+
} else {
|
99
|
+
componentDidMount.current = true
|
100
|
+
}
|
101
|
+
}, [chartData])
|
102
|
+
return (
|
103
|
+
<div
|
104
|
+
{...ariaProps}
|
105
|
+
{...dataProps}
|
106
|
+
className={classnames(css, globalProps(props), className)}
|
107
|
+
id={id}
|
108
|
+
/>
|
109
|
+
)
|
110
|
+
}
|
111
|
+
|
112
|
+
export default Gauge
|