Patternfly-react: PF4: StackChart - setting the default tooltip background color

Created on 8 Jul 2019  路  3Comments  路  Source: patternfly/patternfly-react

It seems that our current default theme applied to StackCharts sets the tooltip fill and stroke to #EDEDED making the text unreadable.

Screen Shot 2019-07-08 at 3 09 18 PM

(changing our first StackChart example to reproduce this):

    <Chart
      legendData={[{ name: 'Cats' }, { name: 'Birds' }, { name: 'Dogs' }, { name: 'Mice' }]}
      legendOrientation="vertical"
      legendPosition="right"
      height={250}
      padding={{
        bottom: 50,
        left: 50,
        right: 200, // Adjusted to accomodate legend
        top: 50
      }}
      width={600}
    >
      <ChartStack domainPadding={{x: [10, 2]}}>
        <ChartBar data={[{ name: 'Cats', x: '2015', y: 1, label: 'Abcd' }, { name: 'Cats', x: '2016', y: 2 }, { name: 'Cats', x: '2017', y: 5 }, { name: 'Cats', x: '2018', y: 3 }]} labelComponent={<ChartTooltip />} />
        <ChartBar data={[{ name: 'Dogs', x: '2015', y: 2 }, { name: 'Dogs', x: '2016', y: 1 }, { name: 'Dogs', x: '2017', y: 7 }, { name: 'Dogs', x: '2018', y: 4 }]} />
        <ChartBar data={[{ name: 'Birds', x: '2015', y: 4 }, { name: 'Birds', x: '2016', y: 4 }, { name: 'Birds', x: '2017', y: 9 }, { name: 'Birds', x: '2018', y: 7 }]} />
        <ChartBar data={[{ name: 'Mice', x: '2015', y: 3 }, { name: 'Mice', x: '2016', y: 3 }, { name: 'Mice', x: '2017', y: 8 }, { name: 'Mice', x: '2018', y: 5 }]} />
      </ChartStack>
    </Chart>

Screen Shot 2019-07-08 at 2 37 59 PM
Screen Shot 2019-07-08 at 2 38 56 PM

You can pass a custom theme object to ChartTooltip but that does not seem to work well here either.

    const theme = {
      ...ChartBaseTheme,
      tooltip: {
        ...ChartBaseTheme.tooltip,
        style: {
          ...ChartBaseTheme.tooltip.style,
          fill: '#FFF'
        }
      }
    };
...
<ChartBar data={chartData} labelComponent={<ChartTooltip theme={theme} />} />

The current workaround which seems to work for the moment:

<ChartBar data={chartData} labelComponent={<ChartTooltip style={{ fill: '#FFF' }} />} />

Would be nice to shore this up in PF in the future though...

PF4 bug

All 3 comments

I've custom tailored this a bit further due to our larger/wide responsive graph. Just noting this for later when we review this again w/ StackChart tooltips, wide responsive variations will help!

https://github.com/RedHatInsights/curiosity-frontend/pull/35

confirmed this resolve the theme issue downstream as well. So upgrading to @patternfly/[email protected] fixes it!

thanks @dlabrecq 馃樃

Was this page helpful?
0 / 5 - 0 ratings