You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

225 lines
4.5 KiB
Vue

<script setup lang="ts">
import * as echarts from "echarts";
function initChart() {
const chartDom = document.getElementById("diggerDailyDistanceChart");
const mainChart = echarts.init(chartDom);
let data1 = [
{
name: "1日",
value: 175,
},
{
name: "2日",
value: 148,
},
{
name: "3日",
value: 195,
},
{
name: "4日",
value: 115,
},
{
name: "5日",
value: 148,
},
{
name: "6日",
value: 95,
},
{
name: "7日",
value: 56,
},
{
name: "8日",
value: 45,
},
{
name: "9日",
value: 15,
},
{
name: "10日",
value: 48,
},
{
name: "11日",
value: 95,
},
{
name: "12日",
value: 128,
},
{
name: "13日",
value: 34,
},
{
name: "14日",
value: 123,
},
{
name: "15日",
value: 175,
},
{
name: "16日",
value: 148,
},
];
let xAxisData = [];
let seriesData2 = [];
data1.forEach((item) => {
xAxisData.push(item.name);
seriesData2.push(item.value);
});
let option = {
tooltip: {
textStyle: {
color: "#000",
},
padding: [10, 10],
trigger: "axis",
backgroundColor: "#fff",
borderColor: "rgba(112, 119, 242, 0.8)",
borderWidth: 1,
},
grid: {
left: "2%",
right: "0%",
bottom: "5%",
containLabel: true,
},
toolbox: {
show: false,
},
xAxis: {
type: "category",
data: xAxisData,
axisLine: {
show: false,
},
axisTick: {
show: false,
},
splitLine: {
show: false,
},
axisLabel: {
color: "#B4C0CC",
},
},
yAxis: [
{
type: "value",
axisLine: {
show: false,
},
axisTick: {
show: false,
},
splitLine: {
lineStyle: {
color: "#35414D",
type: "dashed",
},
},
axisLabel: {
color: "#B4C0CC",
},
},
],
series: [
{
type: "line",
data: seriesData2,
symbolSize: 10,
symbol: "circle",
smooth: false,
yAxisIndex: 0,
label: {
show: false,
// textStyle: {
// color: "#FFD15C",
// fontSize: 20,
// fontFamily: "DIN",
// fontWeight: "bold",
// },
position: "top",
formatter: function (p) {
return p.value > 0 ? p.value : "";
},
},
lineStyle: {
width: 2,
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: "rgba(255, 209, 92, 1)",
},
{
offset: 1,
color: "rgba(255, 209, 92, 1)",
},
]),
shadowColor: "rgba(255, 209, 92, 0.4)",
shadowBlur: 10,
shadowOffsetY: 10,
},
itemStyle: {
normal: {
color: "rgba(255, 209, 92, 1)",
borderColor: "",
borderWidth: 3,
shadowColor: "rgba(255, 209, 92, 01)",
shadowBlur: 5,
},
},
// areaStyle: {
// //区域填充样式
// normal: {
// //线性渐变前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是true则该四个值是绝对像素位置。
// color: new echarts.graphic.LinearGradient(
// 0,
// 0,
// 0,
// 1,
// [
// {
// offset: 0,
// color: "rgba(165, 170, 247, 1)",
// },
// {
// offset: 0.5,
// color: "rgba(165, 170, 247, 0.2)",
// },
// {
// offset: 1,
// color: "rgba(165, 170, 247, 0)",
// },
// ],
// false
// ),
// shadowBlur: 0, //shadowBlur设图形阴影的模糊大小。配合shadowColor,shadowOffsetX/Y, 设置图形的阴影效果。
// },
// },
},
],
};
mainChart.setOption(option);
}
onMounted(() => {
initChart();
});
</script>
<template>
<div id="diggerDailyDistanceChart" style="width: 100%; height: 100%"></div>
</template>