refactor(charts.js): use switch instead of multiple if else
This commit is contained in:
parent
4bb44c0914
commit
38a9428059
@ -16,18 +16,13 @@ import Heatmap from './charts/Heatmap';
|
|||||||
|
|
||||||
export default class Chart {
|
export default class Chart {
|
||||||
constructor(args) {
|
constructor(args) {
|
||||||
if(args.type === 'line') {
|
switch (args.type) {
|
||||||
return new LineChart(arguments[0]);
|
case 'line': return new LineChart(arguments[0]);
|
||||||
} else if(args.type === 'bar') {
|
case 'bar': return new BarChart(arguments[0]);
|
||||||
return new BarChart(arguments[0]);
|
case 'scatter': return new ScatterChart(arguments[0]);
|
||||||
} else if(args.type === 'scatter') {
|
case 'percentage': return new PercentageChart(arguments[0]);
|
||||||
return new ScatterChart(arguments[0]);
|
case 'heatmap': return new Heatmap(arguments[0]);
|
||||||
} else if(args.type === 'percentage') {
|
default: return new LineChart(arguments[0]);
|
||||||
return new PercentageChart(arguments[0]);
|
|
||||||
} else if(args.type === 'heatmap') {
|
|
||||||
return new Heatmap(arguments[0]);
|
|
||||||
} else {
|
|
||||||
return new LineChart(arguments[0]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user