-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Init * Bring old PR work to new PR * Get React chart showing * Add grouped data and color exploration * Fix theme typo to correctly apply config options * Add drillable functionality * Add tooltip customization * Add color override option * Add color grouping * Add tooltip example * Update some documentation wording * Add rails treemap examples * Update sample data and documention * Alphabetize props * Remove Jest file and add some documentation * Add rails spec coverage * Remove unneeded scss and update html dot Co-authored-by: Stephen Crane <scrane88@gmail.com>
- Loading branch information
1 parent
0e2dbff
commit 8a4e2c6
Showing
29 changed files
with
839 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ kits: | |
- gauge | ||
- legend | ||
- line_graph | ||
- treemap_chart | ||
- dialog | ||
- filter | ||
- fixed_confirmation_toast | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
playbook/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* @flow */ | ||
|
||
import React from 'react' | ||
import classnames from 'classnames' | ||
|
||
import { globalProps } from '../utilities/globalProps' | ||
import pbChart from '../plugins/pb_chart' | ||
|
||
type TreemapChartProps = { | ||
chartData: array<{ | ||
name: string, | ||
parent?: string | number, | ||
value: number, | ||
color?: string, | ||
id?: string | number, | ||
}>, | ||
className?: string, | ||
colors: array, | ||
dark?: boolean, | ||
drillable: boolean, | ||
grouped: boolean, | ||
height?: string, | ||
id: number, | ||
title: string, | ||
tooltipHtml: string, | ||
type?: string, | ||
} | ||
|
||
export default class TreemapChart extends React.Component<TreemapChartProps> { | ||
static defaultProps = { | ||
className: 'pb_treemap_chart', | ||
dark: false, | ||
drillable: false, | ||
grouped: false, | ||
type: 'treemap', | ||
} | ||
|
||
componentDidMount() { | ||
const { | ||
chartData, | ||
className, | ||
colors = [], | ||
dark, | ||
drillable, | ||
grouped, | ||
height, | ||
id, | ||
title = "", | ||
tooltipHtml = '<span style="font-weight: bold; color:{point.color};">● </span>{point.name}: <b>{point.value}</b>', | ||
type, | ||
} = this.props | ||
|
||
new pbChart(`.${className}`, { | ||
chartData: chartData, | ||
colors: colors, | ||
dark, | ||
drillable, | ||
grouped, | ||
height: height, | ||
id: id, | ||
title: title, | ||
tooltipHtml, | ||
type, | ||
}) | ||
} | ||
|
||
props: TreemapChartProps | ||
|
||
render() { | ||
const { className, id } = this.props | ||
|
||
return ( | ||
<div | ||
className={classnames(globalProps(this.props), className)} | ||
id={id} | ||
/> | ||
) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
playbook/app/pb_kits/playbook/pb_treemap_chart/docs/_description.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Treemap charts are used to compare the relative size of groups of data. They can also use a nested data structure, allowing a user to drill down into a group to see its constituent data points. | ||
|
||
The default height of treemap 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. | ||
|
||
For more information, see: <a href="https://api.highcharts.com/highcharts/chart.height" target="_blank"> highcharts/chart.height</a>. |
37 changes: 37 additions & 0 deletions
37
playbook/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<% data = [ | ||
{ | ||
name: "Pepperoni", | ||
parent: "Toppings", | ||
value: 600, | ||
}, { | ||
name: "Cheese", | ||
parent: "Toppings", | ||
value: 510, | ||
}, { | ||
name: "Mushroom", | ||
parent: "Toppings", | ||
value: 330, | ||
},{ | ||
name: "Onions", | ||
parent: "Toppings", | ||
value: 250, | ||
}, { | ||
name: "Olives", | ||
parent: "Toppings", | ||
value: 204, | ||
}, { | ||
name: "Pineapple", | ||
parent: "Toppings", | ||
value: 90, | ||
}, { | ||
name: "Pizza Toppings", | ||
id: "Toppings", | ||
}, | ||
] %> | ||
|
||
<%= pb_rails("treemap_chart", props: { | ||
chart_data: data, | ||
colors: ["data-4", "data-7", "#8E6E53", "#124732"], | ||
id: "treemap-colors", | ||
title: "Favored Pizza Toppings", | ||
}) %> |
48 changes: 48 additions & 0 deletions
48
playbook/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react' | ||
|
||
import TreemapChart from '../_treemap_chart' | ||
|
||
const chartData = [ | ||
{ | ||
name: "Pepperoni", | ||
parent: "Toppings", | ||
value: 600, | ||
}, { | ||
name: "Cheese", | ||
parent: "Toppings", | ||
value: 510, | ||
}, { | ||
name: "Mushroom", | ||
parent: "Toppings", | ||
value: 330, | ||
},{ | ||
name: "Onions", | ||
parent: "Toppings", | ||
value: 250, | ||
}, { | ||
name: "Olives", | ||
parent: "Toppings", | ||
value: 204, | ||
}, { | ||
name: "Pineapple", | ||
parent: "Toppings", | ||
value: 90, | ||
}, { | ||
name: "Pizza Toppings", | ||
id: "Toppings", | ||
}, | ||
] | ||
|
||
const TreemapChartColors = (props) => ( | ||
<div> | ||
<TreemapChart | ||
chartData={chartData} | ||
colors={["data-4", "data-7", "#8E6E53", "#124732"]} | ||
id="treemap-colors" | ||
title="Favored Pizza Toppings" | ||
{...props} | ||
/> | ||
</div> | ||
) | ||
|
||
export default TreemapChartColors |
2 changes: 2 additions & 0 deletions
2
playbook/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_colors.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Custom data colors allow for color customization to match the needs of business requirements. | ||
Pass the prop `colors` and use desired values `data-1 | data-2 | data-3 | data-4 | data-5 | data-6 | data-7 | data-8` in an array. Hex colors are also available `eg: #CA0095` |
37 changes: 37 additions & 0 deletions
37
playbook/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<% data = [ | ||
{ | ||
name: "Pepperoni", | ||
parent: "Toppings", | ||
value: 600, | ||
}, { | ||
name: "Cheese", | ||
parent: "Toppings", | ||
value: 510, | ||
}, { | ||
name: "Mushroom", | ||
parent: "Toppings", | ||
value: 330, | ||
},{ | ||
name: "Onions", | ||
parent: "Toppings", | ||
value: 250, | ||
}, { | ||
name: "Olives", | ||
parent: "Toppings", | ||
value: 204, | ||
}, { | ||
name: "Pineapple", | ||
parent: "Toppings", | ||
value: 90, | ||
}, { | ||
name: "Pizza Toppings", | ||
id: "Toppings", | ||
}, | ||
] %> | ||
|
||
|
||
<%= pb_rails("treemap_chart", props: { | ||
chart_data: data, | ||
id: "treemap-default", | ||
title: "Favored Pizza Toppings", | ||
}) %> |
47 changes: 47 additions & 0 deletions
47
playbook/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react' | ||
|
||
import TreemapChart from '../_treemap_chart' | ||
|
||
const chartData = [ | ||
{ | ||
name: "Pepperoni", | ||
parent: "Toppings", | ||
value: 600, | ||
}, { | ||
name: "Cheese", | ||
parent: "Toppings", | ||
value: 510, | ||
}, { | ||
name: "Mushroom", | ||
parent: "Toppings", | ||
value: 330, | ||
},{ | ||
name: "Onions", | ||
parent: "Toppings", | ||
value: 250, | ||
}, { | ||
name: "Olives", | ||
parent: "Toppings", | ||
value: 204, | ||
}, { | ||
name: "Pineapple", | ||
parent: "Toppings", | ||
value: 90, | ||
}, { | ||
name: "Pizza Toppings", | ||
id: "Toppings", | ||
}, | ||
] | ||
|
||
const TreemapChartDefault = (props) => ( | ||
<div> | ||
<TreemapChart | ||
chartData={chartData} | ||
id="treemap-default" | ||
title="Favored Pizza Toppings" | ||
{...props} | ||
/> | ||
</div> | ||
) | ||
|
||
export default TreemapChartDefault |
3 changes: 3 additions & 0 deletions
3
playbook/app/pb_kits/playbook/pb_treemap_chart/docs/_treemap_chart_default.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Points are automatically arranged by their `value` size. | ||
|
||
By default, point colors are assigned sequentially from the global `data` colors. Note that data points without a value (such as parent nodes) will still take on the next available color. |
Oops, something went wrong.