0
点赞
收藏
分享

微信扫一扫

深度学习入门指南(1) - 从chatgpt入手

上善若水山西太原 2024-08-12 阅读 26

实现的代码如下:

import * as echarts from 'echarts'
import { useEffect, useRef } from 'react';
const Home = ()=>{
  const chartRef = useRef(null);
  useEffect(()=>{
    // const chartDom = document.getElementById('main');//使用id获取节点
    const chartDom = chartRef.current;//使用useRef获取节点
    const myChart = echarts.init(chartDom);
    const option = {
      xAxis: {
        type: 'category',
        data: ['vue', 'react', 'angular']
      },
      yAxis: {
        type: 'value'
      },
      series: [
        {
          data: [100, 150, 50],
          type: 'bar'
        }
      ]
    };

    option && myChart.setOption(option);
  },[])
  return (
    <div> 
      <div id='main' ref={chartRef} style={{width:'500px',height:'400px'}}></div>
    </div>
    )
}

export default Home

举报

相关推荐

0 条评论