apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.66k stars 19.61k forks source link

[Typescript] `CategoryAxisBaseOption` is no exported in echarts #17306

Open lankerxd opened 2 years ago

lankerxd commented 2 years ago

What problem does this feature solve?

the problem is 'CategoryAxisBaseOption' interface is no exported,and I want to write such code , like this :

import { CategoryAxisBaseOption, EChartsOption } from 'echarts'
let xAxisData: CategoryAxisBaseOption = ['xAxis1', 'xAxis2']
const chartOption: EChartsOption = {
    xAxis: {
      data: xAxisData,
    },
 }

so what should I do , and why not export CategoryAxisBaseOption。 The real reason for this is package component in Vue , the xAxisData is prop define in Vue component。

What does the proposed API look like?

I don't know how to do it.

lankerxd commented 2 years ago

I made other attempts, but also encountered problems,for example:

import { EChartsOption } from 'echarts' 
const extraOption: EChartsOption = {
    xAxis: {
      data: [],
    },
  }

const xAxisDataIsTooMuch = () => {
  return extraOption.xAxis!.data.length > 6
}

data is error : Property does not exist on type XAXisOption | XAXisOption[]. continue, I know XAXisOption is export as XAXisComponentOption , code:

import {  EChartsOption,XAXisComponentOption } from 'echarts' 
const extraOption: EChartsOption = {
    xAxis: {
      data: [],
    },
  }

const xAxisDataIsTooMuch = () => {
    if (Array.isArray(extraOption.xAxis)) {
      const xAxis: XAXisComponentOption[] = extraOption.xAxis
      return xAxis[0]!.data.length > 6
    } else {
      const xAxis: XAXisComponentOption = extraOption.xAxis!
      return xAxis.data.length > 6
    }
  }

data is error too , I see the source code,The reason for the problem may be that AxisBaseOption have too much interface. but the example is success :

import {  XAXisComponentOption } from 'echarts' 
const xAxisData: XAXisComponentOption = {
    data: [],
  }
xAxisData.data
kaka59 commented 1 year ago

I have also encountered this problem. Is there any repair methods available?