Skip to content

Commit

Permalink
[demo][xy-chart] demo custom tooltip props
Browse files Browse the repository at this point in the history
  • Loading branch information
williaster committed Nov 16, 2017
1 parent 2e75580 commit 78f9e8a
Showing 1 changed file with 38 additions and 25 deletions.
63 changes: 38 additions & 25 deletions packages/demo/examples/01-xy-chart/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
HorizontalReferenceLine,
PatternLines,
LinearGradient,
WithTooltip,
theme,
} from '@data-ui/xy-chart';

Expand Down Expand Up @@ -66,32 +67,44 @@ export default {
description: 'BarSeries -- no axes',
components: [XYChart, BarSeries, LinearGradient, PatternLines],
example: () => (
<ResponsiveXYChart
ariaLabel="Required label"
xScale={{ type: 'time' }}
yScale={{ type: 'linear' }}
<WithTooltip
renderTooltip={({ datum }) => datum.y}
tooltipProps={{
offsetTop: 0,
style: {
backgroundColor: 'pink',
opacity: 0.9,
},
}}
>
<LinearGradient
id="gradient"
from={colors.default}
to={colors.dark}
/>
<PatternLines
id="lines"
height={8}
width={8}
stroke={colors.categories[2]}
strokeWidth={1}
orientation={['horizontal', 'vertical']}
/>
<BarSeries
data={timeSeriesData.map((d, i) => ({
...d,
fill: `url(#${i === 2 ? 'lines' : 'gradient'})`,
}))}
fill="url(#aqua_lightaqua_gradient)"
/>
</ResponsiveXYChart>
<ResponsiveXYChart
ariaLabel="Required label"
xScale={{ type: 'time' }}
yScale={{ type: 'linear' }}
renderTooltip={null}
>
<LinearGradient
id="gradient"
from={colors.default}
to={colors.dark}
/>
<PatternLines
id="lines"
height={8}
width={8}
stroke={colors.categories[2]}
strokeWidth={1}
orientation={['horizontal', 'vertical']}
/>
<BarSeries
data={timeSeriesData.map((d, i) => ({
...d,
fill: `url(#${i === 2 ? 'lines' : 'gradient'})`,
}))}
fill="url(#aqua_lightaqua_gradient)"
/>
</ResponsiveXYChart>
</WithTooltip>
),
},
{
Expand Down

0 comments on commit 78f9e8a

Please sign in to comment.