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

Added the ability to add victory charts title and desc props for better accessibility #2199

Merged
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
39 changes: 33 additions & 6 deletions demo/js/components/victory-chart-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,20 @@ class App extends React.Component {
<div className="demo">
<h1>VictoryChart</h1>
<div style={containerStyle}>
<VictoryChart style={chartStyle} polar>
<VictoryChart
polar
style={chartStyle}
title="Victory Polar Scatter Chart"
desc="Circular graph with a twirl pattern of data points"
>
<VictoryScatter />
</VictoryChart>

<VictoryChart style={assign({}, chartStyle, bgStyle)}>
<VictoryChart
style={assign({}, chartStyle, bgStyle)}
title="Victory Scatter Chart"
desc="Graph with scattered data points"
>
<VictoryScatter
data={[
{ x: -3, y: -3 },
Expand All @@ -227,11 +236,21 @@ class App extends React.Component {
/>
</VictoryChart>

<VictoryChart style={chartStyle} theme={dependentAxisTheme}>
<VictoryChart
style={chartStyle}
theme={dependentAxisTheme}
title="Victory Diagonal Scatter Chart"
desc="Graph with a diagonal pattern of data points"
>
<VictoryScatter />
</VictoryChart>

<VictoryChart style={chartStyle} domainPadding={{ x: [0, 20] }}>
<VictoryChart
style={chartStyle}
domainPadding={{ x: [0, 20] }}
title="Victory Bar Chart"
desc="Bar graph"
>
<VictoryAxis dependentAxis style={axisStyle} />
<VictoryAxis style={axisStyle} tickCount={6} />
<VictoryBar
Expand All @@ -249,7 +268,11 @@ class App extends React.Component {
/>
</VictoryChart>

<VictoryChart style={chartStyle}>
<VictoryChart
style={chartStyle}
title="Victory Bar Chart with label data bars"
desc="Bar graph with labeled data bars with different widths"
>
<VictoryAxis tickFormat={(t, i, ts) => `${t}s ${i} ${ts[0]}`} />
<VictoryBar
groupComponent={<VictoryClipContainer />}
Expand All @@ -262,7 +285,11 @@ class App extends React.Component {
/>
</VictoryChart>

<VictoryChart style={chartStyle}>
<VictoryChart
style={chartStyle}
title="Victory Horizontal Bar Graph"
desc="Horizontal bar graph data with x and y axis points"
>
<VictoryGroup
labels={["a", "b", "c"]}
horizontal
Expand Down
30 changes: 18 additions & 12 deletions packages/victory-chart/src/victory-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const VictoryChart = (initialProps) => {

const modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
const {
desc,
eventKey,
containerComponent,
standalone,
Expand All @@ -46,7 +47,8 @@ const VictoryChart = (initialProps) => {
height,
theme,
polar,
name
name,
title
} = modifiedProps;

const axes = props.polar
Expand Down Expand Up @@ -90,34 +92,38 @@ const VictoryChart = (initialProps) => {
const containerProps = React.useMemo(() => {
if (standalone) {
return {
desc,
domain,
scale,
width,
height,
standalone,
theme,
style: style.parent,
horizontal,
name,
origin: polar ? origin : undefined,
polar,
radius,
origin: polar ? origin : undefined
theme,
title,
scale,
standalone,
style: style.parent
};
}
return {};
}, [
desc,
domain,
scale,
width,
height,
standalone,
theme,
style,
horizontal,
name,
origin,
polar,
radius,
origin
scale,
standalone,
style,
title,
theme,
width
]);

const container = React.useMemo(() => {
Expand Down