index.jsx 610 B

1234567891011121314151617181920212223
  1. import { defineComponent, ref, onMounted, watch } from 'vue'
  2. import * as echarts from 'echarts'
  3. import './common.less'
  4. import { isEmptyObject } from '@cip/utils/util'
  5. export default defineComponent({
  6. name: 'CipCharts',
  7. props: {
  8. options: Object
  9. },
  10. setup (props) {
  11. const dom = ref()
  12. onMounted(() => {
  13. const chartInstance = echarts.init(dom.value)
  14. watch(() => props.options, (val) => {
  15. if (!isEmptyObject(val)) chartInstance.setOption(val)
  16. }, { immediate: true, deep: true })
  17. })
  18. return () => (
  19. <div ref={dom} class={'cip-chart-wrapper'}/>
  20. )
  21. }
  22. })