You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
892 B

  1. import '../styles/charts.less';
  2. import BarChart from './charts/BarChart';
  3. import LineChart from './charts/LineChart';
  4. import ScatterChart from './charts/ScatterChart';
  5. import PercentageChart from './charts/PercentageChart';
  6. import Heatmap from './charts/Heatmap';
  7. // if (ENV !== 'production') {
  8. // // Enable LiveReload
  9. // document.write(
  10. // '<script src="http://' + (location.host || 'localhost').split(':')[0] +
  11. // ':35729/livereload.js?snipver=1"></' + 'script>'
  12. // );
  13. // }
  14. const chartTypes = {
  15. line: LineChart,
  16. bar: BarChart,
  17. scatter: ScatterChart,
  18. percentage: PercentageChart,
  19. heatmap: Heatmap
  20. };
  21. function getChartByType(chartType = 'line', options) {
  22. if (!chartTypes[chartType]) {
  23. return new LineChart(options);
  24. }
  25. return new chartTypes[chartType](options);
  26. }
  27. export default class Chart {
  28. constructor(args) {
  29. return getChartByType(args.type, arguments[0]);
  30. }
  31. }