playbook_ui 15.1.0 → 15.2.0.pre.alpha.PLAY236711331
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 +4 -6
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +7 -0
- data/app/pb_kits/playbook/pb_button/_button.scss +6 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_loading.html.erb +7 -3
- data/app/pb_kits/playbook/pb_button/docs/_button_loading.jsx +29 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_managed_disabled.html.erb +31 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_managed_disabled.md +7 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_managed_disabled_helper.html.erb +21 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_managed_disabled_helper.md +7 -0
- data/app/pb_kits/playbook/pb_button/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_button/index.js +99 -0
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +4 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_stacked_alert.html.erb +16 -16
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_stacked_alert.jsx +2 -1
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_status.html.erb +31 -31
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_status.jsx +4 -3
- data/app/pb_kits/playbook/pb_draggable/_draggable.scss +8 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +105 -29
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +12 -1
- data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.tsx +2 -2
- data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.scss +15 -21
- data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.tsx +6 -5
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +2 -0
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.rb +11 -3
- data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.test.js +9 -8
- data/app/pb_kits/playbook/pb_multiple_users_stacked/_multiple_users_stacked.scss +36 -9
- data/app/pb_kits/playbook/pb_pb_bar_graph/_pb_bar_graph.tsx +8 -6
- data/app/pb_kits/playbook/pb_pb_bar_graph/pb_bar_graph.rb +7 -10
- data/app/pb_kits/playbook/pb_pb_bar_graph/pbbargraph.test.jsx +73 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/_pb_circle_chart.tsx +1 -1
- data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.rb +7 -10
- data/app/pb_kits/playbook/pb_pb_circle_chart/pb_circle_chart.test.jsx +47 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/_pb_line_graph.scss +3 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/_pb_line_graph.tsx +61 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_description.md +3 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.html.erb +34 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.jsx +52 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_colors.md +5 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.html.erb +34 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_default.jsx +45 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.html.erb +47 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.jsx +64 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_height.md +3 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend.html.erb +24 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend.jsx +37 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_nonclickable.html.erb +39 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_nonclickable.jsx +45 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.html.erb +86 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.jsx +116 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/_pb_line_graph_legend_position.md +11 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/example.yml +20 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/docs/index.js +6 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/pbLineGraphTheme.ts +125 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.html.erb +1 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.rb +25 -0
- data/app/pb_kits/playbook/pb_pb_line_graph/pb_line_graph.test.jsx +110 -0
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +105 -22
- data/app/pb_kits/playbook/pb_text_input/_text_input.scss +3 -0
- data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +14 -6
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_default.html.erb +8 -4
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_default.jsx +5 -0
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_default.md +1 -0
- data/app/pb_kits/playbook/pb_text_input/text_input.html.erb +3 -1
- data/app/pb_kits/playbook/pb_text_input/text_input.rb +6 -0
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +250 -233
- data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +1 -1
- data/app/pb_kits/playbook/pb_timeline/timeline.test.js +2 -2
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +10 -10
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +39 -1
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +2 -0
- data/app/pb_kits/playbook/utilities/_hover.scss +2 -2
- data/app/pb_kits/playbook/utilities/globalProps.ts +2 -2
- data/dist/chunks/{_line_graph-CW8Ygzyq.js → _line_graph-AKTV-rqw.js} +1 -1
- data/dist/chunks/_typeahead-DCInCM2E.js +6 -0
- data/dist/chunks/{_weekday_stacked-3-FtXg76.js → _weekday_stacked-ByJl1kOQ.js} +3 -3
- data/dist/chunks/{lib-izYrkvOQ.js → lib-QZuu1ltS.js} +2 -2
- data/dist/chunks/{pb_form_validation-Cah5Z5J3.js → pb_form_validation-CleM960_.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +7 -1
- data/dist/playbook-doc.js +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/hover.rb +5 -1
- data/lib/playbook/version.rb +2 -2
- metadata +37 -7
- data/dist/chunks/_typeahead-DUIMqJiu.js +0 -6
@@ -4,24 +4,21 @@ module Playbook
|
|
4
4
|
module PbPbBarGraph
|
5
5
|
class PbBarGraph < ::Playbook::KitBase
|
6
6
|
prop :options, default: {}
|
7
|
-
prop :container_props, default: {}
|
8
7
|
|
9
8
|
def react_props
|
10
9
|
{
|
10
|
+
className: classname,
|
11
|
+
data: data,
|
11
12
|
options: options,
|
12
|
-
|
13
|
+
id: id,
|
13
14
|
}
|
14
15
|
end
|
15
16
|
|
16
|
-
def container_props_hash
|
17
|
-
container_props.merge({
|
18
|
-
id: id,
|
19
|
-
className: classname,
|
20
|
-
}).compact
|
21
|
-
end
|
22
|
-
|
23
17
|
def classname
|
24
|
-
|
18
|
+
# Highcharts react needs classname attached to the container div,
|
19
|
+
# we pass an empty string here to avoid conflicts, classname is built in the TSX
|
20
|
+
# We still need generate_classnames to retain ability to pass in custom classnames or global props
|
21
|
+
generate_classname("")
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end
|
@@ -15,6 +15,41 @@ afterEach(() => {
|
|
15
15
|
console.warn.mockRestore();
|
16
16
|
});
|
17
17
|
|
18
|
+
const chartData = [{
|
19
|
+
name: 'Installation',
|
20
|
+
data: [1475, 200, 3000, 654, 656],
|
21
|
+
}, {
|
22
|
+
name: 'Manufacturing',
|
23
|
+
data: [4434, 524, 2320, 440, 500],
|
24
|
+
}, {
|
25
|
+
name: 'Sales & Distribution',
|
26
|
+
data: [3387, 743, 1344, 434, 440],
|
27
|
+
}, {
|
28
|
+
name: 'Project Development',
|
29
|
+
data: [3227, 878, 999, 780, 1000],
|
30
|
+
}, {
|
31
|
+
name: 'Other',
|
32
|
+
data: [1111, 677, 3245, 500, 200],
|
33
|
+
}]
|
34
|
+
|
35
|
+
const chartOptions = {
|
36
|
+
series: chartData,
|
37
|
+
title: {
|
38
|
+
text: 'Solar Employment Growth by Sector, 2010-2016',
|
39
|
+
},
|
40
|
+
subtitle: {
|
41
|
+
text: 'Source: thesolarfoundation.com',
|
42
|
+
},
|
43
|
+
xAxis: {
|
44
|
+
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
|
45
|
+
},
|
46
|
+
yAxis: {
|
47
|
+
title: {
|
48
|
+
text: 'Number of Employees',
|
49
|
+
},
|
50
|
+
},
|
51
|
+
}
|
52
|
+
|
18
53
|
const testId = 'bargraph1';
|
19
54
|
|
20
55
|
test('bargraph uses exact classname', () => {
|
@@ -23,9 +58,46 @@ test('bargraph uses exact classname', () => {
|
|
23
58
|
className='super_important_class'
|
24
59
|
data={{ testid: testId }}
|
25
60
|
id='bar-default'
|
61
|
+
options={chartOptions}
|
26
62
|
/>
|
27
63
|
);
|
28
64
|
|
29
65
|
const kit = screen.getByTestId(testId);
|
30
66
|
expect(kit).toHaveClass('super_important_class');
|
31
|
-
});
|
67
|
+
});
|
68
|
+
|
69
|
+
test('Kit to apply base classname', () => {
|
70
|
+
render(
|
71
|
+
<PbBarGraph
|
72
|
+
data={{testid: testId}}
|
73
|
+
options={chartOptions}
|
74
|
+
/>
|
75
|
+
)
|
76
|
+
|
77
|
+
expect(screen.getByTestId(testId)).toHaveClass('pb_pb_bar_graph')
|
78
|
+
})
|
79
|
+
|
80
|
+
|
81
|
+
test('Kit to apply global props', () => {
|
82
|
+
render(
|
83
|
+
<PbBarGraph
|
84
|
+
data={{testid: testId}}
|
85
|
+
margin="lg"
|
86
|
+
options={chartOptions}
|
87
|
+
/>
|
88
|
+
)
|
89
|
+
|
90
|
+
expect(screen.getByTestId(testId)).toHaveClass('m_lg')
|
91
|
+
})
|
92
|
+
|
93
|
+
test('kit to apply id', () => {
|
94
|
+
render(
|
95
|
+
<PbBarGraph
|
96
|
+
data={{testid: testId}}
|
97
|
+
id='bar-graph-id'
|
98
|
+
options={chartOptions}
|
99
|
+
/>
|
100
|
+
)
|
101
|
+
|
102
|
+
expect(screen.getByTestId(testId)).toHaveAttribute('id', 'bar-graph-id')
|
103
|
+
})
|
@@ -4,24 +4,21 @@ module Playbook
|
|
4
4
|
module PbPbCircleChart
|
5
5
|
class PbCircleChart < ::Playbook::KitBase
|
6
6
|
prop :options, default: {}
|
7
|
-
prop :container_props, default: {}
|
8
7
|
|
9
8
|
def react_props
|
10
9
|
{
|
10
|
+
className: classname,
|
11
|
+
data: data,
|
11
12
|
options: options,
|
12
|
-
|
13
|
+
id: id,
|
13
14
|
}
|
14
15
|
end
|
15
16
|
|
16
|
-
def container_props_hash
|
17
|
-
container_props.merge({
|
18
|
-
id: id,
|
19
|
-
className: classname,
|
20
|
-
}).compact
|
21
|
-
end
|
22
|
-
|
23
17
|
def classname
|
24
|
-
|
18
|
+
# Highcharts react needs classname attached to the container div,
|
19
|
+
# we pass an empty string here to avoid conflicts, classname is built in the TSX
|
20
|
+
# We still need generate_classnames to retain ability to pass in custom classnames or global props
|
21
|
+
generate_classname("")
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end
|
@@ -49,3 +49,50 @@ test('Kit to exist', () => {
|
|
49
49
|
expect(screen.getByTestId(testId)).toBeInTheDocument()
|
50
50
|
})
|
51
51
|
|
52
|
+
test('Kit to apply base classname', () => {
|
53
|
+
render(
|
54
|
+
<PbCircleChart
|
55
|
+
data={{testid: testId}}
|
56
|
+
options={chartOptions}
|
57
|
+
/>
|
58
|
+
)
|
59
|
+
|
60
|
+
expect(screen.getByTestId(testId)).toHaveClass('pb_pb_circle_chart')
|
61
|
+
})
|
62
|
+
|
63
|
+
test('Kit to have custom class', () => {
|
64
|
+
render(
|
65
|
+
<PbCircleChart
|
66
|
+
className='custom-class'
|
67
|
+
data={{testid: testId}}
|
68
|
+
options={chartOptions}
|
69
|
+
/>
|
70
|
+
)
|
71
|
+
|
72
|
+
expect(screen.getByTestId(testId)).toHaveClass('custom-class')
|
73
|
+
})
|
74
|
+
|
75
|
+
test('Kit to apply global props', () => {
|
76
|
+
render(
|
77
|
+
<PbCircleChart
|
78
|
+
data={{testid: testId}}
|
79
|
+
margin="lg"
|
80
|
+
options={chartOptions}
|
81
|
+
/>
|
82
|
+
)
|
83
|
+
|
84
|
+
expect(screen.getByTestId(testId)).toHaveClass('m_lg')
|
85
|
+
})
|
86
|
+
|
87
|
+
test('kit to apply id', () => {
|
88
|
+
render(
|
89
|
+
<PbCircleChart
|
90
|
+
data={{testid: testId}}
|
91
|
+
id='circle-chart-id'
|
92
|
+
options={chartOptions}
|
93
|
+
/>
|
94
|
+
)
|
95
|
+
|
96
|
+
expect(screen.getByTestId(testId)).toHaveAttribute('id', 'circle-chart-id')
|
97
|
+
})
|
98
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
import React, { useMemo } from 'react'
|
3
|
+
import classnames from 'classnames'
|
4
|
+
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
5
|
+
import Highcharts from "highcharts"
|
6
|
+
import HighchartsReact from "highcharts-react-official"
|
7
|
+
import pbLineGraphTheme from './pbLineGraphTheme'
|
8
|
+
import { globalProps } from '../utilities/globalProps'
|
9
|
+
|
10
|
+
|
11
|
+
type PbLineGraphProps = {
|
12
|
+
aria?: { [key: string]: string },
|
13
|
+
className?: string,
|
14
|
+
data?: { [key: string]: string },
|
15
|
+
id?: string,
|
16
|
+
htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
|
17
|
+
options: Record<string, unknown>
|
18
|
+
}
|
19
|
+
|
20
|
+
const PbLineGraph = (props: PbLineGraphProps) => {
|
21
|
+
const {
|
22
|
+
aria = {},
|
23
|
+
className,
|
24
|
+
data = {},
|
25
|
+
id,
|
26
|
+
htmlOptions = {},
|
27
|
+
options
|
28
|
+
} = props
|
29
|
+
|
30
|
+
const ariaProps = buildAriaProps(aria)
|
31
|
+
const dataProps = buildDataProps(data)
|
32
|
+
const htmlProps = buildHtmlProps(htmlOptions);
|
33
|
+
const classes = classnames(buildCss('pb_pb_line_graph'), globalProps(props), className)
|
34
|
+
|
35
|
+
const mergedOptions = useMemo(() => {
|
36
|
+
if (!options || typeof options !== "object") {
|
37
|
+
// eslint-disable-next-line no-console
|
38
|
+
console.error("❌ Invalid options passed to <PbLineGraph />", options)
|
39
|
+
return {}
|
40
|
+
}
|
41
|
+
|
42
|
+
return Highcharts.merge({}, pbLineGraphTheme, options)
|
43
|
+
}, [options])
|
44
|
+
return (
|
45
|
+
<div>
|
46
|
+
<HighchartsReact
|
47
|
+
containerProps={{
|
48
|
+
className: classnames(classes),
|
49
|
+
id: id,
|
50
|
+
...ariaProps,
|
51
|
+
...dataProps,
|
52
|
+
...htmlProps
|
53
|
+
}}
|
54
|
+
highcharts={Highcharts}
|
55
|
+
options={mergedOptions}
|
56
|
+
/>
|
57
|
+
</div>
|
58
|
+
)
|
59
|
+
}
|
60
|
+
|
61
|
+
export default PbLineGraph
|
@@ -0,0 +1,3 @@
|
|
1
|
+
This kit is a wrapper around the Highcharts library. It applies styling and default settings but does NOT ship Highcharts. In order to use this kit, 'highcharts' and 'highcharts-react-official' must be installed in your repo. Once done, any prop or functionality provided by Highcharts can be used with this kit without requiring specifc props from Playbook. The doc examples below showcase a few common usecases but are not a comprehensive list of all the functionalities possible.
|
2
|
+
|
3
|
+
See the [highcharts API docs](https://api.highcharts.com/highcharts/) for a comprehensive look at what is possible.
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<% data = [{
|
2
|
+
name: 'Installation',
|
3
|
+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
|
4
|
+
}, {
|
5
|
+
name: 'Manufacturing',
|
6
|
+
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434],
|
7
|
+
}, {
|
8
|
+
name: 'Sales & Distribution',
|
9
|
+
data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387],
|
10
|
+
}, {
|
11
|
+
name: 'Project Development',
|
12
|
+
data: [nil, nil, 7988, 12169, 15112, 22452, 34400, 34227],
|
13
|
+
}, {
|
14
|
+
name: 'Other',
|
15
|
+
data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111],
|
16
|
+
}] %>
|
17
|
+
|
18
|
+
<% categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] %>
|
19
|
+
|
20
|
+
<% chart_options = {
|
21
|
+
series: data,
|
22
|
+
colors: ['#1CA05C', '#FD804C', '#144075', '#00C4D7', '#DA0014'],
|
23
|
+
title: { text: "Line Graph with Custom Data Colors" },
|
24
|
+
xAxis: {
|
25
|
+
categories: categories,
|
26
|
+
},
|
27
|
+
yAxis: {
|
28
|
+
title: {
|
29
|
+
text: "Number of Employees",
|
30
|
+
},
|
31
|
+
},
|
32
|
+
} %>
|
33
|
+
|
34
|
+
<%= pb_rails("pb_line_graph", props: {options: chart_options}) %>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import PbLineGraph from '../../pb_pb_line_graph/_pb_line_graph'
|
3
|
+
import { colors } from 'playbook-ui'
|
4
|
+
|
5
|
+
const data = [{
|
6
|
+
name: 'Installation',
|
7
|
+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
|
8
|
+
}, {
|
9
|
+
name: 'Manufacturing',
|
10
|
+
data: [24916, 28064, 29742, 40851, 50590, 65282, 70121, 85434],
|
11
|
+
}, {
|
12
|
+
name: 'Sales & Distribution',
|
13
|
+
data: [11744, 17722, 16005, 19771, 25185, 28377, 36147, 43387],
|
14
|
+
}, {
|
15
|
+
name: 'Project Development',
|
16
|
+
data: [5332, 6344, 7988, 12169, 15112, 14452, 22400, 30227],
|
17
|
+
}, {
|
18
|
+
name: 'Other',
|
19
|
+
data: [null, null, null, 3112, 4989, 5816, 15274, 18111],
|
20
|
+
}]
|
21
|
+
|
22
|
+
const categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
23
|
+
|
24
|
+
const chartOptions = {
|
25
|
+
title: {
|
26
|
+
text: 'Line Graph with Custom Data Colors',
|
27
|
+
},
|
28
|
+
xAxis: {
|
29
|
+
categories: categories,
|
30
|
+
},
|
31
|
+
yAxis: {
|
32
|
+
min: 0,
|
33
|
+
title: {
|
34
|
+
text: 'Number of Employees',
|
35
|
+
},
|
36
|
+
},
|
37
|
+
series: data,
|
38
|
+
colors: [colors.data_4, colors.data_5, "#144075", colors.data_7, colors.data_8]
|
39
|
+
}
|
40
|
+
|
41
|
+
const PbLineGraphColors = (props) => {
|
42
|
+
return (
|
43
|
+
<div>
|
44
|
+
<PbLineGraph
|
45
|
+
options={chartOptions}
|
46
|
+
{...props}
|
47
|
+
/>
|
48
|
+
</div>
|
49
|
+
)
|
50
|
+
}
|
51
|
+
|
52
|
+
export default PbLineGraphColors
|
@@ -0,0 +1,5 @@
|
|
1
|
+
Custom data colors allow for color customization to match the needs of business requirements.
|
2
|
+
|
3
|
+
For React, import 'colors' from Playbook, then set custom colors in the colors array using the desired color variables. Hex colors are also available.
|
4
|
+
|
5
|
+
For Rails, HEX values are required.
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<% data = [{
|
2
|
+
name: 'Installation',
|
3
|
+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
|
4
|
+
}, {
|
5
|
+
name: 'Manufacturing',
|
6
|
+
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434],
|
7
|
+
}, {
|
8
|
+
name: 'Sales & Distribution',
|
9
|
+
data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387],
|
10
|
+
}, {
|
11
|
+
name: 'Project Development',
|
12
|
+
data: [nil, nil, 7988, 12169, 15112, 22452, 34400, 34227],
|
13
|
+
}, {
|
14
|
+
name: 'Other',
|
15
|
+
data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111],
|
16
|
+
}] %>
|
17
|
+
|
18
|
+
<% categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] %>
|
19
|
+
|
20
|
+
<% chart_options = {
|
21
|
+
series: data,
|
22
|
+
title: { text: "Solar Employment Growth by Sector, 2010-2016" },
|
23
|
+
subtitle: { text: "Source: thesolarfoundation.com" },
|
24
|
+
xAxis: {
|
25
|
+
categories: categories,
|
26
|
+
},
|
27
|
+
yAxis: {
|
28
|
+
title: {
|
29
|
+
text: "Number of Employees",
|
30
|
+
},
|
31
|
+
},
|
32
|
+
} %>
|
33
|
+
|
34
|
+
<%= pb_rails("pb_line_graph", props: {options: chart_options}) %>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import PbLineGraph from '../../pb_pb_line_graph/_pb_line_graph'
|
3
|
+
|
4
|
+
const data = [{
|
5
|
+
name: 'Installation',
|
6
|
+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
|
7
|
+
}, {
|
8
|
+
name: 'Manufacturing',
|
9
|
+
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434],
|
10
|
+
}, {
|
11
|
+
name: 'Sales & Distribution',
|
12
|
+
data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387],
|
13
|
+
}, {
|
14
|
+
name: 'Project Development',
|
15
|
+
data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227],
|
16
|
+
}, {
|
17
|
+
name: 'Other',
|
18
|
+
data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111],
|
19
|
+
}]
|
20
|
+
|
21
|
+
const categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
22
|
+
|
23
|
+
const chartOptions = {
|
24
|
+
series: data,
|
25
|
+
title: { text: "Solar Employment Growth by Sector, 2010-2016" },
|
26
|
+
subtitle: { text: "Source: thesolarfoundation.com" },
|
27
|
+
xAxis: {
|
28
|
+
categories: categories,
|
29
|
+
},
|
30
|
+
yAxis: {
|
31
|
+
title: {
|
32
|
+
text: "Number of Employees",
|
33
|
+
},
|
34
|
+
},
|
35
|
+
}
|
36
|
+
const PbLineGraphDefault = (props) => (
|
37
|
+
<div>
|
38
|
+
<PbLineGraph
|
39
|
+
options={chartOptions}
|
40
|
+
{...props}
|
41
|
+
/>
|
42
|
+
</div>
|
43
|
+
)
|
44
|
+
|
45
|
+
export default PbLineGraphDefault
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<% data = [{
|
2
|
+
name: 'Number of Installations',
|
3
|
+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
|
4
|
+
}] %>
|
5
|
+
|
6
|
+
<% categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] %>
|
7
|
+
|
8
|
+
<% chart_options_first = {
|
9
|
+
title: {
|
10
|
+
text: 'Fixed Height (300px)',
|
11
|
+
},
|
12
|
+
chart: {
|
13
|
+
height: '300px'
|
14
|
+
},
|
15
|
+
xAxis: {
|
16
|
+
categories: categories,
|
17
|
+
},
|
18
|
+
yAxis: {
|
19
|
+
min: 0,
|
20
|
+
title: {
|
21
|
+
text: 'Number of Employees',
|
22
|
+
},
|
23
|
+
},
|
24
|
+
series: data
|
25
|
+
} %>
|
26
|
+
|
27
|
+
<% chart_options_second = {
|
28
|
+
title: {
|
29
|
+
text: 'Percentage Height (50%)',
|
30
|
+
},
|
31
|
+
chart: {
|
32
|
+
height: '50%'
|
33
|
+
},
|
34
|
+
xAxis: {
|
35
|
+
categories: categories,
|
36
|
+
},
|
37
|
+
yAxis: {
|
38
|
+
min: 0,
|
39
|
+
title: {
|
40
|
+
text: 'Number of Employees',
|
41
|
+
},
|
42
|
+
},
|
43
|
+
series: data
|
44
|
+
} %>
|
45
|
+
|
46
|
+
<%= pb_rails("pb_line_graph", props: {options: chart_options_first}) %>
|
47
|
+
<%= pb_rails("pb_line_graph", props: {options: chart_options_second}) %>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import PbLineGraph from '../../pb_pb_line_graph/_pb_line_graph'
|
3
|
+
|
4
|
+
const data = [{
|
5
|
+
name: 'Number of Installations',
|
6
|
+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
|
7
|
+
}]
|
8
|
+
|
9
|
+
const categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
10
|
+
|
11
|
+
const chartOptionsFirst = {
|
12
|
+
title: {
|
13
|
+
text: 'Fixed Height (300px)',
|
14
|
+
},
|
15
|
+
chart: {
|
16
|
+
height: '300px'
|
17
|
+
},
|
18
|
+
xAxis: {
|
19
|
+
categories: categories,
|
20
|
+
},
|
21
|
+
yAxis: {
|
22
|
+
min: 0,
|
23
|
+
title: {
|
24
|
+
text: 'Number of Employees',
|
25
|
+
},
|
26
|
+
},
|
27
|
+
series: data
|
28
|
+
}
|
29
|
+
|
30
|
+
const chartOptionsSecond = {
|
31
|
+
title: {
|
32
|
+
text: 'Percentage Height (50%)',
|
33
|
+
},
|
34
|
+
chart: {
|
35
|
+
height: '50%'
|
36
|
+
},
|
37
|
+
xAxis: {
|
38
|
+
categories: categories,
|
39
|
+
},
|
40
|
+
yAxis: {
|
41
|
+
min: 0,
|
42
|
+
title: {
|
43
|
+
text: 'Number of Employees',
|
44
|
+
},
|
45
|
+
},
|
46
|
+
series: data
|
47
|
+
}
|
48
|
+
|
49
|
+
const PbLineGraphHeight = (props) => {
|
50
|
+
return (
|
51
|
+
<div>
|
52
|
+
<PbLineGraph
|
53
|
+
options={chartOptionsFirst}
|
54
|
+
{...props}
|
55
|
+
/>
|
56
|
+
<PbLineGraph
|
57
|
+
options={chartOptionsSecond}
|
58
|
+
{...props}
|
59
|
+
/>
|
60
|
+
</div>
|
61
|
+
)
|
62
|
+
}
|
63
|
+
|
64
|
+
export default PbLineGraphHeight
|
@@ -0,0 +1,3 @@
|
|
1
|
+
By default, Highcharts have a height of 400px, but this can be customized. You can override the default by specifying either a percentage or a fixed pixel value.
|
2
|
+
|
3
|
+
Using a percentage maintains a consistent aspect ratio across different responsive sizes. For example, setting the height to 50% makes the chart’s height half of its width.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<% data = [{
|
2
|
+
name: 'Number of Installations',
|
3
|
+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175], }] %>
|
4
|
+
|
5
|
+
<% categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug'] %>
|
6
|
+
|
7
|
+
<% chart_options = {
|
8
|
+
series: data,
|
9
|
+
title: { text: "Line Graph with Legend" },
|
10
|
+
xAxis: {
|
11
|
+
categories: categories,
|
12
|
+
},
|
13
|
+
yAxis: {
|
14
|
+
min: 0,
|
15
|
+
title: {
|
16
|
+
text: "Number of Employees",
|
17
|
+
},
|
18
|
+
},
|
19
|
+
legend: {
|
20
|
+
enabled: true,
|
21
|
+
},
|
22
|
+
} %>
|
23
|
+
|
24
|
+
<%= pb_rails("pb_line_graph", props: {options: chart_options}) %>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import PbLineGraph from '../../pb_pb_line_graph/_pb_line_graph'
|
3
|
+
|
4
|
+
const data = [{
|
5
|
+
name: 'Number of Installations',
|
6
|
+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
|
7
|
+
}]
|
8
|
+
|
9
|
+
const categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug']
|
10
|
+
|
11
|
+
const chartOptions = {
|
12
|
+
series: data,
|
13
|
+
title: { text: "Line Graph with Legend" },
|
14
|
+
xAxis: {
|
15
|
+
categories: categories,
|
16
|
+
},
|
17
|
+
yAxis: {
|
18
|
+
min: 0,
|
19
|
+
title: {
|
20
|
+
text: "Number of Employees",
|
21
|
+
},
|
22
|
+
},
|
23
|
+
legend: {
|
24
|
+
enabled: true,
|
25
|
+
},
|
26
|
+
}
|
27
|
+
|
28
|
+
const PbLineGraphLegend = (props) => (
|
29
|
+
<div>
|
30
|
+
<PbLineGraph
|
31
|
+
options={chartOptions}
|
32
|
+
{...props}
|
33
|
+
/>
|
34
|
+
</div>
|
35
|
+
)
|
36
|
+
|
37
|
+
export default PbLineGraphLegend
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<% data = [{
|
2
|
+
name: 'Number of Installations',
|
3
|
+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
|
4
|
+
}] %>
|
5
|
+
|
6
|
+
<% categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug'] %>
|
7
|
+
|
8
|
+
<% chart_options = {
|
9
|
+
series: data,
|
10
|
+
title: { text: "Line Graph with Legend Non Clickable" },
|
11
|
+
xAxis: {
|
12
|
+
categories: categories,
|
13
|
+
},
|
14
|
+
yAxis: {
|
15
|
+
title: {
|
16
|
+
text: 'Number of Employees',
|
17
|
+
},
|
18
|
+
},
|
19
|
+
legend: {
|
20
|
+
enabled: true
|
21
|
+
},
|
22
|
+
} %>
|
23
|
+
|
24
|
+
<%= pb_rails("pb_line_graph", props: {options: chart_options, id: "installations-chart"}) %>
|
25
|
+
|
26
|
+
<script>
|
27
|
+
// Prevent legend item click events from toggling series visibility
|
28
|
+
document.addEventListener('click', function (e) {
|
29
|
+
var container = document.getElementById('installations-chart');
|
30
|
+
if (!container) return;
|
31
|
+
|
32
|
+
var legend = container.querySelector('.highcharts-legend');
|
33
|
+
if (legend && legend.contains(e.target)) {
|
34
|
+
e.stopImmediatePropagation();
|
35
|
+
e.preventDefault();
|
36
|
+
}
|
37
|
+
}, true);
|
38
|
+
|
39
|
+
</script>
|