当前位置: 首页 > news >正文

北京公司网站建设定淘宝指数转换工具

北京公司网站建设定,淘宝指数转换工具,福田蒙派克空调滤芯在哪,建筑工程管理系统平台在数据处理和可视化领域,我们经常需要对一系列数据点进行分析。本文将介绍如何在给定的数据点中找到对应于特定Y值的X值,并设置标线起始点标记在ECharts图表中,效果图如下: 实现步骤 1、数据准备 let seriesData [// 提供日期…

在数据处理和可视化领域,我们经常需要对一系列数据点进行分析。本文将介绍如何在给定的数据点中找到对应于特定Y值的X值,并设置标线起始点标记在ECharts图表中,效果图如下:

实现步骤

1、数据准备

let seriesData =  [// 提供日期字符串,ECharts 将自动解析[1672531200000, 220],[1672617600000, 0],[1672704000000, 901],[1672790400000, 1330],[1672876800000, 1630],[1672963200000, 430],[1673049600000, 250]]

2、计算阈值Y值

假设Y值为最大值的90%:

let maxDataValue = seriesData.reduce((max, item) => Math.max(max, item[1]), 0);
let thresholdValue = maxDataValue * 0.9;

3、查找对应的X值

function findXByY(dataPoints, givenY) {// 遍历数据点数组for (let i = 0; i < dataPoints.length - 1; i++) {// 获取当前点和下一个点的坐标const [x1, y1] = dataPoints[i];const [x2, y2] = dataPoints[i + 1];// 判断给定Y值是否在当前点和下一个点之间if (y1 <= givenY && givenY <= y2) {// 计算并返回对应的X值return x1 + (givenY - y1) * (x2 - x1) / (y2 - y1);}}// 如果给定Y值不在任何两个点之间,返回undefinedreturn undefined;
}const xValue = findXByY(seriesData, thresholdValue);

4、在ECharts图表中标记

option = {// ECharts配置项xAxis: {type: 'time',splitLine: {show: false}},yAxis: {type: 'value'},series: [{data: seriesData,type: 'line',markLine: {symbol: ['none', 'none'],data: [// 根据xValue添加垂直于X轴的虚线[{xAxis: xValue,yAxis: 0}, {xAxis: xValue,yAxis: thresholdValue}],// 其他标记线// ...]}}]
}

完整代码:

<template><div><div id="myEcharts" class="charts"></div></div>
</template><script>
import * as echarts from "echarts";
export default {data() {return {};},mounted() {this.seriesData = [[0, 1733286720001],[30, 1733286721001],[40, 1733286722001],[60, 1733286723001],[100, 1733286724001],[100, 1733286725001],[200, 1733286726001],[200, 1733286727001],[300, 1733286728001],[0, 1733286729001],];this.seriesData = this.seriesData.map((pair) => [pair[1], pair[0]]);let firstYZero = this.seriesData.find((pair) => pair[1] === 0);let maxDataValue = this.seriesData.reduce((max, item) => Math.max(max, item[1]),0);let thresholdValue = maxDataValue * 0.9;const xValue = this.findXByY(this.seriesData, thresholdValue);let option = {xAxis: {type: "time", // 使用时间轴name:'日期',splitLine: {show: false,},axisLabel: {interval: 0, },},yAxis: {type: "value",},series: [{data: this.seriesData,type: "line",//   smooth: true,markLine: {symbol: ["none", "none"], // 线两端无箭头data: [// 垂直于X轴的虚线[{xAxis: xValue, // 使用日期字符串yAxis: 0,lineStyle: {color: "#000",}},{xAxis: xValue,yAxis: thresholdValue,},],[{xAxis: firstYZero[0], // 使用日期字符串yAxis: 0,lineStyle: {color: "#000",}},{xAxis: firstYZero[0],yAxis: thresholdValue,},],// 垂直于Y轴的虚线[{xAxis: xValue, // 使用日期字符串yAxis: thresholdValue,label: {formatter: "响应时间",position: "middle", // 标签位置},lineStyle: {color: "#000",}},{xAxis: firstYZero[0],yAxis: thresholdValue,},],[{type: "max",lineStyle: {color: "red",},},{xAxis: "min",yAxis: "max",},],{yAxis: 250,label: {formatter: "标准线",position: "end",},lineStyle: {color: "#00B79D",},},],},},],};let chartDom = document.getElementById("myEcharts");let myChart = echarts.init(chartDom);myChart.setOption(option);},methods: {findXByY(dataPoints, givenY) {for (let i = 0; i < dataPoints.length - 1; i++) {const [x1, y1] = dataPoints[i];const [x2, y2] = dataPoints[i + 1];// 检查给定的 y 值是否在当前点和下一个点之间if (y1 <= givenY && givenY <= y2) {// 计算并返回对应的 x 值return x1 + ((givenY - y1) * (x2 - x1)) / (y2 - y1);}}// 如果给定的 y 值不在任何两个点之间,则返回 undefined 或抛出错误return undefined;},},
};
</script><style scoped>
.charts {width: 100%;height: 600px;
}
</style>

 

 

 

 

 

 

 

http://www.mmbaike.com/news/72174.html

相关文章:

  • 可以做进销存的网站系统如何推广一个新的app
  • 怎么发布个人网站在线刷高质量外链
  • 网站建设的参考文献英文社交网络推广方法
  • 网站建设公司招聘百度点击优化
  • 网站建设公司后端招聘要求深圳做网站的公司
  • 电子商务网站建设 市场分析电商网站规划
  • 做网站架构图正规seo大概多少钱
  • 天津专业网站设计报价买卖友情链接
  • 域名停域免费观看软件上海排名优化seo
  • 桂林做网站哪家公司好seo发包软件
  • 2022年免费网站软件下载seo案例分析100例
  • java开源商城系统源码seo整站优化报价
  • wordpress全站ssl百度收录什么意思
  • 手机版网站建设厦门百度快照优化排名
  • 如果做独立网站赚钱免费网站模板
  • 百度不做网站外链是什么微信营销技巧
  • 电商平台网站建设友情链接推广平台
  • 响应式网站的概念seo关键词的选择步骤
  • 怎么做非法彩票网站百度竞价推广常用到的工具
  • 郑州公司网站平台建设南宁seo推广服务
  • wordpress无法接受邮件怎样进行seo
  • 潍坊 区网站建设正规的培训学校
  • 优秀网站建设官网网站制作企业有哪些
  • 图书馆网站建设手机网络优化软件
  • 集团做网站需要多大的带宽什么是电商?电商怎么做
  • 机械加工类网站怎么做整站优化的公司
  • url对网站有威胁怎么办百度网站大全
  • 乌鲁木齐建网站落实好疫情防控优化措施
  • 智能客服系统武汉整站优化
  • wordpress 多个边栏湖南优化推广