最近再学习react,今天写了react中使用echarts,现在分享给各人,希望对您能有所帮助!欠好的话,勿喷!!!
代码如下:
- import React, { Component } from 'react'import * as echarts from 'echarts'export default class Statics extends Component { state = { data: [820, 563, 903, 743, 678, 873, 467] } initCharts = () => { let myChart = echarts.init(document.getElementById('myChart')); myChart.setOption({ title: { text: '测试' }, tooltip: { trigger: 'axis' }, xAxis: { type: 'category', data: [1, 2, 3, 4, 5, 6, 7] }, yAxis: { type: 'value' }, series: [{ data: this.state.data, type: 'line' }] }); window.addEventListener("resize", function () { myChart.resize(); }) } componentDidMount() { this.initCharts(); } render() { return (
-
- ) }}
复制代码
来源:https://blog.csdn.net/qq_39436399/article/details/111919858
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |