Skip to content

witChart Chart Component ​

witChart is a Vue chart component based on ECharts, supports multiple chart types and interaction methods, provides custom themes and flexible configuration options. The component integrates ECharts core functionality internally, supports both Canvas and SVG rendering methods, can be flexibly switched according to needs.

Usage Example ​

vue
<template>
  <div style="width: 600px; height: 400px;">
    <witChart
      ref="witChartRef"
      :option="chartOption"
      :autoresize="true"
      :renderer="'CanvasRenderer'"
      @click="handleChartClick"
      @highlight="handleChartHighlight"
    />
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'

const witChartRef = ref<any>(null)
const chartOption = ref({
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [120, 200, 150, 80, 70, 110, 130],
      type: 'bar'
    }
  ]
})

const handleChartClick = (event: any) => {
  console.log('Chart clicked:', event)
}

const handleChartHighlight = (action: any) => {
  console.log('Chart highlighted:', action)
}

// Call component methods
const resizeChart = () => {
  witChartRef.value.resize()
}

const clearChart = () => {
  witChartRef.value.clear()
}
</script>

API ​

Property NameTypeDefault ValueDescription
option[Object]() => {}ECharts configuration, see ECharts documentation for details
autoresize[Boolean]trueWhether to auto resize
renderer[String]'CanvasRenderer'Rendering method, options: 'CanvasRenderer' or 'SVGRenderer'

Method ​

MethodDescriptionParameters
resizeResize chart
clearClear chart content
disposeDestroy chart instance
getWidthGet chart width
getHeightGet chart height

Events ​

湘ICP备2024070110号