[Typescript] CategoryAxisBaseOption is no exported in echarts

nx7onnlm  于 8个月前  发布在  Echarts
关注(0)|答案(2)|浏览(265)

What problem does this feature solve?

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

  1. import { CategoryAxisBaseOption, EChartsOption } from 'echarts'
  2. let xAxisData: CategoryAxisBaseOption = ['xAxis1', 'xAxis2']
  3. const chartOption: EChartsOption = {
  4. xAxis: {
  5. data: xAxisData,
  6. },
  7. }

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.

dbf7pr2w

dbf7pr2w1#

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

  1. import { EChartsOption } from 'echarts'
  2. const extraOption: EChartsOption = {
  3. xAxis: {
  4. data: [],
  5. },
  6. }
  7. const xAxisDataIsTooMuch = () => {
  8. return extraOption.xAxis!.data.length > 6
  9. }

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

  1. import { EChartsOptionXAXisComponentOption } from 'echarts'
  2. const extraOption: EChartsOption = {
  3. xAxis: {
  4. data: [],
  5. },
  6. }
  7. const xAxisDataIsTooMuch = () => {
  8. if (Array.isArray(extraOption.xAxis)) {
  9. const xAxis: XAXisComponentOption[] = extraOption.xAxis
  10. return xAxis[0]!.data.length > 6
  11. } else {
  12. const xAxis: XAXisComponentOption = extraOption.xAxis!
  13. return xAxis.data.length > 6
  14. }
  15. }

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 :

  1. import { XAXisComponentOption } from 'echarts'
  2. const xAxisData: XAXisComponentOption = {
  3. data: [],
  4. }
  5. xAxisData.data
展开查看全部
n3h0vuf2

n3h0vuf22#

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

相关问题