当前位置:网站首页>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>
);
}
边栏推荐
- PAT乙级 1109 擅长C(详解)
- js将数组根据指定属性值分组成二维数组
- 电气成套企业如何借助ERP系统,做好成本利润管理?
- evutil_make_internal_pipe_: pipe: Too many open files
- 2022年7月24日 暑假第二周训练
- 面试官常问:如何手撸一个“消息队列”和“延迟消息队列”?
- Interface testing practical tutorial 01: interface testing environment construction
- Method of changing thread state
- 7-16 daily sword finger offer II 041. Average value of sliding window
- 写出一个程序,接受一个有字母和数字以及空格组成的字符串,和一个字符,然后输出输入字符串中含有该字符的个数。不区分大小写。
猜你喜欢

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

OPPO 自研大规模知识图谱及其在数智工程中的应用

Deliver temperature with science and technology, vivo appears at the digital China Construction Summit

MFC FTP creates multi-level folders and uploads files to the specified directory of FTP

W3school navigation bar exercise

How to debug JNI program

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

What should I do if I can't see any tiles on SAP Fiori launchpad?

js将数组根据指定属性值分组成二维数组

Initializing database error after reinstalling MySQL
随机推荐
Differences between shell environment variables and set, env, export
Verilog的系统任务----$fopen、$fclose和$fdisplay, $fwrite,$fstrobe,$fmonitor
Feign's overall process
相对定位
QT clipboard qclipboard copy paste custom data
A brief analysis of the four process pools
力扣 1480. 一维数组的动态和 383. 赎金信412. Fizz Buzz
附加:【URLEncoder.encode(待编码字符串, “编码方式“);】(是什么?;我们向cookie中设置值的时候,为什么要使用这个去编码?)(待完善……)
What should I do if I can't see any tiles on SAP Fiori launchpad?
文本样式
Text style
Cute image classification -- a general explanation of the article "what are the common flops in CNN model?"
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...)
滑环使用如何固定
赋能金融风控加分项的这30个问题,您都搞懂了吗
【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(九)
马斯克被曝绿了谷歌创始人:导致挚友二婚破裂,曾下跪求原谅
OPPO 自研大规模知识图谱及其在数智工程中的应用
产品经理经验谈100篇(十一)-策略产品经理:模型与方法论
Rotation chart