FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(charts): Adjust pf-core vars & add tooltip examples by dlabrecq · Pull Request #2497 · patternfly/patternfly-react · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (4) .scss  (1) .snap  (16) .ts  (18) .tsx  (1) All 5 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
      • Chart.tsx
        • Chart.test.tsx.snap
        • ChartArea.md
        • chart-area.scss
        • ChartBar.test.tsx.snap
        • ChartBar.md
        • ChartLine.md
      • ChartPie.test.tsx.snap
        • ChartStack.md
      • base-theme.ts
      • color-theme.ts
        • blue-color-theme.ts
        • cyan-color-theme.ts
        • gold-color-theme.ts
        • gray-color-theme.ts
        • green-color-theme.ts
        • multi-color-theme.ts
        • orange-color-theme.ts
        • purple-color-theme.ts
        • blue-color-theme.ts
        • cyan-color-theme.ts
        • gold-color-theme.ts
        • gray-color-theme.ts
        • green-color-theme.ts
        • multi-color-theme.ts
        • orange-color-theme.ts
        • purple-color-theme.ts
This file contains hidden or 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
Expand Up @@ -30,7 +30,7 @@ import { getPaddingForSide } from '../ChartUtils/chart-padding';
*/
export interface ChartProps extends VictoryChartProps {
/**
* See Victory type docs: https://formidable.com/open-source/victory/docs/victory-area/
* See Victory type docs: https://formidable.com/open-source/victory/docs/victory-chart/
*/
' '?: any;
/**
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file contains hidden or 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
Expand Up @@ -128,64 +128,94 @@ import { Chart, ChartArea, ChartAxis, ChartGroup, ChartThemeColor } from '@patte
</div>
```

## Multi-color area chart with tooltip and bottom-left-aligned legend
## Multi-color chart with tooltip, bottom-aligned legend, and responsive width
```js
import React from 'react';
import { Chart, ChartArea, ChartAxis, ChartGroup, ChartThemeColor } from '@patternfly/react-charts';

<div>
<div className="area-chart-legend-bottom">
<Chart
containerComponent={<ChartVoronoiContainer labels={datum => `${datum.name}: ${datum.y}`} />}
legendData={[{ name: 'Cats' }, { name: 'Birds' }, { name: 'Dogs' }]}
legendPosition="bottom-left"
height={225}
padding={{
bottom: 75, // Adjusted to accomodate legend
left: 50,
right: 50,
top: 50,
}}
maxDomain={{y: 9}}
themeColor={ChartThemeColor.multi}
width={650}
>
<ChartAxis />
<ChartAxis dependentAxis showGrid />
<ChartGroup>
<ChartArea
data={[
{ name: 'Cats', x: 1, y: 3 },
{ name: 'Cats', x: 2, y: 4 },
{ name: 'Cats', x: 3, y: 8 },
{ name: 'Cats', x: 4, y: 6 }
]}
interpolation="basis"
/>
<ChartArea
data={[
{ name: 'Birds', x: 1, y: 2 },
{ name: 'Birds', x: 2, y: 3 },
{ name: 'Birds', x: 3, y: 4 },
{ name: 'Birds', x: 4, y: 5 },
{ name: 'Birds', x: 5, y: 6 }
]}
interpolation="basis"
/>
<ChartArea
data={[
{ name: 'Dogs', x: 1, y: 1 },
{ name: 'Dogs', x: 2, y: 2 },
{ name: 'Dogs', x: 3, y: 3 },
{ name: 'Dogs', x: 4, y: 2 },
{ name: 'Dogs', x: 5, y: 4 }
]}
interpolation="basis"
/>
</ChartGroup>
</Chart>
</div>
</div>
class MultiColorChart extends React.Component {
constructor(props) {
super(props);
this.containerRef = React.createRef();
this.state = {
width: 0
};
this.handleResize = () => {
this.setState({ width: this.containerRef.current.clientWidth });
};
}

componentDidMount() {
setTimeout(() => {
this.setState({ width: this.containerRef.current.clientWidth });
window.addEventListener('resize', this.handleResize);
});
}

componentWillUnmount() {
window.removeEventListener('resize', this.handleResize);
}

render() {
const { width } = this.state;

return (
<div ref={this.containerRef}>
<div className="area-chart-legend-bottom-responsive">
<Chart
containerComponent={<ChartVoronoiContainer labels={datum => `${datum.name}: ${datum.y}`} />}
legendData={[{ name: 'Cats' }, { name: 'Birds' }, { name: 'Dogs' }]}
legendPosition="bottom-left"
height={225}
padding={{
bottom: 75, // Adjusted to accomodate legend
left: 50,
right: 50,
top: 50,
}}
maxDomain={{y: 9}}
themeColor={ChartThemeColor.multi}
width={width}
>
<ChartAxis />
<ChartAxis dependentAxis showGrid />
<ChartGroup>
<ChartArea
data={[
{ name: 'Cats', x: 1, y: 3 },
{ name: 'Cats', x: 2, y: 4 },
{ name: 'Cats', x: 3, y: 8 },
{ name: 'Cats', x: 4, y: 6 }
]}
interpolation="basis"
/>
<ChartArea
data={[
{ name: 'Birds', x: 1, y: 2 },
{ name: 'Birds', x: 2, y: 3 },
{ name: 'Birds', x: 3, y: 4 },
{ name: 'Birds', x: 4, y: 5 },
{ name: 'Birds', x: 5, y: 6 }
]}
interpolation="basis"
/>
<ChartArea
data={[
{ name: 'Dogs', x: 1, y: 1 },
{ name: 'Dogs', x: 2, y: 2 },
{ name: 'Dogs', x: 3, y: 3 },
{ name: 'Dogs', x: 4, y: 2 },
{ name: 'Dogs', x: 5, y: 4 }
]}
interpolation="basis"
/>
</ChartGroup>
</Chart>
</div>
</div>
);
}
}
```

## Sparkline chart
Expand All @@ -197,7 +227,8 @@ import { ChartArea, ChartGroup, ChartLabel } from '@patternfly/react-charts';
<div className="sparkline-container">
<div className="sparkline-chart">
<ChartGroup
height={100}
containerComponent={<ChartVoronoiContainer labels={datum => `${datum.name}: ${datum.y}`} voronoiDimension="x" />}
height={75}
padding={0}
width={400}
>
Expand Down
This file contains hidden or 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
Expand Up @@ -5,20 +5,27 @@
width: 650px;
}

.area-chart-legend-bottom-responsive {
height: 225px;
}

.area-chart-legend-right {
height: 200px;
width: 800px;
}

.sparkline-chart {
height: 100px;
height: 75px;
width: 400px;
}

.sparkline-container {
margin-left: 50px;
margin-top: 50px;
height: 135px;
& svg {
overflow: visible;
}
}
}
}
Loading

Back | FazBrowse Home | New Git URL