thumbnail.jsx 877 B

12345678910111213141516171819202122
  1. import React from 'react'
  2. import Echarts from 'echarts-for-react'
  3. import resolveChartThumbnailOption from './resolveChartThumbnailOption'
  4. const Thumbnail = ({ style, type, code, option }) => {
  5. const newOption = resolveChartThumbnailOption(option);
  6. const viewType = ['bar', 'line', 'pie', 'scatter'].indexOf(type) !== -1 ? 'echarts' :
  7. (['aggregateTable', 'dataView'].indexOf(type) !== -1 ? 'table' : 'default');
  8. return (
  9. <div style={{ ...style, width: '100%', height: '100%' }}>
  10. {viewType === 'echarts' ? <Echarts
  11. key={code}
  12. option={newOption}
  13. className='rc-echarts'
  14. style={{height: '100%'}}
  15. /> : ( viewType === 'table' ? <div className='table-default'></div> : <div className='chart-default'></div>)}
  16. </div>
  17. );
  18. }
  19. export default Thumbnail;