index.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import React, { Component } from 'react'
  2. import { IWidgetProps } from '../Widget'
  3. import Table from './Table'
  4. import Scorecard from './Scorecard'
  5. import Iframe from './Iframe'
  6. import RichText from './RichText'
  7. import Chart from './Chart'
  8. import ChartTypes from '../../config/chart/ChartTypes'
  9. export interface IChartProps extends IWidgetProps {
  10. width: number
  11. height: number
  12. }
  13. export class CombinedChart extends Component<IChartProps, {}> {
  14. public shouldComponentUpdate (nextProps: IChartProps) {
  15. return nextProps.renderType !== 'loading'
  16. }
  17. public render () {
  18. const { selectedChart } = this.props
  19. switch (selectedChart) {
  20. case ChartTypes.Table:
  21. return (
  22. <Table {...this.props}/>
  23. )
  24. case ChartTypes.Scorecard:
  25. return (
  26. <Scorecard {...this.props} />
  27. )
  28. case ChartTypes.Iframe:
  29. return (
  30. <Iframe {...this.props} />
  31. )
  32. case ChartTypes.RichText:
  33. return (
  34. <RichText {...this.props} />
  35. )
  36. default:
  37. return (
  38. <Chart {...this.props}/>
  39. )
  40. }
  41. }
  42. }
  43. export default CombinedChart