diff --git a/components/doc/chart/apidoc.js b/components/doc/chart/apidoc.js
index 29c3d9ff62..ad94f0cda6 100644
--- a/components/doc/chart/apidoc.js
+++ b/components/doc/chart/apidoc.js
@@ -1,7 +1,5 @@
-import { DevelopmentSection } from '../common/developmentsection';
import { DocSectionText } from '../common/docsectiontext';
import { DocSubSection } from '../common/docsubsection';
-import { CodeHighlight } from '../common/codehighlight';
export function ApiDoc(props) {
return (
@@ -73,6 +71,12 @@ export function ApiDoc(props) {
null |
Style class of the element. |
+
+ ariaLabel |
+ string |
+ options.plugins.title.text |
+ ARIA label for the chart canvas. Defaults to options.plugins.title.text if available. |
+
diff --git a/components/doc/chart/basicdoc.js b/components/doc/chart/basicdoc.js
index 33b3ffb6a8..b10e1bcb8b 100644
--- a/components/doc/chart/basicdoc.js
+++ b/components/doc/chart/basicdoc.js
@@ -21,6 +21,12 @@ export function BasicDoc(props) {
]
};
const options = {
+ plugins: {
+ title: {
+ display: true,
+ text: 'Custom Chart Title'
+ }
+ },
scales: {
y: {
beginAtZero: true
diff --git a/components/lib/chart/Chart.js b/components/lib/chart/Chart.js
index b722127abe..545c2f14b2 100644
--- a/components/lib/chart/Chart.js
+++ b/components/lib/chart/Chart.js
@@ -81,10 +81,12 @@ const PrimeReactChart = React.memo(
const otherProps = ObjectUtils.findDiffKeys(props, PrimeReactChart.defaultProps);
const className = classNames('p-chart', props.className);
const style = Object.assign({ width: props.width, height: props.height }, props.style);
+ const title = props.options && props.options.plugins && props.options.plugins.title && props.options.plugins.title.text;
+ const ariaLabel = props.ariaLabel || title;
return (
-
+
);
}),
@@ -102,6 +104,7 @@ PrimeReactChart.defaultProps = {
width: null,
height: null,
style: null,
+ ariaLabel: null,
className: null
};
diff --git a/components/lib/chart/chart.d.ts b/components/lib/chart/chart.d.ts
index 67c5b57a9c..b5e60384d1 100644
--- a/components/lib/chart/chart.d.ts
+++ b/components/lib/chart/chart.d.ts
@@ -50,6 +50,11 @@ export interface ChartProps {
* Style class of the element.
*/
className?: string | undefined;
+ /**
+ * ARIA label for the chart canvas. Defaults to options.plugins.title.text if available.
+ * @default options.plugins.title.text
+ */
+ ariaLabel?: string | undefined;
/**
* Used to get the child elements of the component.
* @readonly