import * as echarts from 'echarts/core'
import { BarChart, } from 'echarts/charts'
import {
  AriaComponent,
  GridComponent,
  LegendComponent,
  TooltipComponent
} from 'echarts/components'
import { SVGRenderer } from 'echarts/renderers'

import type { App } from 'vue'

const install = (_: App): void => {
  echarts.use([
    TooltipComponent,
    GridComponent,
    BarChart,
    SVGRenderer,
    LegendComponent,
    AriaComponent
  ])
}
export default {install}

export function useEcharts(el: HTMLElement | string) {
  if (typeof el === 'string') {
    el = document.getElementById(el) as HTMLElement
  }
  return echarts.init(el)
}


