|
@@ -1,15 +1,96 @@
|
|
import { onMount } from "solid-js";
|
|
import { onMount } from "solid-js";
|
|
-import { Chart } from '@antv/g2';
|
|
|
|
|
|
+import { Chart, registerShape } from '@antv/g2';
|
|
// import DataSet from '@antv/data-set';
|
|
// import DataSet from '@antv/data-set';
|
|
|
|
|
|
import "../../../assets/style/BigScreenHome.css"
|
|
import "../../../assets/style/BigScreenHome.css"
|
|
|
|
|
|
|
|
+let cli1 = [
|
|
|
|
+ "135,206,250",
|
|
|
|
+ "0,191,255",
|
|
|
|
+ "127,255,170",
|
|
|
|
+ "0,255,127",
|
|
|
|
+ "50,205,50",
|
|
|
|
+ "240,230,140",
|
|
|
|
+ "255,215,0",
|
|
|
|
+ "255,127,80",
|
|
|
|
+ "255,99,71",
|
|
|
|
+ "255,0,0",
|
|
|
|
+], index = 0;
|
|
|
|
+// 绘制柱状图顶部
|
|
|
|
+registerShape('interval', 'triangle', {
|
|
|
|
+ // 1. 定义关键点
|
|
|
|
+ getPoints(cfg) {
|
|
|
|
+ const x = cfg.x;
|
|
|
|
+ const y = cfg.y;
|
|
|
|
+ const width = cfg.size;
|
|
|
|
+ return [
|
|
|
|
+ { x: x - width / 2, y },
|
|
|
|
+ { x, y: y + width*2 },
|
|
|
|
+ { x: x + width / 2, y },
|
|
|
|
+ { x, y: y - width*2 },
|
|
|
|
+ ];
|
|
|
|
+ },
|
|
|
|
+ // 2. 绘制
|
|
|
|
+ draw(cfg, group) {
|
|
|
|
+ const points = this.parsePoints(cfg.points); // 将0-1空间的坐标转换为画布坐标
|
|
|
|
+ const polygon = group.addShape('path', {
|
|
|
|
+ attrs: {
|
|
|
|
+ path: [
|
|
|
|
+ ['M', points[0].x, points[0].y],
|
|
|
|
+ ['L', points[1].x, points[1].y],
|
|
|
|
+ ['L', points[2].x, points[2].y],
|
|
|
|
+ ['L', points[3].x, points[3].y],
|
|
|
|
+ ],
|
|
|
|
+ fillOpacity: 0.95,
|
|
|
|
+ fill: `l(90) 0:rgb(${cli1[index % cli1.length]}) 1:rgba(${cli1[index % cli1.length]}, 0.8)`
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ index++
|
|
|
|
+ return polygon;
|
|
|
|
+ },
|
|
|
|
+})
|
|
|
|
+// 绘制柱状图楞线
|
|
|
|
+registerShape('interval', 'edgeLine', {
|
|
|
|
+ // 1. 定义关键点
|
|
|
|
+ getPoints(cfg) {
|
|
|
|
+ const x = cfg.x;
|
|
|
|
+ const y = cfg.y;
|
|
|
|
+ const y0 = cfg.y0;
|
|
|
|
+ const width = cfg.size;
|
|
|
|
+ const p1 = (width / 100).toFixed(4) - 0
|
|
|
|
+ return [
|
|
|
|
+ { x: x - p1, y: y - width / 2 },
|
|
|
|
+ { x: x + p1, y: y - width / 2 },
|
|
|
|
+ { x: x + p1, y: y0 },
|
|
|
|
+ { x: x - p1, y: y0 },
|
|
|
|
+ ];
|
|
|
|
+ },
|
|
|
|
+ // 2. 绘制
|
|
|
|
+ draw(cfg, group) {
|
|
|
|
+ const points = this.parsePoints(cfg.points); // 将0-1空间的坐标转换为画布坐标
|
|
|
|
+ const polygon = group.addShape('path', {
|
|
|
|
+ attrs: {
|
|
|
|
+ path: [
|
|
|
|
+ ['M', points[0].x, points[0].y],
|
|
|
|
+ ['L', points[1].x, points[1].y],
|
|
|
|
+ ['L', points[2].x, points[2].y],
|
|
|
|
+ ['L', points[3].x, points[3].y],
|
|
|
|
+ ],
|
|
|
|
+ fillOpacity: 1,
|
|
|
|
+ fill: `l(90) 0:rgba(${cli1[index % cli1.length]}, 1) 1:rgba(${cli1[index % cli1.length]}, 0.4)`
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ index++
|
|
|
|
+ return polygon;
|
|
|
|
+ },
|
|
|
|
+})
|
|
|
|
+
|
|
function Column(prop) {
|
|
function Column(prop) {
|
|
let $canvas = undefined;
|
|
let $canvas = undefined;
|
|
function TrendChart(width, height, $canvas) {
|
|
function TrendChart(width, height, $canvas) {
|
|
- const data = prop.list.map(v=> {
|
|
|
|
|
|
+ const data = prop.list.map(v => {
|
|
return {
|
|
return {
|
|
- type: v.scheduleName,
|
|
|
|
|
|
+ type: v.scheduleName,
|
|
value: v.watchRate
|
|
value: v.watchRate
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -37,13 +118,13 @@ function Column(prop) {
|
|
formatter: n => {
|
|
formatter: n => {
|
|
const nl = n.split(""), len = nl.length > 6 ? 5 : nl.length, out = [];
|
|
const nl = n.split(""), len = nl.length > 6 ? 5 : nl.length, out = [];
|
|
for (let i = 0; i < len; i++) {
|
|
for (let i = 0; i < len; i++) {
|
|
- if(i%3 !== 2 || i === len - 1) {
|
|
|
|
|
|
+ if (i % 3 !== 2 || i === len - 1) {
|
|
out.push(nl[i]);
|
|
out.push(nl[i]);
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
out.push(nl[i] + '\n');
|
|
out.push(nl[i] + '\n');
|
|
}
|
|
}
|
|
- if(nl.length <= 6) return out.join("")
|
|
|
|
|
|
+ if (nl.length <= 6) return out.join("")
|
|
else return out.join("") + "..."
|
|
else return out.join("") + "..."
|
|
},
|
|
},
|
|
style: {
|
|
style: {
|
|
@@ -55,19 +136,11 @@ function Column(prop) {
|
|
|
|
|
|
chart.tooltip(false);
|
|
chart.tooltip(false);
|
|
|
|
|
|
- chart.interval().position('type*value').color('type',[
|
|
|
|
- '#87CEFA',
|
|
|
|
- '#00BFFF',
|
|
|
|
- '#7FFFAA',
|
|
|
|
- '#00FF7F',
|
|
|
|
- '#32CD32',
|
|
|
|
- '#F0E68C',
|
|
|
|
- '#FFD700',
|
|
|
|
- '#FF7F50',
|
|
|
|
- '#FF6347',
|
|
|
|
- '#FF0000'
|
|
|
|
- ]);
|
|
|
|
- chart.interaction('element-active');
|
|
|
|
|
|
+ chart.interval().position('type*value').color('type', cli1.map(v => `l(90) 0:rgba(${v},0.8) 1:rgba(${v},0.2)`));
|
|
|
|
+ index = 0;
|
|
|
|
+ chart.interval().position('type*value').shape('triangle');
|
|
|
|
+ index = 0;
|
|
|
|
+ chart.interval().position('type*value').shape('edgeLine');
|
|
|
|
|
|
// 添加文本标注
|
|
// 添加文本标注
|
|
data.forEach((item) => {
|
|
data.forEach((item) => {
|