Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@meta2d/le5le-charts

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meta2d/le5le-charts - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

0

index.d.ts

@@ -0,0 +0,0 @@ export * from './src/lineChart';

@@ -0,0 +0,0 @@ //le5le charts

2

package.json
{
"name": "@meta2d/le5le-charts",
"version": "1.0.4",
"version": "1.0.5",
"description": "The le5le-charts library based on le5le meta2d.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,3 +0,2 @@

/// <reference types="node" />
import { Pen } from '../../core/src/pen';
import { Pen } from '@meta2d/core/src/pen';
interface Axis {

@@ -4,0 +3,0 @@ lineStyle?: {};

@@ -0,0 +0,0 @@ export function getValidValue(num, value) {

@@ -0,0 +0,0 @@ import { leChartPen } from './common';

@@ -5,13 +5,12 @@ import { scaleCompute } from './normalizedAxis';

export function coordinateAxis(ctx, pen) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
var x = pen.calculative.worldRect.x;
var y = pen.calculative.worldRect.y;
var w = pen.calculative.worldRect.width;
var h = pen.calculative.worldRect.height;
const x = pen.calculative.worldRect.x;
const y = pen.calculative.worldRect.y;
const w = pen.calculative.worldRect.width;
const h = pen.calculative.worldRect.height;
// 缩放比例
var r = w / 2;
var scale = pen.calculative.canvas.store.data.scale;
var series = [];
let r = w / 2;
let scale = pen.calculative.canvas.store.data.scale;
let series = [];
if (pen.echarts) {
for (var i = 0; i < pen.echarts.option.series.length; i++) {
for (let i = 0; i < pen.echarts.option.series.length; i++) {
series.push(pen.echarts.option.series[i].data);

@@ -23,7 +22,7 @@ }

}
var collection_data = [];
for (var i = 0; i < series.length; i++) {
let collection_data = [];
for (let i = 0; i < series.length; i++) {
collection_data = collection_data.concat(series[i]);
}
var initOption = {
let initOption = {
max: Math.max.apply(null, collection_data),

@@ -33,4 +32,4 @@ min: Math.min.apply(null, collection_data),

};
var normalizedOption = scaleCompute(initOption);
var num = pen.echarts
let normalizedOption = scaleCompute(initOption);
let num = pen.echarts
? pen.echarts.option.xAxis.data.length

@@ -42,3 +41,3 @@ : pen.xAxisData.length;

ctx.lineCap = 'butt';
var dash = (w - 1 * (num + 1)) / num;
let dash = (w - 1 * (num + 1)) / num;
ctx.setLineDash([1, dash]);

@@ -62,13 +61,13 @@ ctx.moveTo(x, y + h + 3 * scale);

ctx.setLineDash([2, 2]);
var fontOptions = {
fontStyle: ((_b = (_a = pen.yAxis) === null || _a === void 0 ? void 0 : _a.axisLabel) === null || _b === void 0 ? void 0 : _b.fontStyle) || pen.fontStyle,
textDecoration: (_d = (_c = pen.yAxis) === null || _c === void 0 ? void 0 : _c.axisLabel) === null || _d === void 0 ? void 0 : _d.textDecoration,
fontWeight: ((_f = (_e = pen.yAxis) === null || _e === void 0 ? void 0 : _e.axisLabel) === null || _f === void 0 ? void 0 : _f.fontWeight) || pen.fontWeight,
fontFamily: ((_h = (_g = pen.yAxis) === null || _g === void 0 ? void 0 : _g.axisLabel) === null || _h === void 0 ? void 0 : _h.fontFamily) || pen.fontFamily,
fontSize: ((_k = (_j = pen.yAxis) === null || _j === void 0 ? void 0 : _j.axisLabel) === null || _k === void 0 ? void 0 : _k.fontSize) || pen.fontSize,
lineHeight: ((_m = (_l = pen.yAxis) === null || _l === void 0 ? void 0 : _l.axisLabel) === null || _m === void 0 ? void 0 : _m.lineHeight) || pen.lineHeight,
let fontOptions = {
fontStyle: pen.yAxis?.axisLabel?.fontStyle || pen.fontStyle,
textDecoration: pen.yAxis?.axisLabel?.textDecoration,
fontWeight: pen.yAxis?.axisLabel?.fontWeight || pen.fontWeight,
fontFamily: pen.yAxis?.axisLabel?.fontFamily || pen.fontFamily,
fontSize: pen.yAxis?.axisLabel?.fontSize || pen.fontSize,
lineHeight: pen.yAxis?.axisLabel?.lineHeight || pen.lineHeight,
};
ctx.fillStyle = ((_p = (_o = pen.yAxis) === null || _o === void 0 ? void 0 : _o.axisLabel) === null || _p === void 0 ? void 0 : _p.fontColor) || pen.color;
for (var i = 0; i < normalizedOption.splitNumber + 1; i++) {
var temH = (i * h) / normalizedOption.splitNumber;
ctx.fillStyle = pen.yAxis?.axisLabel?.fontColor || pen.color;
for (let i = 0; i < normalizedOption.splitNumber + 1; i++) {
let temH = (i * h) / normalizedOption.splitNumber;
ctx.textAlign = 'right';

@@ -90,18 +89,18 @@ ctx.textBaseline = 'middle';

ctx.strokeStyle = '#BFBFBF';
var xData = pen.echarts ? pen.echarts.option.xAxis.data : pen.xAxisData;
var xdataX = 0;
for (var i = 0; i < xData.length; i++) {
let xData = pen.echarts ? pen.echarts.option.xAxis.data : pen.xAxisData;
let xdataX = 0;
for (let i = 0; i < xData.length; i++) {
xdataX = x + (1 + dash / 2) + (dash + 1) * i;
ctx.textAlign = 'center';
ctx.textBaseline = 'top';
var fontOptions_1 = {
fontStyle: ((_r = (_q = pen.xAxis) === null || _q === void 0 ? void 0 : _q.axisLabel) === null || _r === void 0 ? void 0 : _r.fontStyle) || pen.calculative.fontStyle,
textDecoration: (_t = (_s = pen.xAxis) === null || _s === void 0 ? void 0 : _s.axisLabel) === null || _t === void 0 ? void 0 : _t.textDecoration,
fontWeight: ((_v = (_u = pen.xAxis) === null || _u === void 0 ? void 0 : _u.axisLabel) === null || _v === void 0 ? void 0 : _v.fontWeight) || pen.calculative.fontWeight,
fontFamily: ((_x = (_w = pen.xAxis) === null || _w === void 0 ? void 0 : _w.axisLabel) === null || _x === void 0 ? void 0 : _x.fontFamily) || pen.calculative.fontFamily,
fontSize: ((_z = (_y = pen.xAxis) === null || _y === void 0 ? void 0 : _y.axisLabel) === null || _z === void 0 ? void 0 : _z.fontSize) || pen.calculative.fontSize,
lineHeight: ((_1 = (_0 = pen.xAxis) === null || _0 === void 0 ? void 0 : _0.axisLabel) === null || _1 === void 0 ? void 0 : _1.lineHeight) || pen.calculative.lineHeight,
let fontOptions = {
fontStyle: pen.xAxis?.axisLabel?.fontStyle || pen.calculative.fontStyle,
textDecoration: pen.xAxis?.axisLabel?.textDecoration,
fontWeight: pen.xAxis?.axisLabel?.fontWeight || pen.calculative.fontWeight,
fontFamily: pen.xAxis?.axisLabel?.fontFamily || pen.calculative.fontFamily,
fontSize: pen.xAxis?.axisLabel?.fontSize || pen.calculative.fontSize,
lineHeight: pen.xAxis?.axisLabel?.lineHeight || pen.calculative.lineHeight,
};
ctx.font = getFont(fontOptions_1); //r / 10 +'px AlibabaPuHuiTi-Regular, Alibaba PuHuiTi';
ctx.fillStyle = ((_3 = (_2 = pen.xAxis) === null || _2 === void 0 ? void 0 : _2.axisLabel) === null || _3 === void 0 ? void 0 : _3.fontColor) || pen.calculative.color;
ctx.font = getFont(fontOptions); //r / 10 +'px AlibabaPuHuiTi-Regular, Alibaba PuHuiTi';
ctx.fillStyle = pen.xAxis?.axisLabel?.fontColor || pen.calculative.color;
ctx.fillText(xData[i], xdataX, (y + h + 10 * scale));

@@ -108,0 +107,0 @@ ctx.fill();

import { leChartPen } from './common';
export declare function gauge(ctx: CanvasRenderingContext2D, pen: leChartPen): void;

@@ -1,12 +0,1 @@

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { getValidValue } from './common';

@@ -16,3 +5,2 @@ import { getFont } from "@meta2d/core";

export function gauge(ctx, pen) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
if (!pen.onAdd) {

@@ -27,8 +15,8 @@ pen.onAdd = onAdd;

}
var x = pen.calculative.worldRect.x;
var y = pen.calculative.worldRect.y;
var w = pen.calculative.worldRect.width;
var h = pen.calculative.worldRect.height;
var scale = pen.calculative.canvas.store.data.scale;
var basicConfigure = {
const x = pen.calculative.worldRect.x;
const y = pen.calculative.worldRect.y;
const w = pen.calculative.worldRect.width;
const h = pen.calculative.worldRect.height;
let scale = pen.calculative.canvas.store.data.scale;
let basicConfigure = {
startAngle: 225,

@@ -42,3 +30,3 @@ endAngle: -45,

if (pen.echarts && pen.echarts.option) {
var series = pen.echarts.option.series[0];
let series = pen.echarts.option.series[0];
pen.startAngle = series.startAngle || basicConfigure.startAngle;

@@ -53,15 +41,15 @@ pen.endAngle = series.endAngle || basicConfigure.endAngle;

}
pen = __assign(__assign({}, basicConfigure), pen);
var r = w > h ? ((h / 2) * 9) / 10 : ((w / 2) * 9) / 10;
var centerX = x + w / 2;
var centerY = y + h / 2;
var value = pen.echarts
pen = { ...basicConfigure, ...pen };
let r = w > h ? ((h / 2) * 9) / 10 : ((w / 2) * 9) / 10;
let centerX = x + w / 2;
let centerY = y + h / 2;
let value = pen.echarts
? pen.echarts.option.series[0].data[0].value
: pen.value;
var pointColor;
var gap = pen.startAngle - pen.endAngle;
var bgColor = pen.background || '#E6EBF8';
let pointColor;
let gap = pen.startAngle - pen.endAngle;
let bgColor = pen.background || '#E6EBF8';
//绘制背景
ctx.strokeStyle = bgColor;
var bgLineWidth = r / 10;
let bgLineWidth = r / 10;
ctx.lineWidth = bgLineWidth;

@@ -73,5 +61,5 @@ ctx.beginPath();

ctx.closePath();
var bili = 0;
let bili = 0;
if (pen.axisLine && !pen.isClock) {
for (var i = pen.axisLine.length - 1; i >= 0; i--) {
for (let i = pen.axisLine.length - 1; i >= 0; i--) {
if (pen.axisLine[i][0] * (pen.max - pen.min) < value) {

@@ -93,10 +81,10 @@ bili = pen.axisLine[i][0];

//主刻度线
var dashWidth = 2 * scale;
var mainR = r - bgLineWidth;
let dashWidth = 2 * scale;
let mainR = r - bgLineWidth;
if (mainR < 0) {
mainR = 0;
}
var arcLength = (gap / 180) * Math.PI * mainR;
var dash = (arcLength - dashWidth * pen.splitNumber) / pen.splitNumber;
var offsetAngle = ((gap / 180) * Math.PI * dashWidth) / 2 / arcLength;
let arcLength = (gap / 180) * Math.PI * mainR;
let dash = (arcLength - dashWidth * pen.splitNumber) / pen.splitNumber;
let offsetAngle = ((gap / 180) * Math.PI * dashWidth) / 2 / arcLength;
ctx.beginPath();

@@ -110,10 +98,10 @@ ctx.strokeStyle = pen.color || '#999999';

//从刻度线
var fromDashWidth = 1 * scale;
var fromR = r - bgLineWidth;
let fromDashWidth = 1 * scale;
let fromR = r - bgLineWidth;
if (fromR < 0) {
fromR = 0;
}
var fromArcLength = (gap / 180) * Math.PI * fromR;
var fromDash = (fromArcLength - fromDashWidth * 5 * pen.splitNumber) / 5 / pen.splitNumber;
var fromOffsetAngle = ((gap / 180) * Math.PI * fromDashWidth) / 2 / fromArcLength;
let fromArcLength = (gap / 180) * Math.PI * fromR;
let fromDash = (fromArcLength - fromDashWidth * 5 * pen.splitNumber) / 5 / pen.splitNumber;
let fromOffsetAngle = ((gap / 180) * Math.PI * fromDashWidth) / 2 / fromArcLength;
ctx.beginPath();

@@ -128,15 +116,15 @@ ctx.strokeStyle = pen.color || '#999999';

ctx.beginPath();
var valueGap = pen.max - pen.min;
var interval = valueGap / pen.splitNumber;
var fontOption = {
fontStyle: ((_a = pen.tickLabel) === null || _a === void 0 ? void 0 : _a.fontStyle) || pen.calculative.fontStyle,
textDecoration: ((_b = pen.tickLabel) === null || _b === void 0 ? void 0 : _b.textDecoration) || pen.textDecoration,
fontWeight: ((_c = pen.tickLabel) === null || _c === void 0 ? void 0 : _c.fontWeight) || pen.calculative.fontWeight,
fontFamily: ((_d = pen.tickLabel) === null || _d === void 0 ? void 0 : _d.fontFamily) || pen.calculative.fontFamily,
fontSize: (((_e = pen.tickLabel) === null || _e === void 0 ? void 0 : _e.fontSize) || pen.calculative.fontSize) * scale,
lineHeight: ((_f = pen.tickLabel) === null || _f === void 0 ? void 0 : _f.lineHeight) || pen.calculative.lineHeight,
let valueGap = pen.max - pen.min;
let interval = valueGap / pen.splitNumber;
let fontOption = {
fontStyle: pen.tickLabel?.fontStyle || pen.calculative.fontStyle,
textDecoration: pen.tickLabel?.textDecoration || pen.textDecoration,
fontWeight: pen.tickLabel?.fontWeight || pen.calculative.fontWeight,
fontFamily: pen.tickLabel?.fontFamily || pen.calculative.fontFamily,
fontSize: (pen.tickLabel?.fontSize || pen.calculative.fontSize) * scale,
lineHeight: pen.tickLabel?.lineHeight || pen.calculative.lineHeight,
};
ctx.font = getFont(fontOption);
var textR = r - bgLineWidth - r / 20;
for (var i = 0; i <= pen.splitNumber; i++) {
let textR = r - bgLineWidth - r / 20;
for (let i = 0; i <= pen.splitNumber; i++) {
if (Math.abs(pen.startAngle) + Math.abs(pen.endAngle) === 360) {

@@ -147,6 +135,6 @@ //形成一个圆形

}
var angle = pen.startAngle - ((interval * i) / valueGap) * gap;
var width = Math.cos((angle / 180) * Math.PI);
var height = Math.sin((angle / 180) * Math.PI);
ctx.fillStyle = ((_g = pen.tickLabel) === null || _g === void 0 ? void 0 : _g.color) || '#999999';
let angle = pen.startAngle - ((interval * i) / valueGap) * gap;
let width = Math.cos((angle / 180) * Math.PI);
let height = Math.sin((angle / 180) * Math.PI);
ctx.fillStyle = pen.tickLabel?.color || '#999999';
if (width > 0.02) {

@@ -175,4 +163,4 @@ ctx.textAlign = 'end';

//绘制指针
var pointNum = 1;
var valueArray = ['value'];
let pointNum = 1;
let valueArray = ['value'];
if (pen.isClock) {

@@ -183,4 +171,4 @@ pointNum = 3;

if (pen.isClock) {
for (var i = 0; i < pointNum; i++) {
var currentAngle = ((pen.startAngle -
for (let i = 0; i < pointNum; i++) {
let currentAngle = ((pen.startAngle -
((pen[valueArray[i]] - pen.min) / (pen.max - pen.min)) * gap) /

@@ -196,3 +184,3 @@ 180) *

}
var pointerR = (4 / 5) * r;
let pointerR = (4 / 5) * r;
if (valueArray[i] === 'hourvalue') {

@@ -204,3 +192,3 @@ pointerR = (3 / 5) * r;

}
var pointerHalfW = (r * 1) / 40;
let pointerHalfW = (r * 1) / 40;
ctx.beginPath();

@@ -216,7 +204,7 @@ ctx.setLineDash([]);

else {
var currentAngle = ((pen.startAngle - ((value - pen.min) / (pen.max - pen.min)) * gap) /
let currentAngle = ((pen.startAngle - ((value - pen.min) / (pen.max - pen.min)) * gap) /
180) *
Math.PI;
var pointerR = (4 / 5) * r;
var pointerHalfW = (r * 1) / 40;
let pointerR = (4 / 5) * r;
let pointerHalfW = (r * 1) / 40;
ctx.beginPath();

@@ -237,12 +225,12 @@ ctx.setLineDash([]);

ctx.textBaseline = 'middle';
var titleOption = {
fontStyle: ((_h = pen.titleLabel) === null || _h === void 0 ? void 0 : _h.fontStyle) || pen.calculative.fontStyle,
textDecoration: ((_j = pen.titleLabel) === null || _j === void 0 ? void 0 : _j.textDecoration) || pen.textDecoration,
fontWeight: ((_k = pen.titleLabel) === null || _k === void 0 ? void 0 : _k.fontWeight) || pen.calculative.fontWeight,
fontFamily: ((_l = pen.titleLabel) === null || _l === void 0 ? void 0 : _l.fontFamily) || pen.calculative.fontFamily,
fontSize: (((_m = pen.titleLabel) === null || _m === void 0 ? void 0 : _m.fontSize) || pen.calculative.fontSize) * scale,
lineHeight: ((_o = pen.titleLabel) === null || _o === void 0 ? void 0 : _o.lineHeight) || pen.calculative.lineHeight,
let titleOption = {
fontStyle: pen.titleLabel?.fontStyle || pen.calculative.fontStyle,
textDecoration: pen.titleLabel?.textDecoration || pen.textDecoration,
fontWeight: pen.titleLabel?.fontWeight || pen.calculative.fontWeight,
fontFamily: pen.titleLabel?.fontFamily || pen.calculative.fontFamily,
fontSize: (pen.titleLabel?.fontSize || pen.calculative.fontSize) * scale,
lineHeight: pen.titleLabel?.lineHeight || pen.calculative.lineHeight,
};
ctx.font = getFont(titleOption);
ctx.fillStyle = ((_p = pen.titleLabel) === null || _p === void 0 ? void 0 : _p.color) || pointColor;
ctx.fillStyle = pen.titleLabel?.color || pointColor;
if (pen.isClock) {

@@ -271,7 +259,7 @@ ctx.fillText(('0' + parseInt(pen.hourvalue)).slice(-2) +

if (pen.isClock) {
pen.clockInterval = setInterval(function () {
var date = new Date();
var second = date.getSeconds();
var minute = date.getMinutes() + second / 60;
var hour = (date.getHours() % 12) + minute / 60;
pen.clockInterval = setInterval(() => {
let date = new Date();
let second = date.getSeconds();
let minute = date.getMinutes() + second / 60;
let hour = (date.getHours() % 12) + minute / 60;
pen.calculative.canvas.parent.setValue({

@@ -289,3 +277,3 @@ id: pen.id,

else {
var tem_1 = pen.value;
const tem = pen.value;
pen.value = 0;

@@ -295,8 +283,8 @@ pen.frames = [

duration: 2000,
value: tem_1,
value: tem,
},
];
pen.calculative.canvas.parent.startAnimate(pen.id);
setTimeout(function () {
pen.value = tem_1;
setTimeout(() => {
pen.value = tem;
}, 1000);

@@ -303,0 +291,0 @@ }

import { leChartPen } from './common';
export declare function histogram(ctx: CanvasRenderingContext2D, pen: leChartPen): void;

@@ -8,8 +8,8 @@ import { coordinateAxis } from './coordinateAxis';

}
var scale = pen.calculative.canvas.store.data.scale;
var x = pen.calculative.worldRect.x;
var y = pen.calculative.worldRect.y;
var w = pen.calculative.worldRect.width;
var h = pen.calculative.worldRect.height;
var series = [];
let scale = pen.calculative.canvas.store.data.scale;
const x = pen.calculative.worldRect.x;
const y = pen.calculative.worldRect.y;
const w = pen.calculative.worldRect.width;
const h = pen.calculative.worldRect.height;
let series = [];
if (pen.echarts && !pen.echarts.option.color) {

@@ -27,3 +27,3 @@ pen.echarts.option.color = [

if (pen.echarts) {
for (var i = 0; i < pen.echarts.option.series.length; i++) {
for (let i = 0; i < pen.echarts.option.series.length; i++) {
series.push(pen.echarts.option.series[i].data);

@@ -35,10 +35,10 @@ }

}
var coordinate = coordinateAxis(ctx, pen);
var dash = coordinate.dash;
var normalizedOption = coordinate.normalizedOption;
var itemWidth = (dash * 4) / 5 / series.length;
let coordinate = coordinateAxis(ctx, pen);
let dash = coordinate.dash;
let normalizedOption = coordinate.normalizedOption;
let itemWidth = (dash * 4) / 5 / series.length;
// ctx.strokeStyle = '#ffffff';
for (var j = 0; j < series.length; j++) {
for (let j = 0; j < series.length; j++) {
ctx.beginPath();
var data = series[j];
let data = series[j];
ctx.fillStyle = pen.echarts

@@ -49,6 +49,6 @@ ? pen.echarts.option.color[j]

ctx.lineWidth = 1 * scale;
var currentX = 0;
var currentY = 0;
var currentH = 0;
for (var i = 0; i < data.length; i++) {
let currentX = 0;
let currentY = 0;
let currentH = 0;
for (let i = 0; i < data.length; i++) {
currentX = x + (1 + 0.1 * dash) + (dash + 1) * i + itemWidth * j;

@@ -55,0 +55,0 @@ currentH =

import { leChartPen } from './common';
export declare function lineChart(ctx: CanvasRenderingContext2D, pen: leChartPen): void;
export declare function beforeValue(pen: leChartPen, value: any): any;

@@ -1,26 +0,1 @@

var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
import { coordinateAxis } from './coordinateAxis';

@@ -33,8 +8,8 @@ import { ReplaceMode } from './common';

}
var x = pen.calculative.worldRect.x;
var y = pen.calculative.worldRect.y;
var w = pen.calculative.worldRect.width;
var h = pen.calculative.worldRect.height;
var scale = pen.calculative.canvas.store.data.scale;
var series = [];
const x = pen.calculative.worldRect.x;
const y = pen.calculative.worldRect.y;
const w = pen.calculative.worldRect.width;
const h = pen.calculative.worldRect.height;
let scale = pen.calculative.canvas.store.data.scale;
let series = [];
if (pen.echarts && !pen.echarts.option.color) {

@@ -51,12 +26,12 @@ pen.echarts.option.color = [

}
var coordinate = coordinateAxis(ctx, pen);
var dash = coordinate.dash;
var normalizedOption = coordinate.normalizedOption;
let coordinate = coordinateAxis(ctx, pen);
let dash = coordinate.dash;
let normalizedOption = coordinate.normalizedOption;
//数据值绘制
var smooth = (pen.echarts ? pen.echarts.option.series[0].smooth : pen.smooth)
const smooth = (pen.echarts ? pen.echarts.option.series[0].smooth : pen.smooth)
? true
: false;
var coordinateValue = [];
let coordinateValue = [];
if (pen.echarts) {
for (var i = 0; i < pen.echarts.option.series.length; i++) {
for (let i = 0; i < pen.echarts.option.series.length; i++) {
series.push(pen.echarts.option.series[i].data);

@@ -68,5 +43,5 @@ }

}
var _loop_1 = function (j) {
for (let j = 0; j < series.length; j++) {
ctx.beginPath();
var data = series[j];
let data = series[j];
ctx.strokeStyle = pen.echarts

@@ -78,4 +53,4 @@ ? pen.echarts.option.color[j]

: pen.chartsColor[j];
var currentX = x + (1 + dash / 2);
var currentY = y +
let currentX = x + (1 + dash / 2);
let currentY = y +
h -

@@ -91,3 +66,3 @@ ((data[0] - normalizedOption.min) /

//小于两个点的情况无法构成贝塞尔
for (var i = 1; i < data.length; i++) {
for (let i = 1; i < data.length; i++) {
currentX = x + (1 + dash / 2) + (dash + 1) * i;

@@ -105,4 +80,4 @@ currentY =

else {
var cAx_1, cAy_1, cBx_1, cBy_1;
data.forEach(function (item, index) {
let cAx, cAy, cBx, cBy;
data.forEach((item, index) => {
currentX = x + (1 + dash / 2) + (dash + 1) * index;

@@ -115,4 +90,4 @@ currentY =

h;
var last1x = x + (1 + dash / 2) + (dash + 1) * (index + 1);
var last1y = y +
let last1x = x + (1 + dash / 2) + (dash + 1) * (index + 1);
let last1y = y +
h -

@@ -122,4 +97,4 @@ ((data[index + 1] - normalizedOption.min) /

h;
var before1x = x + (1 + dash / 2) + (dash + 1) * (index - 1);
var before1y = y +
let before1x = x + (1 + dash / 2) + (dash + 1) * (index - 1);
let before1y = y +
h -

@@ -129,4 +104,4 @@ ((data[index - 1] - normalizedOption.min) /

h;
var last2x = x + (1 + dash / 2) + (dash + 1) * (index + 2);
var last2y = y +
let last2x = x + (1 + dash / 2) + (dash + 1) * (index + 2);
let last2y = y +
h -

@@ -157,7 +132,7 @@ ((data[index + 2] - normalizedOption.min) /

coordinateValue.push({ x: currentX, y: currentY });
cAx_1 = currentX + (last1x - before1x) / 4;
cAy_1 = currentY + (last1y - before1y) / 4;
cBx_1 = last1x - (last2x - currentX) / 4;
cBy_1 = last1y - (last2y - currentY) / 4;
ctx.bezierCurveTo(cAx_1, cAy_1, cBx_1, cBy_1, last1x, last1y);
cAx = currentX + (last1x - before1x) / 4;
cAy = currentY + (last1y - before1y) / 4;
cBx = last1x - (last2x - currentX) / 4;
cBy = last1y - (last2y - currentY) / 4;
ctx.bezierCurveTo(cAx, cAy, cBx, cBy, last1x, last1y);
//绘制到下一个节点的贝塞尔曲线

@@ -168,3 +143,3 @@ });

else {
for (var i = 1; i < data.length; i++) {
for (let i = 1; i < data.length; i++) {
currentX = x + (1 + dash / 2) + (dash + 1) * i;

@@ -184,3 +159,3 @@ currentY =

ctx.save();
coordinateValue.forEach(function (item, index) {
coordinateValue.forEach((item, index) => {
ctx.beginPath();

@@ -196,5 +171,2 @@ ctx.strokeStyle = '#fff';

coordinateValue = [];
};
for (var j = 0; j < series.length; j++) {
_loop_1(j);
}

@@ -207,12 +179,12 @@ }

}
var _xAxisData = pen.xAxisData;
var _data = pen.data;
var replaceMode = pen.replaceMode;
var xAxisData = [];
var data = [];
const _xAxisData = pen.xAxisData;
const _data = pen.data;
const replaceMode = pen.replaceMode;
let xAxisData = [];
let data = [];
if (!replaceMode) {
//追加
xAxisData = __spreadArray(__spreadArray([], __read(_xAxisData), false), __read(value.dataX), false);
_data.forEach(function (item, index) {
var _item = __spreadArray(__spreadArray([], __read(item), false), __read(value.dataY[index]), false);
xAxisData = [..._xAxisData, ...value.dataX];
_data.forEach((item, index) => {
let _item = [...item, ...value.dataY[index]];
data.push(_item);

@@ -223,5 +195,5 @@ });

//替换部分
value.dataX.forEach(function (item, i) {
var _index = _xAxisData.indexOf(item);
_data.forEach(function (d, index) {
value.dataX.forEach((item, i) => {
let _index = _xAxisData.indexOf(item);
_data.forEach((d, index) => {
d[_index] = value.dataY[index][i];

@@ -240,4 +212,4 @@ });

delete value.dataY;
return Object.assign(value, { xAxisData: xAxisData, data: data });
return Object.assign(value, { xAxisData, data });
}
//# sourceMappingURL=lineChart.js.map

@@ -0,0 +0,0 @@ export interface ScaleOption {

@@ -1,14 +0,3 @@

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
// 双精度浮点数有效数字为15位
var maxDecimal = 15;
const maxDecimal = 15;
/**

@@ -22,5 +11,4 @@ * 解决js的浮点数存在精度问题,在计算出最后结果时可以四舍五入一次,刻度太小也没有意义

*/
export function fixedNum(num, decimal) {
if (decimal === void 0) { decimal = maxDecimal; }
var str = '' + num;
export function fixedNum(num, decimal = maxDecimal) {
let str = '' + num;
if (str.indexOf('.') >= 0)

@@ -48,10 +36,18 @@ str = Number.parseFloat(str).toFixed(decimal);

export function scaleCompute(option) {
option = __assign({ max: null, min: null, splitNumber: 4, symmetrical: false, deviation: false, preferZero: false }, option);
var magics = [
option = {
max: null,
min: null,
splitNumber: 4, // splitNumber建议取4或者5等这种容易被整除的数字
symmetrical: false,
deviation: false,
preferZero: false,
...option,
};
const magics = [
10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100, 150,
]; // 加入150形成闭环
// tslint:disable-next-line: prefer-const
var dataMax = option.max, dataMin = option.min, splitNumber = option.splitNumber, symmetrical = option.symmetrical, deviation = option.deviation, preferZero = option.preferZero;
let { max: dataMax, min: dataMin, splitNumber, symmetrical, deviation, preferZero, } = option;
if (!numberValid(dataMax) || !numberValid(dataMin) || dataMax < dataMin) {
return { splitNumber: splitNumber };
return { splitNumber };
}

@@ -63,3 +59,3 @@ else if (dataMax === dataMin && dataMax === 0) {

interval: magics[0],
splitNumber: splitNumber,
splitNumber,
};

@@ -78,9 +74,9 @@ }

}
var tempGap = (dataMax - dataMin) / splitNumber;
var multiple = Math.floor(Math.log10(tempGap) - 1); // 指数
const tempGap = (dataMax - dataMin) / splitNumber;
let multiple = Math.floor(Math.log10(tempGap) - 1); // 指数
multiple = Math.pow(10, multiple);
var tempStep = tempGap / multiple;
var expectedStep = magics[0] * multiple;
var storedMagicsIndex = -1;
var index; // 当前魔数下标
const tempStep = tempGap / multiple;
let expectedStep = magics[0] * multiple;
let storedMagicsIndex = -1;
let index; // 当前魔数下标
for (index = 0; index < magics.length; index++) {

@@ -92,4 +88,4 @@ if (magics[index] > tempStep) {

}
var axisMax = dataMax;
var axisMin = dataMin;
let axisMax = dataMax;
let axisMin = dataMin;
function countDegree(step) {

@@ -103,3 +99,3 @@ axisMax = parseInt('' + (dataMax / step + 1)) * step; // parseInt令小数去尾 -1.8 -> -1

if (symmetrical && axisMax * axisMin < 0) {
var tm = Math.max(Math.abs(axisMax), Math.abs(axisMin));
const tm = Math.max(Math.abs(axisMax), Math.abs(axisMin));
axisMax = tm;

@@ -119,3 +115,3 @@ axisMin = -tm;

else if (!symmetrical || axisMax * axisMin > 0) {
var tempSplitNumber = void 0;
let tempSplitNumber;
out: do {

@@ -152,10 +148,10 @@ tempSplitNumber = Math.round((axisMax - axisMin) / expectedStep);

axisMin = fixedNum(axisMin);
var interval = fixedNum((axisMax - axisMin) / splitNumber);
const interval = fixedNum((axisMax - axisMin) / splitNumber);
return {
max: axisMax,
min: axisMin,
interval: interval,
splitNumber: splitNumber,
interval,
splitNumber,
};
}
//# sourceMappingURL=normalizedAxis.js.map
import { leChartPen } from './common';
export declare function pieChart(ctx: CanvasRenderingContext2D, pen: leChartPen): void;

@@ -1,26 +0,1 @@

var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
import { ReplaceMode } from './common';

@@ -30,3 +5,2 @@ import { getFont } from "@meta2d/core";

export function pieChart(ctx, pen) {
var _a, _b;
if (!pen.onBeforeValue) {

@@ -36,8 +10,8 @@ pen.onBeforeValue = beforeValue;

// 缩放模式
var scale = pen.calculative.canvas.store.data.scale;
var x = pen.calculative.worldRect.x;
var y = pen.calculative.worldRect.y;
var w = pen.calculative.worldRect.width;
var h = pen.calculative.worldRect.height;
var isEcharts = pen.echarts ? true : false;
let scale = pen.calculative.canvas.store.data.scale;
const x = pen.calculative.worldRect.x;
const y = pen.calculative.worldRect.y;
const w = pen.calculative.worldRect.width;
const h = pen.calculative.worldRect.height;
const isEcharts = pen.echarts ? true : false;
// if (pen.echarts && !pen.echarts.option.color) {

@@ -91,15 +65,15 @@ // pen.echarts.option.color = [

}
var seriesArray = isEcharts ? pen.echarts.option.series : pen.data;
var beforeSeriesLength = 0;
var _loop_1 = function (ser) {
var series = seriesArray[ser];
var r = w / 2;
const seriesArray = isEcharts ? pen.echarts.option.series : pen.data;
let beforeSeriesLength = 0;
for (let ser = 0; ser < seriesArray.length; ser++) {
let series = seriesArray[ser];
let r = w / 2;
if (h < w) {
r = h / 2;
}
var centerX = x + w / 2;
var centerY = y + h / 2;
var sum = 0;
const centerX = x + w / 2;
const centerY = y + h / 2;
let sum = 0;
if (isEcharts) {
sum = series.data.reduce(function (prev, curr) {
sum = series.data.reduce((prev, curr) => {
return prev + curr.value;

@@ -109,27 +83,26 @@ }, 0);

else {
sum = series.reduce(function (prev, curr) {
sum = series.reduce((prev, curr) => {
return prev + curr.value;
}, 0);
}
var fromR = (r *
const fromR = (r *
parseFloat(isEcharts ? series.radius[0] : pen.chartsRadius[ser][0])) /
100;
var toR = (r *
const toR = (r *
parseFloat(isEcharts ? series.radius[1] : pen.chartsRadius[ser][1])) /
100;
if (fromR > toR) {
return { value: void 0 };
return;
}
var beforeAngle = 0;
var afterAngle = 0;
let beforeAngle = 0;
let afterAngle = 0;
ctx.strokeStyle = isEcharts
? ((_a = series.itemStyle) === null || _a === void 0 ? void 0 : _a.borderColor) || '#fff'
? series.itemStyle?.borderColor || '#fff'
: '#fff';
ctx.lineWidth = (isEcharts ? ((_b = series.itemStyle) === null || _b === void 0 ? void 0 : _b.borderWidth) || 2 : 2) * scale;
var data = isEcharts ? series.data : series;
data.forEach(function (item, index) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
ctx.lineWidth = (isEcharts ? series.itemStyle?.borderWidth || 2 : 2) * scale;
const data = isEcharts ? series.data : series;
data.forEach((item, index) => {
afterAngle += (Math.PI * 2 * item.value) / sum;
ctx.beginPath();
var colorLength = beforeSeriesLength + index;
let colorLength = beforeSeriesLength + index;
if (colorLength >= pen.chartsColor.length) {

@@ -150,6 +123,6 @@ colorLength = colorLength % pen.chartsColor.length;

//绘制label
var centerAngle = (beforeAngle + afterAngle) / 2;
var temX = centerX + (toR + 10 * scale) * Math.sin(centerAngle);
var temY = centerY - (toR + 10 * scale) * Math.cos(centerAngle);
var temFillStyle = ctx.fillStyle;
let centerAngle = (beforeAngle + afterAngle) / 2;
let temX = centerX + (toR + 10 * scale) * Math.sin(centerAngle);
let temY = centerY - (toR + 10 * scale) * Math.cos(centerAngle);
let temFillStyle = ctx.fillStyle;
if (!series.label) {

@@ -176,8 +149,8 @@ series.label = { position: 'outside', show: true };

}
var fontOption = {
fontStyle: ((_a = pen.tickLabel) === null || _a === void 0 ? void 0 : _a.fontStyle) || pen.calculative.fontStyle,
fontWeight: ((_b = pen.tickLabel) === null || _b === void 0 ? void 0 : _b.fontWeight) || pen.calculative.fontWeight,
fontFamily: ((_c = pen.tickLabel) === null || _c === void 0 ? void 0 : _c.fontFamily) || pen.calculative.fontFamily,
lineHeight: ((_d = pen.tickLabel) === null || _d === void 0 ? void 0 : _d.lineHeight) || pen.calculative.lineHeight,
fontSize: (((_e = pen.tickLabel) === null || _e === void 0 ? void 0 : _e.fontSize) || pen.calculative.fontSize) * scale
let fontOption = {
fontStyle: pen.tickLabel?.fontStyle || pen.calculative.fontStyle,
fontWeight: pen.tickLabel?.fontWeight || pen.calculative.fontWeight,
fontFamily: pen.tickLabel?.fontFamily || pen.calculative.fontFamily,
lineHeight: pen.tickLabel?.lineHeight || pen.calculative.lineHeight,
fontSize: (pen.tickLabel?.fontSize || pen.calculative.fontSize) * scale
};

@@ -192,6 +165,6 @@ ctx.font = getFont(fontOption); // r / 10 + 'px AlibabaPuHuiTi-Regular, Alibaba PuHuiTi';

}
if ((isEcharts && series.labelLine.show !== false) || (!isEcharts && ((_h = (_g = (_f = pen.tickLabel) === null || _f === void 0 ? void 0 : _f.labelLine) === null || _g === void 0 ? void 0 : _g.show) !== null && _h !== void 0 ? _h : true))) {
if ((isEcharts && series.labelLine.show !== false) || (!isEcharts && (pen.tickLabel?.labelLine?.show ?? true))) {
ctx.lineTo(temX - 5 * scale, temY);
}
if ((isEcharts && series.label.show !== false) || (!isEcharts && ((_k = (_j = pen.tickLabel) === null || _j === void 0 ? void 0 : _j.show) !== null && _k !== void 0 ? _k : true))) {
if ((isEcharts && series.label.show !== false) || (!isEcharts && (pen.tickLabel?.show ?? true))) {
ctx.fillText(item.name, temX - 5 * scale, temY);

@@ -207,3 +180,3 @@ }

}
if ((isEcharts && series.label.show !== false) || (!isEcharts && ((_m = (_l = pen.tickLabel) === null || _l === void 0 ? void 0 : _l.show) !== null && _m !== void 0 ? _m : true))) {
if ((isEcharts && series.label.show !== false) || (!isEcharts && (pen.tickLabel?.show ?? true))) {
ctx.fillText(item.name, temX + 5 * scale, temY);

@@ -216,3 +189,3 @@ }

ctx.strokeStyle = isEcharts
? ((_o = series.itemStyle) === null || _o === void 0 ? void 0 : _o.borderColor) || '#fff'
? series.itemStyle?.borderColor || '#fff'
: '#fff';

@@ -222,7 +195,2 @@ beforeAngle = afterAngle;

beforeSeriesLength += data.length;
};
for (var ser = 0; ser < seriesArray.length; ser++) {
var state_1 = _loop_1(ser);
if (typeof state_1 === "object")
return state_1.value;
}

@@ -235,9 +203,9 @@ }

}
var _data = pen.data;
var replaceMode = pen.replaceMode;
var data = [];
const _data = pen.data;
const replaceMode = pen.replaceMode;
let data = [];
if (!replaceMode) {
//追加
_data.forEach(function (item, index) {
var _item = __spreadArray(__spreadArray([], __read(item), false), __read(value.dataY[index]), false);
_data.forEach((item, index) => {
let _item = [...item, ...value.dataY[index]];
data.push(_item);

@@ -248,5 +216,5 @@ });

//替换部分
value.dataY.forEach(function (item, index) {
item.forEach(function (_innerItem, _innderIndex) {
var _filterItem = _data[index].filter(function (_i) { return _i.name === _innerItem.name; });
value.dataY.forEach((item, index) => {
item.forEach((_innerItem, _innderIndex) => {
let _filterItem = _data[index].filter((_i) => _i.name === _innerItem.name);
if (_filterItem.length > 0) {

@@ -265,4 +233,4 @@ _filterItem[0].value = _innerItem.value;

delete value.dataY;
return Object.assign(value, { data: data });
return Object.assign(value, { data });
}
//# sourceMappingURL=pieChart.js.map

@@ -0,0 +0,0 @@ import { lineChart } from './lineChart';

@@ -7,8 +7,8 @@ import { lineChart } from './lineChart';

return {
lineChart: lineChart,
histogram: histogram,
pieChart: pieChart,
gauge: gauge,
lineChart,
histogram,
pieChart,
gauge,
};
}
//# sourceMappingURL=register.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc