38 lines
892 B
JavaScript
38 lines
892 B
JavaScript
import '../styles/charts.less';
|
|
|
|
import BarChart from './charts/BarChart';
|
|
import LineChart from './charts/LineChart';
|
|
import ScatterChart from './charts/ScatterChart';
|
|
import PercentageChart from './charts/PercentageChart';
|
|
import Heatmap from './charts/Heatmap';
|
|
|
|
// if (ENV !== 'production') {
|
|
// // Enable LiveReload
|
|
// document.write(
|
|
// '<script src="http://' + (location.host || 'localhost').split(':')[0] +
|
|
// ':35729/livereload.js?snipver=1"></' + 'script>'
|
|
// );
|
|
// }
|
|
|
|
const chartTypes = {
|
|
line: LineChart,
|
|
bar: BarChart,
|
|
scatter: ScatterChart,
|
|
percentage: PercentageChart,
|
|
heatmap: Heatmap
|
|
};
|
|
|
|
function getChartByType(chartType = 'line', options) {
|
|
if (!chartTypes[chartType]) {
|
|
return new LineChart(options);
|
|
}
|
|
|
|
return new chartTypes[chartType](options);
|
|
}
|
|
|
|
export default class Chart {
|
|
constructor(args) {
|
|
return getChartByType(args.type, arguments[0]);
|
|
}
|
|
}
|