wuba / react-native-echarts

📈 React Native ECharts Library: An awesome charting library for React Native, built upon Apache ECharts and leveraging react-native-svg and react-native-skia. Offers significantly better performance compared to WebView-based solutions.
https://wuba.github.io/react-native-echarts/
Apache License 2.0
755 stars 25 forks source link

Heatmap always giving 'Heatmap must use with visualMap' error even though we provided visual map. #99

Closed Manikanta-GEP closed 1 year ago

Manikanta-GEP commented 1 year ago

Heatmap always giving 'Heatmap must use with visualMap' error even though we provided visual map.

import React, {useRef, useEffect} from 'react'; import {StyleSheet} from 'react-native'; import as echarts from 'echarts/core'; import as Echarts from 'echarts/charts'; import {GridComponent} from 'echarts/components'; import {SVGRenderer, SvgChart} from '@wuba/react-native-echarts';

// LineChart, BarChart, PieChart, ScatterChart, RadarChart, MapChart, TreeChart, TreemapChart, GraphChart, GaugeChart, FunnelChart, ParallelChart, SankeyChart, BoxplotChart, CandlestickChart, EffectScatterChart, LinesChart, HeatmapChart, PictorialBarChart, ThemeRiverChart, SunburstChart, CustomChart echarts.use([SVGRenderer, Echarts.HeatmapChart, GridComponent]);

const HeatMap = props => { const {styles} = props?.data; const {height = 320, width = 320} = styles; const skiaRef = useRef(null); useEffect(() => { function getVirtualData(year) { const date = +echarts.time.parse(year + '-01-01'); const end = +echarts.time.parse(+year + 1 + '-01-01'); const dayTime = 3600 24 1000; const data = []; for (let time = date; time < end; time += dayTime) { data.push([echarts.time.format(time, '{yyyy}-{MM}-{dd}', false), Math.floor(Math.random() * 10000)]); } return data; } const option = { title: { top: 30, left: 'center', text: 'Daily Step Count', }, tooltip: {}, visualMap: { min: 0, max: 10000, type: 'piecewise', orient: 'horizontal', left: 'center', top: 65, }, calendar: { top: 120, left: 30, right: 30, cellSize: ['auto', 13], range: '2016', itemStyle: { borderWidth: 0.5, }, yearLabel: {show: false}, }, series: { type: 'heatmap', coordinateSystem: 'calendar', data: getVirtualData('2016'), }, }; let chart; if (skiaRef.current) { chart = echarts.init(skiaRef.current, 'light', { renderer: 'svg', width: width, height: height, }); chart.setOption(option); } return () => chart?.dispose(); }, []);

return ; };

export default HeatMap;

const styles = StyleSheet.create({});

Expected behavior Need to render heat map.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

zhiqingchen commented 1 year ago
import {
  VisualMapComponent,
} from 'echarts/components';

echarts.use([
  VisualMapComponent,
]);
Manikanta-GEP commented 1 year ago

Thanks for the response @zhiqingchen ,

import React, {useRef, useEffect} from 'react'; import {StyleSheet} from 'react-native'; import * as echarts from 'echarts/core'; import {TooltipComponent, GridComponent, VisualMapComponent} from 'echarts/components'; import {HeatmapChart} from 'echarts/charts'; import {SVGRenderer, SvgChart} from '@wuba/react-native-echarts';

echarts.use([TooltipComponent, GridComponent, VisualMapComponent, HeatmapChart, SVGRenderer]);

Issue still there.

Manikanta-GEP commented 1 year ago

I am using these versions "@wuba/react-native-echarts": "1.2.2", "echarts": "5.4.3",

Manikanta-GEP commented 1 year ago

@zhiqingchen , Thanks for the help, By restating metro bundler, it worked.