当前位置:网站首页>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>
);
}
边栏推荐
- Dichotomy queries values in an array
- 2、Citrix Virtual Apps and Desktops 2203剪贴板重定向策略
- What are the precautions for using carbon brushes
- Relative positioning
- 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...)
- Intranet penetration based on FRP -- SSH Remote connection to intranet server with the help of public server
- Have you understood these 30 questions of enabling financial risk control plus points
- 3D laser slam:aloam---ceres optimization part and code analysis
- 力扣 1480. 一维数组的动态和 383. 赎金信412. Fizz Buzz
- How to debug JNI program
猜你喜欢

Realize the disk partition and file system mount of the newly added hard disk

js基础知识整理之 —— 数组

MFC FTP创建多级文件夹、上传文件到FTP指定目录

初学者入门:使用WordPress搭建一个专属自己的博客

Li Kou 1480. Dynamic sum of one-dimensional array 383. Ransom letter 412. Fizz buzz

Intranet penetration based on FRP -- SSH Remote connection to intranet server with the help of public server

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

JS basic knowledge collation - array
![51: Chapter 5: develop admin management services: 4: develop [add admin account, interface]; (only [user name + password, method]; [@t...] annotation controls transactions; when setting cookies, do yo](/img/6f/4f93eca1d923a58b2ef4b1947538be.png)
51: Chapter 5: develop admin management services: 4: develop [add admin account, interface]; (only [user name + password, method]; [@t...] annotation controls transactions; when setting cookies, do yo

赋能金融风控加分项的这30个问题,您都搞懂了吗
随机推荐
二分法查询数组中的值
利用eBPF探测Rootkit漏洞
clearfix的作用
能说一说 Kotlin 中 lateinit 和 lazy 的区别吗?
Application of responsibility chain model in transfer accurate valuation
Perfect guide | how to use ODBC for agent free Oracle database monitoring?
Bank case | ZABBIX cross version upgrade guide, isn't 4.2-6.0 popular?
滑环的分类以及用途
51:第五章:开发admin管理服务:4:开发【新增admin账号,接口】;(只开发了【用户名+密码的,方式】;【@T…】注解控制事务;设置cookie时,是否需要使用URLEncoder去编码;)
Qt剪切板QClipboard 复制粘贴自定义数据
Method of changing thread state
Seata 在蚂蚁国际银行业务的落地实践
Interface testing practical tutorial 01: interface testing environment construction
evutil_make_internal_pipe_: pipe: Too many open files
@Simple use of conditional
高度塌陷和BFC
16-VMware Horizon 2203 虚拟桌面-Win10 自动桌面池完整克隆专用(十六)
v-text
v-show
Tencent cloud and the China Federation of industry released the research results of industrial AI quality inspection standardization to accelerate the intelligent transformation of manufacturing indus