playbook_ui_docs 14.23.0.pre.alpha.PLAY2243customindeterminatemaincheckboxlabels9046 → 14.23.0.pre.alpha.advancedtablefix9082

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling.html.erb +46 -0
  3. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_row_styling_rails.md +7 -0
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header.md +1 -1
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header.jsx +107 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_multi_header.md +1 -0
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.html.erb +51 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_with_custom_header_rails.md +1 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +1 -0
  11. data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.md +1 -1
  12. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +1 -1
  13. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate_rails.md +1 -2
  14. data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.md +1 -1
  15. data/app/pb_kits/playbook/pb_line_graph/docs/_description.md +1 -3
  16. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_colors.jsx +36 -17
  17. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_colors_react.md +3 -0
  18. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_default.jsx +31 -16
  19. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_height.jsx +63 -31
  20. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_height.md +3 -0
  21. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend.jsx +35 -16
  22. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_nonclickable.jsx +41 -16
  23. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.jsx +107 -62
  24. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.md +4 -7
  25. data/app/pb_kits/playbook/pb_line_graph/docs/example.yml +0 -1
  26. data/app/pb_kits/playbook/pb_line_graph/docs/index.js +0 -1
  27. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_strict_mode.html.erb +10 -0
  28. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_strict_mode.jsx +26 -0
  29. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_strict_mode.md +3 -0
  30. data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +2 -0
  31. data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +1 -0
  32. data/app/pb_kits/playbook/pb_table/docs/_table_with_selectable_rows.html.erb +0 -1
  33. data/dist/playbook-doc.js +1 -1
  34. metadata +14 -5
  35. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_pb_styles.jsx +0 -52
  36. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_pb_styles.md +0 -1
  37. /data/app/pb_kits/playbook/pb_advanced_table/docs/{_advanced_table_row_styling.md → _advanced_table_row_styling_react.md} +0 -0
  38. /data/app/pb_kits/playbook/pb_line_graph/docs/{_line_graph_colors.md → _line_graph_colors_rails.md} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6aa9a9f4c66a252c47c0366fa4b9780e1766b5e74f7f76299e18126da982cf3
4
- data.tar.gz: 3a87005bb49c7c0f2b780f175b9552ef28333e467283cc6823c7ba4c505ba5d8
3
+ metadata.gz: face0b80f1d5d9e0fb87ccc7cebcc7ef475bcc9d8145a351996b12411ec38617
4
+ data.tar.gz: 9fbf92d363ce40a13a78681df95530ad0272a61575375cc9fdb7e883cd8ebd2b
5
5
  SHA512:
6
- metadata.gz: 3647332acd0b50048838885b07e3062d2d4b94705c42b2c451d0eeebc6d9d50038e2fbcafeed2b36ae4b13310b4a62da6c1106488299837ab3f89aa9c96c37d2
7
- data.tar.gz: d8d3bb26410bb016ac9890abe3c044046db362cc56c5e5a40d4a1825860d9e770867c56fadb3e221301eb4f92b2344c5fea6936c17fd5f1ff32e0a67fdc33555
6
+ metadata.gz: 3ba7b40439c66ea7b7fa22eb6ef5bd3e09cd60cef1fda49c4f12dc526b6105ebeb7c7e35a1df0019e39ec9db2b038cd917688e7bd139f9eda6ef163cbb801c8c
7
+ data.tar.gz: c73cf9c7237f5c8b4500e63cc26ba019d75b4cbad1978b460cb7152495f797e3976687ff50ec048079365c9b5da294007def7a87dfb9240102f59b2d8c021389
@@ -0,0 +1,46 @@
1
+ <% column_definitions = [
2
+ {
3
+ accessor: "year",
4
+ label: "Year",
5
+ cellAccessors: ["quarter", "month", "day"],
6
+ },
7
+ {
8
+ accessor: "newEnrollments",
9
+ label: "New Enrollments",
10
+ },
11
+ {
12
+ accessor: "scheduledMeetings",
13
+ label: "Scheduled Meetings",
14
+ },
15
+ {
16
+ accessor: "attendanceRate",
17
+ label: "Attendance Rate",
18
+ },
19
+ {
20
+ accessor: "completedClasses",
21
+ label: "Completed Classes",
22
+ },
23
+ {
24
+ accessor: "classCompletionRate",
25
+ label: "Class Completion Rate",
26
+ },
27
+ {
28
+ accessor: "graduatedStudents",
29
+ label: "Graduated Students",
30
+ }
31
+ ] %>
32
+
33
+ <% row_styling = [
34
+ {
35
+ row_id: "1",
36
+ background_color: "#F9BB00",
37
+ },
38
+ {
39
+ row_id: "8",
40
+ background_color: "#0056CF",
41
+ font_color: "white",
42
+ expand_button_color: "white",
43
+ },
44
+ ] %>
45
+
46
+ <%= pb_rails("advanced_table", props: { id: "row-styling", table_data: @table_data_with_id, column_definitions: column_definitions, row_styling: row_styling }) %>
@@ -0,0 +1,7 @@
1
+ The `row_styling` prop can be used in conjunction with row ids to control certain styling options on individual rows. Currently, `row_styling` gives you 3 optional controls:
2
+
3
+ - `background_color` : use this to control the background color of the row
4
+ - `font_color`: use this to control font color for each row if needed, for example if using a darker background color.
5
+ - `expand_button_color`: use this to control the color of the expand icon if needed, for example if using a darker background color.
6
+
7
+ **NOTE:** Each object within the `table_data` Array must contain a unique id in order to attach an id to all Rows for this to function.
@@ -1 +1 @@
1
- The optional `header` key/value pair can be used within `columnDefinitions` to render a custom header. This example shows an Icon and Tooltip being used but other kits can be used as well.
1
+ The optional `header` key/value pair can be used within `columnDefinitions` to render a custom header. This example shows an Icon and Tooltip being used but other kits can be used as well.
@@ -0,0 +1,107 @@
1
+ import React from "react"
2
+ import AdvancedTable from '../../pb_advanced_table/_advanced_table'
3
+ import Icon from "../../pb_icon/_icon"
4
+ import Flex from "../../pb_flex/_flex"
5
+ import Caption from "../../pb_caption/_caption"
6
+ import Tooltip from "../../pb_tooltip/_tooltip"
7
+ import MOCK_DATA from "./advanced_table_mock_data.json"
8
+
9
+ const AdvancedTableWithCustomHeaderMultiHeader = (props) => {
10
+
11
+ const columnDefinitions = [
12
+ {
13
+ accessor: "year",
14
+ label: "Year",
15
+ id: "year",
16
+ cellAccessors: ["quarter", "month", "day"],
17
+ },
18
+ {
19
+ label: "Enrollment Data",
20
+ id: "enrollmentData",
21
+ header: () => (
22
+ <Flex alignItems="center"
23
+ justifyContent="center"
24
+ >
25
+ <Caption marginRight="xs">Enrollments Data</Caption>
26
+ <Tooltip placement="top"
27
+ text="Whoa. I'm a Tooltip"
28
+ zIndex={10}
29
+ >
30
+ <Icon cursor="pointer"
31
+ icon="info"
32
+ size="xs"
33
+ />
34
+ </Tooltip>
35
+ </Flex>
36
+ ),
37
+ columns: [
38
+ {
39
+ label: "Enrollment Stats",
40
+ id: "enrollmentStats",
41
+ columns: [
42
+ {
43
+ accessor: "newEnrollments",
44
+ id: "newEnrollments",
45
+ label: "New Enrollments",
46
+ },
47
+ {
48
+ accessor: "scheduledMeetings",
49
+ id: "scheduledMeetings",
50
+ label: "Scheduled Meetings",
51
+ },
52
+ ],
53
+ },
54
+ ],
55
+ },
56
+ {
57
+ label: "Performance Data",
58
+ id: "performanceData",
59
+ columns: [
60
+ {
61
+ label: "Completion Metrics",
62
+ id: "completionMetrics",
63
+ columns: [
64
+ {
65
+ accessor: "completedClasses",
66
+ label: "Completed Classes",
67
+ id: "completedClasses",
68
+ },
69
+ {
70
+ accessor: "classCompletionRate",
71
+ label: "Class Completion Rate",
72
+ id: "classCompletionRate",
73
+ },
74
+ ],
75
+ },
76
+ {
77
+ label: "Attendance",
78
+ id: "attendance",
79
+ columns: [
80
+ {
81
+ accessor: "attendanceRate",
82
+ label: "Attendance Rate",
83
+ id: "attendanceRate",
84
+ },
85
+ {
86
+ accessor: "scheduledMeetings",
87
+ label: "Scheduled Meetings",
88
+ id: "scheduledMeetings",
89
+ },
90
+ ],
91
+ },
92
+ ],
93
+ },
94
+ ];
95
+
96
+ return (
97
+ <div>
98
+ <AdvancedTable
99
+ columnDefinitions={columnDefinitions}
100
+ tableData={MOCK_DATA}
101
+ {...props}
102
+ />
103
+ </div>
104
+ )
105
+ }
106
+
107
+ export default AdvancedTableWithCustomHeaderMultiHeader;
@@ -0,0 +1 @@
1
+ The optional `header` key/value pair within `columnDefinitions` can also be used with multi headers as seen here.
@@ -0,0 +1,51 @@
1
+ <%
2
+ column_definitions = [
3
+ {
4
+ accessor: "year",
5
+ label: "Year",
6
+ cellAccessors: ["quarter", "month", "day"],
7
+ },
8
+ {
9
+ accessor: "newEnrollments",
10
+ label: "New Enrollments",
11
+ header: ->(cell, label) {
12
+ capture do
13
+ pb_rails("flex", props: { align_items: "center", justify_content: "center" }) do
14
+ pb_rails("caption", props: { margin_right: "xs", text: "New Enrollments" }) +
15
+ pb_rails("icon", props: { id: "tooltip-interact", icon: "info", size: "xs" }) +
16
+ pb_rails("tooltip", props: {
17
+ trigger_element_id: "tooltip-interact",
18
+ tooltip_id: "example-custom-tooltip",
19
+ position: "top",
20
+ z_index: "10"
21
+ }) do
22
+ "Whoa. I'm a Tooltip"
23
+ end
24
+ end
25
+ end
26
+ }
27
+ },
28
+ {
29
+ accessor: "scheduledMeetings",
30
+ label: "Scheduled Meetings",
31
+ },
32
+ {
33
+ accessor: "attendanceRate",
34
+ label: "Attendance Rate",
35
+ },
36
+ {
37
+ accessor: "completedClasses",
38
+ label: "Completed Classes",
39
+ },
40
+ {
41
+ accessor: "classCompletionRate",
42
+ label: "Class Completion Rate",
43
+ },
44
+ {
45
+ accessor: "graduatedStudents",
46
+ label: "Graduated Students",
47
+ }
48
+ ]
49
+ %>
50
+
51
+ <%= pb_rails("advanced_table", props: { id: "custom_header_table", table_data: @table_data, column_definitions: column_definitions }) %>
@@ -0,0 +1 @@
1
+ The optional `header` item can be used within `column_definitions` to render a custom header. This example shows an Icon and Tooltip being used but other kits can be used as well.
@@ -10,6 +10,7 @@ examples:
10
10
  - advanced_table_beta_sort: Enable Sorting
11
11
  - advanced_table_responsive: Responsive Tables
12
12
  - advanced_table_custom_cell_rails: Custom Components for Cells
13
+ - advanced_table_with_custom_header_rails: Custom Header Cell
13
14
  - advanced_table_column_headers: Multi-Header Columns
14
15
  - advanced_table_column_headers_multiple: Multi-Header Columns (Multiple Levels)
15
16
  - advanced_table_no_subrows: Table with No Subrows or Expansion
@@ -18,6 +19,7 @@ examples:
18
19
  - advanced_table_selectable_rows_actions_rails: Selectable Rows (With Actions)
19
20
  - advanced_table_selectable_rows_header_rails: Selectable Rows (No Actions Bar)
20
21
  - advanced_table_scrollbar_none: Advanced Table Scrollbar None
22
+ - advanced_table_row_styling: Row Styling
21
23
  - advanced_table_column_styling_rails: Column Styling
22
24
  - advanced_table_column_styling_column_headers_rails: Column Styling with Multiple Headers
23
25
  - advanced_table_column_border_color_rails: Column Group Border Color
@@ -41,6 +43,7 @@ examples:
41
43
  - advanced_table_responsive: Responsive Tables
42
44
  - advanced_table_custom_cell: Custom Components for Cells
43
45
  - advanced_table_with_custom_header: Custom Header Cell
46
+ - advanced_table_with_custom_header_multi_header: Custom Header with Multiple Headers
44
47
  - advanced_table_pagination: Pagination
45
48
  - advanced_table_pagination_with_props: Pagination Props
46
49
  - advanced_table_loading: Loading State
@@ -40,3 +40,4 @@ export { default as AdvancedTableColumnStylingColumnHeaders } from './_advanced_
40
40
  export { default as AdvancedTableInfiniteScroll} from './_advanced_table_infinite_scroll.jsx'
41
41
  export {default as AdvancedTableWithCustomHeader} from './_advanced_table_with_custom_header.jsx'
42
42
  export { default as AdvancedTableCustomSort } from './_advanced_table_custom_sort.jsx'
43
+ export { default as AdvancedTableWithCustomHeaderMultiHeader } from './_advanced_table_with_custom_header_multi_header.jsx'
@@ -1,7 +1,7 @@
1
1
  ##### Prop
2
2
 
3
3
  `align` **Type**: String | **Values**: left | center | right (defaults to center)
4
- `verticalAlign` **Type**: String | **Values**: top | middle | bottom (defaults middle)
4
+ `verticalAlign` **Type**: String | **Values**: top | middle | bottom (defaults to bottom)
5
5
  `layout` **Type**: String | **Values**: horizontal | vertical | proximate (defaults to horizontal)
6
6
  `x` **Type**: Number (defaults to 0)
7
7
  `y` **Type**: Number (defaults to 0)
@@ -9,10 +9,10 @@
9
9
  <tr>
10
10
  <th>
11
11
  <%= pb_rails("checkbox", props: {
12
+ text: "Uncheck All",
12
13
  value: "checkbox-value",
13
14
  name: "main-checkbox",
14
15
  indeterminate_main: true,
15
- indeterminate_main_labels: ["Check All Ice Cream", "Uncheck All Ice Cream"],
16
16
  id: "indeterminate-checkbox"
17
17
  }) %>
18
18
  </th>
@@ -1,2 +1 @@
1
- If you want to use indeterminate, "check/uncheck all" checkboxes, add `indeterminate_main: true` and an `id` to the main checkbox. Then, add an `indeterminate_parent` prop with the main checkbox's `id` to the children checkboxes.
2
- If you want to customize the main checkbox labels, set an array `indeterminate_main_labels` with "Check All" and "Uncheck All" labels.
1
+ If you want to use indeterminate, "check/uncheck all" checkboxes, add `indeterminate_main: true` and an `id` to the main checkbox. Then, add an `indeterminate_parent` prop with the main checkbox's `id` to the children checkboxes.
@@ -1,7 +1,7 @@
1
1
  ##### Prop
2
2
 
3
3
  `align` **Type**: String | **Values**: left | center | right (defaults to center)
4
- `verticalAlign` **Type**: String | **Values**: top | middle | bottom (defaults middle)
4
+ `verticalAlign` **Type**: String | **Values**: top | middle | bottom (defaults to bottom)
5
5
  `layout` **Type**: String | **Values**: horizontal | vertical | proximate (defaults to horizontal)
6
6
  `x` **Type**: Number (defaults to 0)
7
7
  `y` **Type**: Number (defaults to 0)
@@ -1,3 +1 @@
1
- Line graphs are used to show changes in data over time. The default height of line graph is 400px and can be changed. The default height is in pixel units, but can also use percentage string (percentage would be that of the width. For example, `height:"50%"` would mean that the height is 50% of the width). This allows for preserving the aspect ratio across responsive sizes.
2
-
3
- For more information, see: <a href="https://api.highcharts.com/highcharts/chart.height" target="_blank"> highcharts/chart.height</a>.
1
+ **Important Note for the React Kit**: In order to leverage this kit, you must install `highcharts` and `highcharts-react-official` into your project as shown below. To then apply Playbook styles to your Highchart, import lineGraphTheme.ts from playbook-ui and merge it with your Highchart options. Then, pass the merged value to the options prop. Playbook’s styling will be applied automatically. See the examples in the documentation below.
@@ -1,6 +1,8 @@
1
1
  import React from 'react'
2
-
3
- import LineGraph from '../_line_graph'
2
+ import lineGraphTheme from '../lineGraphTheme'
3
+ import Highcharts from "highcharts"
4
+ import HighchartsReact from "highcharts-react-official"
5
+ import colors from '../../tokens/exports/_colors.module.scss'
4
6
 
5
7
  const data = [{
6
8
  name: 'Installation',
@@ -19,19 +21,36 @@ const data = [{
19
21
  data: [null, null, null, 3112, 4989, 5816, 15274, 18111],
20
22
  }]
21
23
 
22
- const LineGraphColors = (props) => (
23
- <div>
24
- <LineGraph
25
- axisTitle="Number of Employees"
26
- chartData={data}
27
- colors={['data-4', 'data-5', 'data-6', 'data-7', 'data-8']}
28
- id="line-colors"
29
- title="Line Graph with Custom Data Colors"
30
- xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}
31
- yAxisMin={0}
32
- {...props}
33
- />
34
- </div>
35
- )
24
+ const categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
25
+
26
+ const LineGraphColors = () => {
27
+ const chartOptions = {
28
+ title: {
29
+ text: 'Line Graph with Custom Data Colors',
30
+ },
31
+ xAxis: {
32
+ categories: categories,
33
+ },
34
+ yAxis: {
35
+ min: 0,
36
+ title: {
37
+ text: 'Number of Employees',
38
+ },
39
+ },
40
+ series: data,
41
+ colors: [colors.data_4, colors.data_5, "#144075", colors.data_7, colors.data_8]
42
+ }
43
+
44
+ const options = Highcharts.merge({}, lineGraphTheme, chartOptions)
45
+
46
+ return (
47
+ <div>
48
+ <HighchartsReact
49
+ highcharts={Highcharts}
50
+ options={options}
51
+ />
52
+ </div>
53
+ )
54
+ }
36
55
 
37
- export default LineGraphColors
56
+ export default LineGraphColors
@@ -0,0 +1,3 @@
1
+
2
+ Custom data colors allow for color customization to match the needs of business requirements.
3
+ Import the colors from Playbook's tokens, then set custom colors in the colors array using the desired color variables. Hex colors are also available `eg: #CA0095`.
@@ -1,6 +1,7 @@
1
1
  import React from 'react'
2
-
3
- import LineGraph from '../_line_graph'
2
+ import lineGraphTheme from '../lineGraphTheme'
3
+ import Highcharts from "highcharts"
4
+ import HighchartsReact from "highcharts-react-official"
4
5
 
5
6
  const data = [{
6
7
  name: 'Installation',
@@ -19,19 +20,33 @@ const data = [{
19
20
  data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111],
20
21
  }]
21
22
 
22
- const LineGraphDefault = (props) => (
23
- <div>
24
- <LineGraph
25
- axisTitle="Number of Employees"
26
- chartData={data}
27
- id="line-default"
28
- subTitle="Source: thesolarfoundation.com"
29
- title="Solar Employment Growth by Sector, 2010-2016"
30
- xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}
31
- yAxisMin={0}
32
- {...props}
33
- />
34
- </div>
35
- )
23
+ const categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
24
+
25
+ const chartOptions = {
26
+ series: data,
27
+ title: { text: "Solar Employment Growth by Sector, 2010-2016" },
28
+ subtitle: { text: "Source: thesolarfoundation.com" },
29
+ xAxis: {
30
+ categories: categories,
31
+ },
32
+ yAxis: {
33
+ title: {
34
+ text: "Number of Employees",
35
+ },
36
+ },
37
+ }
38
+
39
+ const LineGraphDefault = () => {
40
+ const options = Highcharts.merge({}, lineGraphTheme, chartOptions)
41
+
42
+ return(
43
+ <div>
44
+ <HighchartsReact
45
+ highcharts={Highcharts}
46
+ options={options}
47
+ />
48
+ </div>
49
+ )
50
+ }
36
51
 
37
52
  export default LineGraphDefault
@@ -1,38 +1,70 @@
1
1
  import React from 'react'
2
- import LineGraph from '../_line_graph'
2
+ import lineGraphTheme from '../lineGraphTheme'
3
+ import Highcharts from "highcharts"
4
+ import HighchartsReact from "highcharts-react-official"
3
5
 
4
6
  const data = [{
5
7
  name: 'Number of Installations',
6
8
  data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
7
9
  }]
8
10
 
9
- const LineGraphDefault = (props) => (
10
- <div>
11
- <LineGraph
12
- axisTitle="Number of Employees"
13
- chartData={data}
14
- height="300px"
15
- id="line-fixed-height"
16
- title="Fixed Height (300px)"
17
- xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}
18
- yAxisMin={0}
19
- {...props}
20
- />
21
-
22
- <br />
23
- <br />
24
-
25
- <LineGraph
26
- axisTitle="Number of Employees"
27
- chartData={data}
28
- height="50%"
29
- id="line-percentage-height"
30
- title="Percentage Height (50%)"
31
- xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}
32
- yAxisMin={0}
33
- {...props}
34
- />
35
- </div>
36
- )
37
-
38
- export default LineGraphDefault
11
+ const categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
12
+
13
+ const LineGraphHeight = () => {
14
+ const chartOptionsFirst = {
15
+ title: {
16
+ text: 'Fixed Height (300px)',
17
+ },
18
+ chart: {
19
+ height: '300px'
20
+ },
21
+ xAxis: {
22
+ categories: categories,
23
+ },
24
+ yAxis: {
25
+ min: 0,
26
+ title: {
27
+ text: 'Number of Employees',
28
+ },
29
+ },
30
+ series: data
31
+ }
32
+
33
+ const chartOptionsSecond = {
34
+ title: {
35
+ text: 'Percentage Height (50%)',
36
+ },
37
+ chart: {
38
+ height: '50%'
39
+ },
40
+ xAxis: {
41
+ categories: categories,
42
+ },
43
+ yAxis: {
44
+ min: 0,
45
+ title: {
46
+ text: 'Number of Employees',
47
+ },
48
+ },
49
+ series: data
50
+ }
51
+
52
+ const optionsFirst = Highcharts.merge({}, lineGraphTheme, chartOptionsFirst)
53
+ const optionsSecond = Highcharts.merge({}, lineGraphTheme, chartOptionsSecond)
54
+
55
+ return (
56
+ <div>
57
+ <HighchartsReact
58
+ highcharts={Highcharts}
59
+ options={optionsFirst}
60
+ />
61
+
62
+ <HighchartsReact
63
+ highcharts={Highcharts}
64
+ options={optionsSecond}
65
+ />
66
+ </div>
67
+ )
68
+ }
69
+
70
+ export default LineGraphHeight
@@ -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.
@@ -1,24 +1,43 @@
1
1
  import React from 'react'
2
- import LineGraph from '../../pb_line_graph/_line_graph'
2
+ import lineGraphTheme from '../lineGraphTheme'
3
+ import Highcharts from "highcharts"
4
+ import HighchartsReact from "highcharts-react-official"
3
5
 
4
6
  const data = [{
5
7
  name: 'Number of Installations',
6
8
  data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
7
9
  }]
8
10
 
9
- const LineGraphLegend = (props) => (
10
- <div>
11
- <LineGraph
12
- axisTitle="Number of Employees"
13
- chartData={data}
14
- id="line-test-2"
15
- legend
16
- title="Line Graph with Legend"
17
- xAxisCategories={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug']}
18
- yAxisMin={0}
19
- {...props}
20
- />
21
- </div>
22
- )
11
+ const categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug']
23
12
 
24
- export default LineGraphLegend
13
+ const chartOptions = {
14
+ series: data,
15
+ title: { text: "Line Graph with Legend" },
16
+ xAxis: {
17
+ categories: categories,
18
+ },
19
+ yAxis: {
20
+ min: 0,
21
+ title: {
22
+ text: "Number of Employees",
23
+ },
24
+ },
25
+ legend: {
26
+ enabled: true,
27
+ },
28
+ }
29
+
30
+ const LineGraphLegend = () => {
31
+ const options = Highcharts.merge({}, lineGraphTheme, chartOptions)
32
+
33
+ return(
34
+ <div>
35
+ <HighchartsReact
36
+ highcharts={Highcharts}
37
+ options={options}
38
+ />
39
+ </div>
40
+ )
41
+ }
42
+
43
+ export default LineGraphLegend