-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Play-450] Charts/Graphs kits legend position (#2171)
* added the five legend props to the default setupChart method in pb_chart.js as well as to the line_graph kit for both react and rails * added spec test for line_graph * added five legend props to bar_graph * added spec tests for bar_graph new props * added the five props tot the setupPieChart method in pb_chat and added the five props to the rails and react circle chart kits * created new doc in circle_chart to showcase the five new props * added a new doc to bar_graph to showcase the 5 new legend position props * created new doc for line_graph to showcase 5 new legend position props * refactored the documentation files per feedback * refactred the doc examples to show one for alignmnet one for layout and one for x and y offset for the bar graph * added doc examples in circle chart for alignment, layout, and x and y offset * added doc examples to line graph for new legend props * fixed but in rails version of line graph where subtitle prop was not being passed correctly and update the doc examples for legend position * fixed bug in rails version of bar graph where subtitle prop was not being passed correctly and update the doc examples for legend position * update the doc examples for legend position
- Loading branch information
1 parent
51b321f
commit 35ea2fd
Showing
24 changed files
with
706 additions
and
3 deletions.
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
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
62 changes: 62 additions & 0 deletions
62
playbook/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.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,62 @@ | ||
<% data = [{ | ||
name: 'Installation', | ||
data: [1475] | ||
}, { | ||
name: 'Manufacturing', | ||
data: [4434] | ||
}, { | ||
name: 'Sales & Distribution', | ||
data: [3387] | ||
}, { | ||
name: 'Project Development', | ||
data: [3227] | ||
}, { | ||
name: 'Other', | ||
data: [1111] | ||
}] %> | ||
<%= pb_rails("title", props: {size: 4, text: "align | vertical_align", padding_top: "sm", padding_bottom: "sm"})%> | ||
<%= pb_rails("bar_graph", props: { | ||
axis_title: 'Number of Employees', | ||
chart_data: data, | ||
id:"legend-position", | ||
y_axis_min: 0, | ||
x_axis_categories:['Jan'], | ||
title: 'Alignment of Legend', | ||
legend: true, | ||
align: 'right', | ||
vertical_align: 'top', | ||
padding_bottom: "sm", | ||
}) %> | ||
<%= pb_rails("title", props: {size: 4, text: "layout", padding_top: "sm", padding_bottom: "sm"})%> | ||
<%= pb_rails("bar_graph", props: { | ||
axis_title: 'Number of Employees', | ||
chart_data: data, | ||
id:"legend-position-1", | ||
y_axis_min: 0, | ||
x_axis_categories:['Jan'], | ||
title: 'Layout of Legend', | ||
legend: true, | ||
layout: 'vertical', | ||
padding_top: "sm", | ||
padding_bottom: "sm", | ||
}) %> | ||
<%= pb_rails("title", props: {size: 4, text: "x | y", padding_top: "sm", padding_bottom: "sm"})%> | ||
<%= pb_rails("bar_graph", props: { | ||
axis_title: 'Number of Employees', | ||
chart_data: data, | ||
id:"legend-position-2", | ||
y_axis_min: 0, | ||
x_axis_categories:['Jan'], | ||
title: 'Offset of Legend', | ||
legend: true, | ||
layout: "vertical", | ||
x: 100, | ||
y: 10, | ||
padding_top: "sm", | ||
}) %> |
86 changes: 86 additions & 0 deletions
86
playbook/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.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,86 @@ | ||
import React from 'react' | ||
import { BarGraph, Title } from '../..' | ||
|
||
const chartData = [{ | ||
name: 'Installation', | ||
data: [1475], | ||
}, { | ||
name: 'Manufacturing', | ||
data: [4434], | ||
}, { | ||
name: 'Sales & Distribution', | ||
data: [3387], | ||
}, { | ||
name: 'Project Development', | ||
data: [3227], | ||
}, { | ||
name: 'Other', | ||
data: [1111], | ||
}] | ||
|
||
const BarGraphLegendPosition = (props) => ( | ||
<div> | ||
<Title | ||
paddingBottom="sm" | ||
paddingTop="sm" | ||
size={4} | ||
tag="h4" | ||
text="align | verticalAlign" | ||
/> | ||
<BarGraph | ||
align='right' | ||
axisTitle="Number of Employees" | ||
chartData={chartData} | ||
id="legend-position" | ||
legend | ||
paddingBottom="sm" | ||
title="Alignment of Legend" | ||
verticalAlign="top" | ||
xAxisCategories={['Jan']} | ||
yAxisMin={0} | ||
{...props} | ||
/> | ||
<Title | ||
paddingBottom="sm" | ||
paddingTop="sm" | ||
size={4} | ||
tag="h4" | ||
text="layout" | ||
/> | ||
<BarGraph | ||
axisTitle="Number of Employees" | ||
chartData={chartData} | ||
id="legend-position-1" | ||
layout="vertical" | ||
legend | ||
paddingBottom="sm" | ||
paddingTop="sm" | ||
title="Layout of Legend" | ||
xAxisCategories={['Jan']} | ||
yAxisMin={0} | ||
{...props} | ||
/> | ||
<Title | ||
paddingBottom="sm" | ||
paddingTop="sm" | ||
size={4} | ||
tag="h4" | ||
text="x | y" | ||
/> | ||
<BarGraph | ||
axisTitle="Number of Employees" | ||
chartData={chartData} | ||
id="legend-position-2" | ||
layout="vertical" | ||
legend | ||
title="Offset of Legend" | ||
x={100} | ||
xAxisCategories={['Jan']} | ||
y={10} | ||
yAxisMin={0} | ||
{...props} | ||
/> | ||
</div> | ||
) | ||
|
||
export default BarGraphLegendPosition |
17 changes: 17 additions & 0 deletions
17
playbook/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.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,17 @@ | ||
##### Prop | ||
|
||
`align` **Type**: String | **Values**: left | center | right (defaults to center) | ||
`verticalAlign` **Type**: String | **Values**: top | middle | bottom (defaults middle) | ||
`layout` **Type**: String | **Values**: horizontal | vertical | proximate (defaults to horizontal) | ||
`x` **Type**: Number (defaults to 0) | ||
`y` **Type**: Number (defaults to 0) | ||
|
||
- | ||
|
||
- `layout` determines the position of the legend items | ||
`layout: proximate` will place the legend items as close as possible to the graphs they're representing. It will also determine whether to place the legend above/below or on the side of the plot area, if the legend is in a corner. | ||
|
||
- `x` offsets the legend relative to its horizontal alignmnet. Negative x moves it to the left, positive x moves it to the right | ||
|
||
|
||
- `y` offsets the legend relative to its vertical alignmnet. Negative y moves it up, positive y moves it down. |
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
Oops, something went wrong.