Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] add package [sparkline] add support for tooltips #72

Merged
merged 8 commits into from
Nov 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ env:
- PACKAGE=data-ui-theme
- PACKAGE=forms
- PACKAGE=network
- PACKAGE=shared
script:
- 'cd ./packages/$PACKAGE && npm install && npm run test'
- 'cd ./packages/$PACKAGE && npm install && npm prune && npm run test'
- 'cd ../../'
- 'eslint --ignore-path=.eslintignore --ext .js,.jsx ./packages/$PACKAGE'
after_script:
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"packages": [
"packages/*"
],
"version": "independent"
"version": "0.0.46"
}
57 changes: 36 additions & 21 deletions packages/demo/examples/03-sparkline/BarSeriesExamples.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {

HorizontalReferenceLine,
VerticalReferenceLine,
WithTooltip,

PatternLines,
LinearGradient,
Expand Down Expand Up @@ -48,27 +49,41 @@ export default [
</Sparkline>
</Example>

<Example title="Custom fill with label and max line">
<Sparkline
{...sparklineProps}
data={range(35).map((_, i) => i + (5 * Math.random()) + (i === 34 ? 5 : 0))}
>
<HorizontalReferenceLine
reference="max"
stroke={allColors.grape[8]}
strokeWidth={1}
strokeDasharray="3,3"
labelPosition="right"
labelOffset={12}
renderLabel={() => 'max'}
/>
<BarSeries
fill={(d, i) => allColors.grape[i === 34 ? 8 : 2]}
fillOpacity={0.7}
renderLabel={(d, i) => (i === 34 ? '🚀' : null)}
/>
</Sparkline>
</Example>
{(data => (
<Example title="Custom fill with label + ref line bound to tooltip">
<WithTooltip>
{({ onMouseMove, onMouseLeave, tooltipData }) => (
<Sparkline
{...sparklineProps}
onMouseLeave={onMouseLeave}
onMouseMove={onMouseMove}
data={data}
>
<BarSeries
fill={(d, i) => {
const indexToHighlight = tooltipData ? tooltipData.index : 34;
return allColors.grape[i === indexToHighlight ? 8 : 2];
}}
fillOpacity={0.7}
renderLabel={(d, i) => {
const indexToHighlight = tooltipData ? tooltipData.index : 34;
return i === indexToHighlight ? '🚀' : null;
}}
/>
<HorizontalReferenceLine
reference={tooltipData ? tooltipData.datum.y : 'max'}
stroke={allColors.grape[8]}
strokeWidth={1}
strokeDasharray="3,3"
labelPosition="right"
labelOffset={12}
renderLabel={() => (tooltipData ? tooltipData.datum.y.toFixed(2) : 'max')}
/>
</Sparkline>
)}
</WithTooltip>
</Example>
))(range(35).map((_, i) => i + (5 * Math.random()) + (i === 34 ? 5 : 0)))}

<Example title="Gradient fill with vertical reference line">
<Sparkline
Expand Down
Loading