Browse Source

modify some codes

master
xiaowuler 3 years ago
parent
commit
e2896db02c
  1. 3798
      04.系统编码/Frontend/package-lock.json
  2. 173
      04.系统编码/Frontend/src/components/RamanLidar.vue
  3. 20
      04.系统编码/Frontend/src/model/custome-array.ts
  4. 367
      04.系统编码/Frontend/src/model/heat-map-drawer.ts
  5. 133
      04.系统编码/Frontend/src/model/high-chart-heatmap-create.ts
  6. 27
      04.系统编码/Frontend/src/uilts/array-creater.ts
  7. 5
      04.系统编码/Frontend/src/uilts/axios.ts
  8. 18
      04.系统编码/Frontend/src/uilts/box-drawer.ts

3798
04.系统编码/Frontend/package-lock.json

File diff suppressed because it is too large

173
04.系统编码/Frontend/src/components/RamanLidar.vue

@ -35,28 +35,8 @@
:class="{'active': currentRegion === 'pukou'}">浦口</span></el-col>
</el-row>
</div>
<!-- layertype -->
<div class="menu-item">
<h2 class="tip">要素选择</h2>
<!-- <el-row :gutter="12">-->
<!-- <el-col :span="24"><span @click="onElementClick('PBLH', '边界层高度')"-->
<!-- :class="{'active': currentElement === 'PBLH'}">边界层高度</span></el-col>-->
<!-- <el-col :span="24"><span @click="onElementClick('opticalthickness', '光学厚度')"-->
<!-- :class="{'active': currentElement === 'opticalthickness'}">光学厚度</span></el-col>-->
<!-- <el-col :span="24"><span @click="onElementClick('Lidar_ratio', '激光雷达比')"-->
<!-- :class="{'active': currentElement === 'Lidar_ratio'}">激光雷达比</span></el-col>-->
<!-- <el-col :span="24"><span @click="onElementClick('PM', '气溶胶PM')" :class="{'active': currentElement === 'PM'}">气溶胶PM</span>-->
<!-- </el-col>-->
<!-- <el-col :span="24"><span @click="onElementClick('ext_plot', '消光系数')"-->
<!-- :class="{'active': currentElement === 'ext_plot'}">消光系数</span></el-col>-->
<!-- <el-col :span="24"><span @click="onElementClick('layertype', '云气溶胶分类')"-->
<!-- :class="{'active': currentElement === 'layertype'}">云气溶胶分类</span></el-col>-->
<!-- <el-col :span="24"><span @click="onElementClick('wv_plot', '水汽')"-->
<!-- :class="{'active': currentElement === 'wv_plot'}">水汽</span></el-col>-->
<!-- <el-col :span="24"><span @click="onElementClick('cloudheight', '云高')"-->
<!-- :class="{'active': currentElement === 'cloudheight'}">云高</span></el-col>-->
<!-- </el-row>-->
</div>
</div>
@ -75,23 +55,8 @@
<span @click="onPrevDayClick"><img src="/images/prev.png"/></span>
<span @click="onNextDayClick"><img src="/images/next.png"/></span>
</div>
<!-- <div class="refresh-btn" @click="onRefreshClick">-->
<!-- <img src="/images/refresh.png"/>-->
<!-- </div>-->
<!-- <div class="btns-group">-->
<!-- <span @click="onPlayClick">{{ isPlay ? '暂停动画' : '播放动画' }}</span>-->
<!-- <a @click="onDownloadClick">下载动画</a>-->
<!-- <a id="radarDownload" :href="downloadSrc" download style="display: none;">下载隐藏层</a>-->
<!-- </div>-->
</div>
<div class="picture-view">
<!-- <span class="arrow arrow-prev" @click="onPrevImgClick"><img src="/images/prev-btn.png" /></span>-->
<!-- <span class="arrow arrow-next" @click="onNextImgClick"><img src="/images/next-btn.png" /></span>-->
<!-- &lt;!&ndash; <span class="save-btn" @click="onSaveClick" v-if="currentElement === 'PBLH'"><img src="/images/save.png" /></span> &ndash;&gt;-->
<!-- <a :href="downloadImgUrl" download class="save-btn" v-if="currentElement !== 'PBLH'"><img src="/images/save.png" /></a>-->
<!-- <div class="download-pictures hide" id="pictures">-->
<!-- <a v-for="(url, index) in urls" :key="index" download></a>-->
<!-- </div>-->
<div class="picture-container raman-picture-container" v-show="currentTab === 'boundary-layer-height'">
<div class="picture">
<h2>水汽</h2>
@ -142,9 +107,11 @@
<div class="picture-container raman-picture-container" v-show="currentTab === 'MWR'">
<div class="picture">
<h2 class="title">云的识别</h2>
<canvas id='cloud_recognition_chart' style="width: 500px;"></canvas>
</div>
<div class="picture">
<h2 class="title">消光系数</h2>
<canvas id='extinction_chart' style="width: 500px;"></canvas>
</div>
<div class="picture">
<h2 class="title">水汽</h2>
@ -158,15 +125,16 @@
<script lang="ts">
import {onMounted, reactive, toRefs} from 'vue';
import moment, {min} from "moment";
import moment from "moment";
import {RamanLidarConfig} from '../uilts/Config';
import {post} from '../uilts/axios';
import {ElMessage} from "element-plus";
import * as Highcharts from 'highcharts';
import {ConstantRamanLidar} from "../model/constant";
import {get} from '../uilts/axios';
import {HighChartCreate} from "../model/high-chart-create";
import {BoxDrawer, ColorChart, createEmptyCanvas} from "../uilts/box-drawer";
import {CustomeArray} from "../model/custome-array"
import {CoordinateScale, HeatMapDrawer} from "../model/heat-map-drawer";
import { Box, ColorChart } from '../uilts/box-drawer';
export default {
name: 'RamanLidar',
@ -176,19 +144,23 @@ export default {
boundaryLayerHeight: HighChartCreate
cloudsHeight: HighChartCreate
cloudTopHeight: HighChartCreate
LidarRatio: HighChartCreate
LidarRatio: HighChartCreate,
cloudRecognitionDrawer: HeatMapDrawer,
extinctionDrawer: HeatMapDrawer
} = {
boundaryLayerHeight: null,
cloudsHeight: null,
cloudTopHeight: null,
LidarRatio: null
LidarRatio: null,
cloudRecognitionDrawer: null,
extinctionDrawer: null
}
let options = reactive({
currentTab: 'MWR',
currentRegion: 'jiangning',
currentElement: 'PBLH',
currentType: '边界层高度',
date: moment('2021-12-14').format('YYYY-MM-DD'),
date: moment('2022-01-02').format('YYYY-MM-DD'),
times: [],
currentTime: null,
downloadImgUrl: '/images/default-picture.png',
@ -211,8 +183,8 @@ export default {
initTimeLine();
setTitle(moment(options.date, 'YYYY-MM-DD'));
setTimeout(() => {
activeImage();
}, 50)
reloadChangeData();
}, 50);
})
//
@ -262,6 +234,10 @@ export default {
creates.LidarRatio.init();
}
const initCloudRecognition = () => {
}
const onTabClick = (name) => {
options.currentTab = name;
setTimeout(() => {
@ -286,7 +262,118 @@ export default {
cloudTopHeightApi()
} else if (options.currentTab === 'MWR') {
//waterVapourApi()
reloadCloudRecognition(801, 'layertype', drawCloudRecognition);
reloadCloudRecognition(801, 'extinction', drawExtinction);
reloadCloudRecognition(1001, 'extinction', drawExtinction);
}
}
const drawExtinction = (result: CustomeArray<any>) => {
if (result.length != 24) return;
if (creates.extinctionDrawer != null){
creates.extinctionDrawer.close();
}
let matrix = converCloudRecognition(801, result);
creates.extinctionDrawer = new HeatMapDrawer(800, 600, matrix, "extinction_chart", '米');
creates.extinctionDrawer.setAxis(new CoordinateScale([0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]), new CoordinateScale([0, 2000, 4000, 6000, 8000, 10000, 12000], true, true));
creates.extinctionDrawer.setColorChart(prepareExtinctionnColors());
creates.extinctionDrawer.draw();
}
const prepareExtinctionnColors = () => {
return new ColorChart(['##990000','#CC0000', '#FF0000', '#FF3300', '#FF6600', '#FF9900', '#FFCC00', '#FFFF00', '#CCFF33', '#99FF66',
'#66FF99', '#33FFCC', '#00FFFF', '#00CCFF', '#0099FF', '#0066FF', '#0033FF', '#0000FF', '#0000CC', '#000099'],
[10, 8, 6, 4, 2, 1, 0.8, 0.6, 0.4, 0.2, 0.1, 0.08, 0.06, 0.04, 0.02, 0.01, 0.008, 0.006, 0.004, 0.002, 0.001], true, true
);
}
const reloadCloudRecognition = (capacity: number, element: string, callback: any) => {
let result = new CustomeArray(callback);
let time = moment(options.date);
for(let index = 0; index < 24; index ++){
reloadSingleCloudRecognition(capacity, time.clone().add(-index, 'h').format('M_D_H'), element, result);
}
}
const drawCloudRecognition = (result: CustomeArray<any>) => {
if (result.length != 24) return;
if (creates.cloudRecognitionDrawer != null){
creates.cloudRecognitionDrawer.close();
}
let matrix = converCloudRecognition(801, result);
creates.cloudRecognitionDrawer = new HeatMapDrawer(800, 600, matrix, "cloud_recognition_chart", '米');
creates.cloudRecognitionDrawer.setAxis(new CoordinateScale([0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]), new CoordinateScale([0, 2000, 4000, 6000, 8000, 10000, 12000], true, true));
creates.cloudRecognitionDrawer.setColorChart(prepareCloudRecognitionColors());
creates.cloudRecognitionDrawer.draw();
}
const prepareCloudRecognitionColors = () => {
return new ColorChart(['#0000FF','#00FF00', '#FF0000', '#FFFFFF'],
[3, 2, 1, 0, -99]
);
}
const converCloudRecognition = (capacity: number, result: CustomeArray<any>) => {
result.sort((x, y) => moment(x.time, 'M_D_H').isBefore(moment(y.time, 'M_D_H')) ? -1 : 1);
let matrix = new Array<Array<Box>>();
let index = -1;
result.forEach(r => {
const time = moment(r.time, 'M_D_H').format("MM月DD日HH时")
if (r.data == null){
for(let x = 0; x < 60; x++){
index ++;
if (matrix[index] == null){
matrix[index] = new Array<Box>(capacity);
}
for(let y = 0; y < capacity; y++){
matrix[index][y] = new Box(index, y, 0, 0, 0, y * 15, time, "米");
}
}
return;
}
const interval = Math.round(60 / r.data[0].length);
for(let h = 0, len = r.data.length; h < len; h++){
let tempIndex = parseInt(index + "");
for(let i = 0,len = r.data[h].length; i < len; i++){
for(let _i = 0; _i < interval; _i++){
tempIndex ++;
if (matrix[tempIndex] == null){
matrix[tempIndex] = new Array<Box>(capacity);
}
matrix[tempIndex][h] = new Box(tempIndex, h, 0, 0, r.data[h][i], i * 15, time, "米");
}
}
}
index = index + r.data[0].length * interval;
});
return matrix;
}
const reloadSingleCloudRecognition = (capacity: number, time: string, elementCode, result: CustomeArray<any>) => {
const params = prepareApiParams(time, elementCode)
get('/njqxj/lmlidar', params, ConstantRamanLidar.baseUrl).then((response: any) => {
if (response.state != 0) {
setCloudRecognitionResult(capacity, time, response.message, null, result);
return;
}
setCloudRecognitionResult(capacity, time, response.message, response.data, result);
})
}
const setCloudRecognitionResult = (capacity: number, time: string, message: string, data: any, result: CustomeArray<any>) =>{
result.push({
time: time,
message: message,
data: data == null ? null : JSON.parse(data).slice(0, capacity)
})
}
const initEcharts = (name) => {

20
04.系统编码/Frontend/src/model/custome-array.ts

@ -0,0 +1,20 @@
/**
* push
*/
export class CustomeArray<T> extends Array<T>{
private callBack: any = null;
private params: any = null;
constructor(callBack: any, ...params: any){
super();
this.callBack = callBack;
this.params = params;
}
push(item: T): number {
const index = super.push(item);
this.callBack(this, this.params);
return index;
}
}

367
04.系统编码/Frontend/src/model/heat-map-drawer.ts

@ -0,0 +1,367 @@
import moment from "moment";
import { Box, Calc, ColorChart } from "../uilts/box-drawer";
export class HeatMapDrawer{
private readonly id: string;
private canvas: any = null;
private canvasContext: any = null;
private targetCanvas: any = null;
private targetCanvasContext: any = null;
private borderWidth: number = 0;
private borderHeight: number = 0;
private readonly width: number = null;
private readonly height: number = null;
private readonly paddingLeft: number = 200;
private readonly paddingRight: number = 100;
private readonly paddingTop: number = 60;
private readonly paddingBottom: number = 50;
private colorChart: ColorChart = null;
private values: any = null;
private readonly verticalScaleSpecialCount: number = 1;
private readonly horizontalScaleSpecialCount: number = 1;
// 垂直刻度
private readonly verticalScaleLine: number = 18;
// 水平刻度
private readonly horizontalScaleLine: number = 20;
public base64Image: string = null;
private verticalScaleIntervalLength: number = 0;
private horizontalScaleIntervalLength: number = 0;
private paddingColorLeft: number = 50;
private defaultColorWidth: number = 30;
private calc: Calc = null;
private box: Box = null;
private xAxis: CoordinateScale;
private yAxis: CoordinateScale;
private unit: string;
constructor(width: number, height: number, values: any, id: string, unit: string) {
if (id == null) return;
this.id = id;
this.width = width;
this.height = height;
this.values = values;
this.unit = unit;
this.init();
}
public setAxis(xAxis: CoordinateScale, yAxis: CoordinateScale): void {
this.xAxis = xAxis;
this.yAxis = yAxis;
}
public setColorChart(colorChart: ColorChart) : void {
this.colorChart = colorChart;
}
public drawColorChart(): void {
let startX = this.paddingLeft + this.horizontalScaleLine + this.borderWidth + this.paddingColorLeft;
let heightInterval = 0;
let startY = this.paddingTop + this.verticalScaleLine + heightInterval;
let interval = (this.borderHeight - heightInterval) / (this.colorChart.colors.length)
this.canvasContext.font = "normal 24px Verdana";
this.canvasContext.fillStyle = "#000000";
for(let lastLen = this.colorChart.colors.length - 1, index = lastLen; index >= 0; index --){
const targetIndex = lastLen - index;
const _y = startY + index * interval;
this.canvasContext.fillStyle = this.colorChart.colors[targetIndex];
this.canvasContext.fillRect(startX, _y, this.defaultColorWidth, interval);
this.canvasContext.fillStyle = "#000000";
if (index == 0){
if (this.colorChart.showStartValue){
const text = this.colorChart.values[targetIndex + 1];
this.canvasContext.fillText(text, startX + this.defaultColorWidth, _y + 9);
}
const text = this.colorChart.values[targetIndex];
this.canvasContext.fillText(text, startX + this.defaultColorWidth, _y + interval + 9);
}else if (index == lastLen){
if (this.colorChart.showEndValue){
const text = this.colorChart.values[targetIndex];
this.canvasContext.fillText(text, startX + this.defaultColorWidth, _y + interval + 9);
}
const text = this.colorChart.values[targetIndex + 1];
this.canvasContext.fillText(text, startX + this.defaultColorWidth, _y + 9);
}else{
const text = this.colorChart.values[targetIndex];
this.canvasContext.fillText(text, startX + this.defaultColorWidth, _y + interval + 9);
}
}
}
public draw(): void{
this.drawCoordinate();
this.drawColorChart();
this.redraw();
this.setTargetCanvas(this.id);
}
private calcDataScale() : void{
this.verticalScaleIntervalLength = this.borderWidth / (this.values.length - 1);
this.horizontalScaleIntervalLength = this.borderHeight / (this.values[0].length - 1);
}
private redraw(): void{
this.calcDataScale();
let startX = this.paddingLeft + this.horizontalScaleLine - this.verticalScaleIntervalLength / 2;
let startY = this.paddingTop + this.verticalScaleLine - this.horizontalScaleIntervalLength / 2;
for(let dataIndex = 0, len = this.values.length, lastDataLen = len - 1; dataIndex < len; dataIndex++){
let value = this.values[dataIndex];
for(let lastInfoLen = this.values[0].length - 1, infoIndex = lastInfoLen; infoIndex >= 0; infoIndex--){
let x = startX + dataIndex * this.verticalScaleIntervalLength;
let y = startY + (this.borderHeight - infoIndex * this.horizontalScaleIntervalLength);
let width = this.verticalScaleIntervalLength;
let height = this.horizontalScaleIntervalLength;
if (dataIndex == 0) {
x = x + this.verticalScaleIntervalLength / 2;
width = width / 2;
}
if (infoIndex == lastInfoLen){
y = y + this.horizontalScaleIntervalLength / 2;
height = height / 2;
}
if (dataIndex == lastDataLen){
width = width / 2;
}
if (infoIndex == 0){
height = height / 2;
}
let targetValue = value[infoIndex].value;
let color = this.colorChart.getColor(targetValue);
value[infoIndex].updateBorderInfo(width, height);
if (color == null) continue;
this.canvasContext.fillStyle = color;
this.canvasContext.fillRect(x, y, width, height);
}
// this.values[dataIndex] = this.values[dataIndex].reverse();
}
this.createCalc(this.values);
}
private createCalc(boxes: any): void{
this.calc = new Calc(this.width, this.height, this.paddingLeft + this.verticalScaleLine, this.paddingTop + this.horizontalScaleLine,
this.paddingRight + this.horizontalScaleLine, this.paddingBottom + this.verticalScaleLine, boxes);
}
private init(): void{
// 创建画布
this.canvas = document.createElement('canvas');
this.canvas.width = this.width;
this.canvas.height = this.height;
this.canvasContext = this.canvas.getContext('2d');
this.fillBackground();
// this.resetValues();
}
private setTargetCanvas(id): void{
this.targetCanvas = document.getElementById(id);
this.targetCanvas.width = this.width;
this.targetCanvas.height = this.height;
this.targetCanvasContext = this.targetCanvas.getContext('2d');
this.copyCanvas();
this.bindMoveEvent();
}
private copyCanvas(): void{
const imgData= this.canvasContext.getImageData(0,0, this.width, this.height);
this.targetCanvasContext.putImageData(imgData, 0, 0);
}
private _onMouseMove = this.onMouseMove.bind(this);
private _onMouseOut = this.onMouseOut.bind(this)
private bindMoveEvent(): void{
this.targetCanvas.addEventListener('mousemove', this._onMouseMove);
this.targetCanvas.addEventListener('mouseout', this._onMouseOut);
}
private onMouseOut() : void{
this.copyCanvas();
}
private onMouseMove(e) : void{
let box = this.calc.calc(e.offsetX, e.offsetY);
if (box == null) {
if (this.box != null){
this.copyCanvas();
this.box = null;
}
return;
}
if (this.box != null){
if (this.box.id == box.id) return;
this.copyCanvas();
this.box = null;
}
box.show(this.targetCanvasContext);
this.box = box;
}
public close(): void{
this.targetCanvas.removeEventListener('mousemove', this._onMouseMove);
this.targetCanvas.removeEventListener('mouseout', this._onMouseOut);
this.values.length = 0;
}
private fillBackground(): void{
this.canvasContext.fillStyle = 'white';
this.canvasContext.fillRect(0,0, this.width,this.height);
}
public drawCoordinate(): void{
this.drawBorder();
this.drawVerticalScale();
this.drawHorizontalScale();
this.drawHeightText();
this.drawTemperatureText(this.unit);
}
//高度单位
private drawHeightText(): void {
let name =['高','度','(','m',')']; // 文本内容
let x = 70,y = 180; // 文字开始的坐标
let letterSpacing = 20; // 设置字间距
for(let i = 0; i < name.length; i++) {
const str = name.slice(i, i + 1).toString();
if (str.match(/[A-Za-z0-9-()-]/) && (y < 576)) { // 非汉字 旋转
this.canvasContext.save();
this.canvasContext.translate(x, y);
this.canvasContext.rotate(Math.PI / 180 * 90);
this.canvasContext.textBaseline = 'bottom';
this.canvasContext.font = "normal 35px Verdana";
this.canvasContext.fillStyle = "#000000";
this.canvasContext.fillText(str, 0, 0);
this.canvasContext.restore();
y += this.canvasContext.measureText(str).width + letterSpacing; // 计算文字宽度
} else if (str.match(/[\u4E00-\u9FA5]/) && (y < 576)) {
this.canvasContext.save();
this.canvasContext.textBaseline = 'top';
this.canvasContext.font = "normal 35px Verdana";
this.canvasContext.fillStyle = "#000000";
this.canvasContext.fillText(str, x, y);
this.canvasContext.restore();
y += this.canvasContext.measureText(str).width + letterSpacing; // 计算文字宽度
}
}
}
//温度单位
private drawTemperatureText(unit): void {
this.canvasContext.font = "normal 35px Verdana";
this.canvasContext.fillStyle = "#000000";
let unitX = 1390
if (unit === '(degree)') unitX =1350
this.canvasContext.fillText(unit, unitX, 50);
}
private drawVerticalScale(): void{
let scaleCount = this.xAxis.scales.length;
let verticalScaleIntervalLength = this.borderWidth / (scaleCount - 1);
let startX = this.paddingLeft + this.horizontalScaleLine;
let startY = this.paddingTop + this.verticalScaleLine;
for(let index = 0, len = scaleCount, lastLen = scaleCount - 1; index < len; index++){
if ((index == 0 && !this.xAxis.showStartValue) || (index == lastLen && !this.xAxis.showEndValue)) continue;
this.setScaleStyle(true);
const _x = startX + index * verticalScaleIntervalLength;
this.canvasContext.beginPath();
this.canvasContext.moveTo(_x, startY);
this.canvasContext.lineTo(_x,startY - this.verticalScaleLine);
this.canvasContext.moveTo(_x, startY + this.borderHeight);
this.canvasContext.lineTo(_x,startY + this.verticalScaleLine + this.borderHeight);
this.canvasContext.stroke();
if (true){
this.canvasContext.font = "normal 30px Verdana";
this.canvasContext.fillStyle = "#000000";
this.canvasContext.fillText(this.xAxis.scales[index], _x - this.canvasContext.measureText(this.xAxis.scales[index]).width / 2, startY + this.verticalScaleLine + this.borderHeight + 36);
}
}
}
private drawHorizontalScale(): void{
let scaleCount = this.yAxis.scales.length;
let horizontalScaleIntervalLength = this.borderHeight / (scaleCount - 1);
let startX = this.paddingLeft + this.horizontalScaleLine;
let startY = this.paddingTop + this.verticalScaleLine;
const lastLen = scaleCount - 1;
for(let index = lastLen; index >= 0; index--) {
if ((index == 0 && !this.yAxis.showStartValue) || (index == lastLen && !this.yAxis.showEndValue)) continue;
this.setScaleStyle(true);
const _y = startY + (this.borderHeight - index * horizontalScaleIntervalLength);
this.canvasContext.beginPath();
this.canvasContext.moveTo(startX, _y);
this.canvasContext.lineTo(startX - this.horizontalScaleLine, _y);
this.canvasContext.moveTo(this.borderWidth + startX, _y);
this.canvasContext.lineTo(this.borderWidth + startX + this.horizontalScaleLine, _y);
this.canvasContext.stroke();
if (true) {
this.canvasContext.font = "normal 30px Verdana";
this.canvasContext.fillStyle = "#000000";
this.canvasContext.fillText(this.yAxis.scales[index], startX - this.canvasContext.measureText(this.yAxis.scales[index]).width - this.horizontalScaleLine, _y + 10);
}
}
}
private setScaleStyle(isSpecial: boolean): void{
if (isSpecial){
this.canvasContext.lineWidth = 3;
this.canvasContext.strokeStyle = '#101010';
return;
}
this.canvasContext.lineWidth = 2;
this.canvasContext.strokeStyle = '#5e5e5e';
}
private drawBorder(): void{
const x = this.horizontalScaleLine + this.paddingLeft;
const y = this.verticalScaleLine + this.paddingTop;
const _x = this.width - this.horizontalScaleLine - this.paddingRight;
const _y = this.height - this.verticalScaleLine - this.paddingBottom;
this.canvasContext.beginPath();
this.canvasContext.lineWidth = "2";
this.canvasContext.strokeStyle = "black";
this.borderWidth = _x - x;
this.borderHeight = _y - y;
this.canvasContext.rect(x, y, this.borderWidth, this.borderHeight);
this.canvasContext.stroke();
}
}
export class CoordinateScale {
public scales: Array<number>;
public showStartValue: boolean;
public showEndValue: boolean;
constructor(scales: Array<number>, showStartValue: boolean = false, showEndValue: boolean = false){
this.scales = scales;
this.showEndValue = showEndValue;
this.showStartValue = showStartValue;
}
}

133
04.系统编码/Frontend/src/model/high-chart-heatmap-create.ts

@ -0,0 +1,133 @@
import * as Highcharts from "highcharts"
// Highcharts.heatmap(Highcharts);
export class HighChartHeatMapCreate {
private readonly id: string;
private highChart: any;
private chart: any;
private xAxis: Array<any> = [];
private yAxis: Array<any> = [];
private series: Array<any> = [];
private legend: any = null;
private tooltip: any = null;
private colorAxis: any = null;
constructor(id: string) {
this.id = id;
}
public setChart(type: string = 'heatmap'): void{
this.chart = {
type: 'heatmap',
marginTop: 40,
marginBottom: 80,
plotBorderWidth: 1
};
}
public setXAxis(text: string, reversed: boolean = true){
this.xAxis.push({
categories: ['Alexander', 'Marie', 'Maximilian', 'Sophia', 'Lukas', 'Maria', 'Leon', 'Anna', 'Tim', 'Laura']
});
}
public setYAxis(text: string, max: number, min: number, tickInterval: number, tickAmount: number, opposite: boolean = false, lineWidth: number = 1, reversed: boolean = true){
this.yAxis.push({
categories: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
title: null
});
}
public setColorAxis(): void {
this.colorAxis = {
min: 0,
minColor: '#FFFFFF',
maxColor: Highcharts.getOptions().colors[0]
}
}
public setLegend(enabled: boolean = false){
this.legend = {
align: 'right',
layout: 'vertical',
margin: 0,
verticalAlign: 'top',
y: 25,
symbolHeight: 280
}
}
public setTooltip(pointFormat: string, headerFormat: string = '<b>{series.name}</b><br/>'){
this.tooltip = {
formatter: function () {
return '<b>' + this.series.xAxis.categories[this.point.x] + '</b> sold <br><b>' +
this.point.value + '</b> items on <br><b>' + this.series.yAxis.categories[this.point.y] + '</b>';
}
}
}
// public setSeries(name: string)
public setSeries(data: any){
// let series: any = {
// name: name,
// data: [],
// }
// if (color == null || valueSuffix == null){
// this.series.push(series);
// return
// }
// series.yAxis = yAxis;
// series.tooltip = {
// valueSuffix: valueSuffix
// };
// series.color = color;
this.series.push({
name: 'Sales per employee',
borderWidth: 1,
data: data,
dataLabels: {
enabled: true,
color: '#000000'
}
});
}
public init(): void{
const options = this.getOptions();
this.highChart = Highcharts.chart(this.id, options);
// return this.highChart;
}
private getOptions(){
let options: any = {
credits: {
enabled: false
},
chart: this.chart,
title: {
text: null
},
xAxis: this.xAxis,
yAxis: this.yAxis,
colorAxis: this.colorAxis,
tooltip: this.tooltip,
series: this.series
};
if (this.legend != null)
options.legend = this.legend;
return options;
}
public updateSeries(index: number, data: Array<any>): void{
this.highChart.series[index].setData(data);
}
public updateXAxis(categories: Array<any>, index: number = 0){
this.highChart.xAxis[index].setCategories(categories);
}
}

27
04.系统编码/Frontend/src/uilts/array-creater.ts

@ -0,0 +1,27 @@
const arrayProtoType = Object.create(Array.prototype)
// 创建一个新的原型,这就是改造之后的数组原型
const ArrayProto = []
// 重新构建Array原型里面的虽有方法
Object.getOwnPropertyNames(Array.prototype).forEach(key => {
// console.log(key)
if (typeof arrayProtoType[key] === "function"){
// console.log(arrayProtoType[key], key)
ArrayProto[key] = function () {
// listenMethods(key);
return arrayProtoType[key].apply(this, arguments);
}
}
if (key === "push"){
listenProps("push")
}
ArrayProto[key] = arrayProtoType[key];
})
function listenProps(prop){
console.log( prop + 'prop触发了');
// 其他你需要监听的逻辑
}
export {
ArrayProto
}

5
04.系统编码/Frontend/src/uilts/axios.ts

@ -6,12 +6,7 @@ import { Config } from "./Config";
let loading = null;
const service = axios.create({
// baseURL:"http://112.124.40.88:8999",
// baseURL:'http://rdp.nagr.com.cn:18080',
// baseURL:"http://localhost:8002",
baseURL: Config.url,
// baseURL: 'http://localhost:8002',
timeout: 500000
})

18
04.系统编码/Frontend/src/uilts/box-drawer.ts

@ -1,6 +1,4 @@
import moment from "moment";
import {h, provide} from "vue";
import {urlRE} from "vite/dist/node/utils/cssUtils";
export function createEmptyCanvas(id: string, width: number, height: number): void{
let canvas: any = document.getElementById(id);
@ -400,8 +398,9 @@ export class ColorChart{
}
public getColor(value: number): string{
for(let index = 1; index < this.valueLength; index ++){
if (this.values[index -1] <= value && this.values[index] > value){
if (this.values[index -1] < value && this.values[index] >= value){
return this.colors[index - 1];
}
}
@ -409,11 +408,11 @@ export class ColorChart{
}
}
interface IBox {
export interface IBox {
show(canvasContext: any);
}
class Box implements IBox{
export class Box implements IBox{
id: string = null;
x: number;
@ -421,7 +420,7 @@ class Box implements IBox{
width: number;
height: number;
value: number;
public value: number;
dataHeight: number;
time: string;
util: string;
@ -448,6 +447,11 @@ class Box implements IBox{
this.id = this.uuid();
}
updateBorderInfo(width: number, height: number): void{
this.width = width;
this.height = height;
}
show(canvasContext: any) {
this.setSelectStyle(canvasContext);
this.setTip(canvasContext);
@ -545,7 +549,7 @@ class Box implements IBox{
}
}
class Calc{
export class Calc{
private readonly width: number;
private readonly height: number;

Loading…
Cancel
Save