Skip to content

Commit

Permalink
double-line - add margin & change mock data
Browse files Browse the repository at this point in the history
  • Loading branch information
kc-leung committed Oct 17, 2022
1 parent 9cf8c57 commit c5ef84c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
17 changes: 11 additions & 6 deletions src/components/plotly/double-line/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const DoubleLine = ({
formatData,
showTicks,
showAxisTitles,
showCurrency,
tickSuffix,
tickPrefix,
hoverInfo,
hoverText,
...props
Expand Down Expand Up @@ -79,7 +80,8 @@ const DoubleLine = ({
},
}),
showticklabels: showTicks,
tickprefix: showCurrency[0] && '$',
tickprefix: tickPrefix[0],
ticksuffix: tickSuffix[0],
automargin: true,
overlaying: 'y2',
},
Expand All @@ -91,12 +93,13 @@ const DoubleLine = ({
},
}),
showticklabels: showTicks,
tickprefix: showCurrency[1] && '$',
tickprefix: tickPrefix[1],
ticksuffix: tickSuffix[1],
automargin: true,
side: 'right',
},
margin: {
pad: 4,
pad: 10,
},
}}
/>
Expand All @@ -110,7 +113,8 @@ DoubleLine.propTypes = {
formatData: PropTypes.objectOf(PropTypes.func),
showTicks: PropTypes.bool,
showAxisTitles: PropTypes.bool,
showCurrency: PropTypes.arrayOf(PropTypes.bool),
tickSuffix: PropTypes.arrayOf(PropTypes.string),
tickPrefix: PropTypes.arrayOf(PropTypes.string),
hoverInfo: PropTypes.string,
hoverText: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.string),
Expand All @@ -123,7 +127,8 @@ DoubleLine.defaultProps = {
formatData: {},
showTicks: true,
showAxisTitles: true,
showCurrency: [false, false],
tickSuffix: [],
tickPrefix: [],
hoverInfo: '',
hoverText: [],
...plotlyDefaultProps,
Expand Down
40 changes: 20 additions & 20 deletions stories/data/plotly/mock-data-double-line.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
[
{
"city": "Longueuil",
"spend": 250,
"transactions": 2.2
"spend": 4.2,
"transactions": 4
},
{
"city": "Niagara Falls",
"spend": 113,
"transactions": 2.5
"spend": 3.9,
"transactions": 4.2
},
{
"city": "Montreal",
"spend": 141,
"transactions": 2
"spend": 1.5,
"transactions": 3.5
},
{
"city": "Saskatoon",
"spend": 152,
"transactions": 2.3
"spend": 4,
"transactions": 4.3
},
{
"city": "Vancouver",
"spend": 220,
"transactions": 3
"spend": 3,
"transactions": 4
},
{
"city": "Toronto",
"spend": 250,
"transactions": 2.8
"spend": 4.2,
"transactions": 4.5
},
{
"city": "Ottawa",
"spend": 113,
"transactions": 2.5
"spend": 3,
"transactions": 3.5
},
{
"city": "Brampton",
"spend": 141,
"transactions": 2
"spend": 2.8,
"transactions": 3.8
},
{
"city": "Calgary",
"spend": 152,
"transactions": 2.3
"spend": 3.2,
"transactions": 4.2
},
{
"city": "Edmonton",
"spend": 300,
"transactions": 3
"spend": 5,
"transactions": 5
}
]
2 changes: 1 addition & 1 deletion stories/plotly/plotly-double-line.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ const Template = (args) =>
</ResponsiveChartWrapper>

export const Default = Template.bind({})
Default.args = { showCurrency: [true, false] }
Default.args = { tickSuffix: ['%', '%'] }

0 comments on commit c5ef84c

Please sign in to comment.