Skip to content

Commit f8f20be

Browse files
authored
Merge pull request #159 from BenLorantfy/betterPropTypeForChartType
Better PropType for type field
2 parents cd354e8 + a2ef4b0 commit f8f20be

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', 'scatter']),
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)