playbook_ui 11.12.1.pre.alpha.charts1 → 11.12.1.pre.alpha.passphrase1
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/index.js +1 -0
- 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_passphrase/_passphrase.jsx +56 -97
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.html.erb +145 -1
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.jsx +127 -3
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.md +11 -2
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.html.erb +136 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.jsx +90 -8
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.md +5 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_confirmation.html.erb +51 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_confirmation.jsx +39 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.html.erb +0 -2
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.jsx +6 -20
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_input_props.html.erb +2 -2
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_input_props.jsx +1 -1
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.html.erb +318 -5
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.jsx +134 -48
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.md +11 -5
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.html.erb +123 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.jsx +96 -20
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.md +6 -2
- data/app/pb_kits/playbook/pb_passphrase/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_passphrase/passphrase.html.erb +1 -1
- data/app/pb_kits/playbook/pb_passphrase/passphrase.rb +5 -9
- data/app/pb_kits/playbook/pb_passphrase/passphrase.test.jsx +0 -47
- 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-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/version.rb +1 -1
- metadata +15 -16
- 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 -216
- 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 -213
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +0 -148
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.md +0 -1
- data/app/pb_kits/playbook/pb_passphrase/passwordStrength.js +0 -55
- data/app/pb_kits/playbook/pb_passphrase/useHaveIBeenPwned.js +0 -52
- data/app/pb_kits/playbook/pb_passphrase/useZxcvbn.js +0 -58
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +0 -111
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a2d4fa765df74ba9a5c6abd8ec9bd670371bb4b752bbdec10225d4d35d66293
|
4
|
+
data.tar.gz: ce21ba1dc523fc7875b39a604a0b63f7c54b5f62cd27297a2209f3cfa1b42dc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dace3a848d70cbc4cc6e854aa8bd0c687c8acc6485f37235daabbd18acab8b6393e8e4e2a4c021deb64811303c60364ac8fb43e00201bdd9f0e3f1c59f205d5c
|
7
|
+
data.tar.gz: 7fb618f8c14835809a4b2d02d0afac8476048a5c2209e846466999263a68021ec0ba069ad40bab7b8d7ff72c21952c37d4bc1a887c5e6e93e11214298ae93e7d
|
@@ -115,6 +115,7 @@ export { default as barGraphSettings } from './pb_bar_graph/barGraphSettings'
|
|
115
115
|
export { default as dashboardValueSettings } from './pb_dashboard_value/dashboardValueSettings'
|
116
116
|
|
117
117
|
// Other JS/Plugins
|
118
|
+
export { default as pbChart } from './plugins/pb_chart.js'
|
118
119
|
export { default as datePickerHelper } from './pb_date_picker/date_picker_helper'
|
119
120
|
export { default as PbPopover } from './pb_popover'
|
120
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
|
@@ -71,26 +71,26 @@ const GaugeComplex = (props) => (
|
|
71
71
|
orientation="column"
|
72
72
|
wrap
|
73
73
|
>
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
<Body
|
75
|
+
color="light"
|
76
|
+
text="% Abandoned"
|
77
|
+
/>
|
78
78
|
<Flex wrap>
|
79
79
|
<FlexItem
|
80
80
|
fixedSize="150px"
|
81
81
|
overflow="hidden"
|
82
82
|
shrink
|
83
|
-
>
|
83
|
+
>
|
84
84
|
<Gauge
|
85
85
|
chartData={data}
|
86
86
|
disableAnimation
|
87
|
-
height="
|
87
|
+
height="100%"
|
88
88
|
id="gauge-complex"
|
89
89
|
suffix="%"
|
90
90
|
{...props}
|
91
91
|
/>
|
92
|
-
|
93
|
-
</Flex>
|
92
|
+
</FlexItem>
|
93
|
+
</Flex>
|
94
94
|
</Flex>
|
95
95
|
</Flex>
|
96
96
|
</Card>
|
@@ -1,2 +1,12 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div, "",
|
2
|
+
id: object.id,
|
3
|
+
data: object.data,
|
4
|
+
class: object.classname) %>
|
5
|
+
<% content_for :pb_js do %>
|
6
|
+
<%= javascript_tag do %>
|
7
|
+
window.addEventListener('DOMContentLoaded', function() {
|
8
|
+
new pbChart('.selector', <%= object.chart_options %>)
|
9
|
+
})
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
2
12
|
|