import styles from './index.less';import fullScreen from '@sl-theia/full-screen';import { useState, useEffect, useRef } from 'react';// import { useSocket } from '@sl-theia/theia-socket-io-client';import * as echarts from 'echarts';import Title from '@/components/Title';const titlesData = [ { name: '强农产业', spell: 'Strengthening agricultural industry' },]const Industry = ((props: any) => { const barChartRef = useRef<HTMLDivElement>(null); useEffect(()=>{ chart(); },[]); const chart = ()=>{ const {current} = barChartRef; if(current){ let myChart = echarts.init(current,undefined); myChart.setOption({ }) } } return (<> <div className={styles.leftItem}> <Title data={titlesData[0]}></Title> <div ref={barChartRef} className={styles.barChart} style={{ width: '100%', height: '100%' }}></div> </div> </> )})export default Industry
柱状图间隔颜色
itemStyle: { color: function(params:any) { var colorList = [ [ { offset: 0, color: 'rgba(0,204,255, 0.1)', // 0% 处的颜色 }, { offset: 0.5, color: 'rgba(0,204,255, 0.5)', // 100% 处的颜色 }, { offset: 1, color: 'rgba(0,204,255)', // 100% 处的颜色 }], [ { offset: 0, color: 'rgba(249, 191, 0, 0.1)', // 0% 处的颜色 }, { offset: 0.5, color: 'rgba(249, 191, 0, 0.5)', // 100% 处的颜色 }, { offset: 1, color: '#FFCC00', // 100% 处的颜色 }] ]; return new echarts.graphic.LinearGradient(0,0,0,1,colorList[(params.dataIndex)%2]) } },