Skip to content

Commit 9f19958

Browse files
committed
Changed PropType of type field to validate against current chart types including extended ones
1 parent 15f1448 commit 9f19958

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ class ChartComponent extends React.Component {
2121
options: PropTypes.object,
2222
plugins: PropTypes.arrayOf(PropTypes.object),
2323
redraw: PropTypes.bool,
24-
type: PropTypes.oneOf(['doughnut', 'pie', 'line', 'bar', 'horizontalBar', 'radar', 'polarArea', 'bubble']),
24+
type: function(props, propName, componentName) {
25+
if(!Object.keys(Chart.controllers).find((chartType) => chartType === props[propName])){
26+
return new Error(
27+
'Invalid chart type `' + props[propName] + '` supplied to' +
28+
' `' + componentName + '`.'
29+
);
30+
}
31+
},
2532
width: PropTypes.number,
2633
datasetKeyProvider: PropTypes.func
2734
}

0 commit comments

Comments
 (0)