Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xAxis "0" not found error #1

Closed
akshgods opened this issue Jan 11, 2023 · 1 comment
Closed

xAxis "0" not found error #1

akshgods opened this issue Jan 11, 2023 · 1 comment

Comments

@akshgods
Copy link

Your example i copied, and getting this error
xAxis "0" not found

import * as React from 'react';
import {useEffect, useRef} from 'react';

import {StyleSheet, View, Dimensions} from 'react-native';
import {SVGRenderer, SkiaChart} from 'wrn-echarts';
import * as echarts from 'echarts/core';
import {BarChart} from 'echarts/charts';
import {TitleComponent, TooltipComponent} from 'echarts/components';

// register extensions
echarts.use([
  TitleComponent,
  TooltipComponent,
  SVGRenderer,
  // ...
  BarChart,
]);

const E_HEIGHT = 250;
const E_WIDTH = Dimensions.get('screen').width;

function SkiaComponent({option}: any) {
  const skiaRef = useRef<any>(null);

  useEffect(() => {
    let chart: any;
    if (skiaRef.current) {
      // @ts-ignore
      chart = echarts.init(skiaRef.current, 'light', {
        renderer: 'svg',
        width: E_WIDTH,
        height: E_HEIGHT,
      });
      chart.setOption(option);
    }
    return () => chart?.dispose();
  }, [option]);

  return <SkiaChart ref={skiaRef} />;
}

const option = {
  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',
    },
  ],
};
export default function GrowthDetails() {
  return (
    <View style={styles.container}>
      <SkiaComponent option={option}></SkiaComponent>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  box: {
    width: 60,
    height: 60,
    marginVertical: 20,
  },
});

Error Screen Shot

Simulator Screen Shot - iPhone 13 Pro - 2023-01-11 at 13 24 51

@zhiqingchen
Copy link
Member

GridComponent needs to be used, example has been updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants