当前位置:网站首页>Echart line chart displays the last point and vertical dotted line by default
Echart line chart displays the last point and vertical dotted line by default
2022-07-27 13:37:00 【hzxOnlineOk】
First on the renderings :

Code :
import {
useEffect, useState } from 'react';
import * as echarts from 'echarts';
export default function Line(props) {
const xdatas = props.xdata || [];
const ydatas = props.ydata || [];
const idx = props.idx;
useEffect(() => {
const container = document.getElementById('lineContainer' + idx);
// Based on the prepared dom, initialization echarts example
var myChart = echarts.init(container);
let option = {
tooltip: {
trigger: 'axis',
},
toolbox: {
show: false,
feature: {
saveAsImage: {
}, // Display and provide the button to download the report image
},
},
xAxis: {
type: 'category',
boundaryGap: false,
show: true,
axisTick: {
show: false }, // x Axis scale hidden
data: xdatas,
},
yAxis: {
type: 'value',
boundaryGap: [0, '30%'],
show: true,
},
grid: {
// Move the position of the chart in the canvas
left: '17%',
},
series: [
{
type: 'line',
data: ydatas,
smooth: 0.5,
// symbol: 'none', // none Do not show data points The default is false Exhibition
lineStyle: {
color: '#5470C6',
width: 5,
},
itemStyle: {
normal: {
color: '#3d86f3',
lineStyle: {
color: '#3d86f3',
width: 3,
},
},
},
markLine: {
// Lock the last element to show the vertical dotted line
symbol: ['none', 'none'],
label: {
show: false },
data: [{
xAxis: ydatas.length - 1 }],
},
// markLine: {
// symbol: ['none', 'none'],
// // label: { show: false },
// data: [{ xAxis: ydatas[ydatas.length - 1], yAxis: 100 }, { xAxis: ydatas[ydatas.length - 1], yAxis: 100 }]
// },
markPoint: {
// Tagged data , It can be the maximum value, the minimum value or the custom coordinates
// data: [
// {
// yAxis: ydatas, // y The axis is the data axis , Then mark the data y Axis coordinates are the currently displayed data ,this.trenddata[1] Is all the data displayed , He's an array , Get the last data in the form of array subscript
// },
// ],
data: [
{
yAxis: ydatas[ydatas.length - 1], // y The axis is the data axis , Then mark the data y Axis coordinates are the currently displayed data ,this.trenddata[1] Is all the data displayed , He's an array , Get the last data in the form of array subscript
x: '90%',
// x: '90%', // Mark data x Position of the shaft , Because it is the last point , So this position is fixed , The position of the last point in the icon can be expressed as a percentage
},
],
symbol: 'circle', // Marking graphics
symbolSize: 4, // Mark the size of the graphic
// Style of dimension points
itemStyle: {
color: '#FF4747', // Mark some colors
},
},
areaStyle: {
// Area fill pattern
normal: {
// Linear gradient , front 4 The parameters are x0,y0,x2,y2( Range 0~1); Equivalent to the percentage in the graphics bounding box . If the last parameter is ‘true’, Then the four values are absolute pixel positions .
color: new echarts.graphic.LinearGradient(
0,
0,
0,
1,
[
{
offset: 0,
color: 'rgba(196, 215, 255, 1)',
},
{
offset: 1,
color: 'rgba(246, 249, 255, 1)',
},
],
false,
),
// shadowColor: "rgba(109, 126, 0, 0.5)", // Shadow color
shadowBlur: () => {
var windth = window.innerWidth;
let fontSize = windth / 1920;
return fontSize * 20;
}, //shadowBlur Set the blur size of the graphics shadow . coordination shadowColor,shadowOffsetX/Y, Set the shadow effect of the drawing .
},
},
},
],
};
// Use the configuration item and data display chart just specified .
myChart.setOption(option, true);
}, []);
return (
<div
id={
`lineContainer${
idx}`}
style={
{
width: '100%', height: 200, marginTop: -50 }}
></div>
);
}
边栏推荐
- Training in the second week of summer vacation on July 24, 2022
- Go语言系列:如何搭建Go语言开发环境?
- Set up SSH key based authentication using putty
- Talk about one of the important classes of feign components, reactivefeign
- Interview site: three kinds of questions
- 插入排序,正序,倒序
- 基于frp实现内网穿透——借助公网服务器实现ssh远程连接内网服务器
- 3D laser slam:aloam---ceres optimization part and code analysis
- Preliminary discussion on NetGen and Gmsh mesh generation of any multiple sub models of CAD based on osg+occ
- 接口测试实战教程01:接口测试环境搭建
猜你喜欢

JNI程序如何进行参数传递

电气成套企业如何借助ERP系统,做好成本利润管理?

Seata 在蚂蚁国际银行业务的落地实践

面试考点:三种图的问题

Sff1004-mhchxm diode sff1004

责任链模式在转转精准估价中的应用

52:第五章:开发admin管理服务:5:开发【分页查询admin账号列表,接口】;(Swagger的@ApiParam(),对方法参数进行注释;PageHelper分页插件;拦截器拦截检查登录状态)

马斯克被曝绿了谷歌创始人:导致挚友二婚破裂,曾下跪求原谅

Classification and application of slip rings
![52: Chapter 5: developing admin management services: 5: developing [paging query admin account list, interface]; (swagger's @apiparam(), annotate the method parameters; PageHelper paging plug-in; Inte](/img/08/1cc315d568673a3892c20bc1254d38.png)
52: Chapter 5: developing admin management services: 5: developing [paging query admin account list, interface]; (swagger's @apiparam(), annotate the method parameters; PageHelper paging plug-in; Inte
随机推荐
Application of responsibility chain model in transfer accurate valuation
7.26 simulation summary
C ftp add, delete, modify, query, create multi-level directory, automatic reconnection, switch directory
clear
A brief analysis of the four process pools
@Simple use of conditional
C# FTP增、删、改、查、创建多级目录、自动重连、切换目录
C语言犄角旮旯的知识之数组与函数
How to debug JNI program
MTK6765编译环境搭建
What are the precautions for using carbon brushes
计算字符串最后一个单词的长度,单词以空格隔开。
Training in the second week of summer vacation on July 24, 2022
Additional: [urlencoder.encode (string to be encoded, "encoding method");] (what is it?; why do we use this to encode when we set values in cookies?) (to be improved...)
W3school navigation bar exercise
相对定位
网络异常流量分析系统设计
Feign's dynamic proxy
绝对定位
Arrays and functions of knowledge in every corner of C language