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

@meta2d/chart-diagram

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meta2d/chart-diagram - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

2

package.json
{
"name": "@meta2d/chart-diagram",
"version": "1.0.5",
"version": "1.0.6",
"description": "The charting library based on le5le meta2d and echarts/highcharts.",

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

@@ -19,3 +19,2 @@ import { BindId, Pen } from '@meta2d/core';

};
beforeScale: number;
}

@@ -22,0 +21,0 @@ export declare function echarts(pen: ChartPen): Path2D;

@@ -26,3 +26,3 @@ var __read = (this && this.__read) || function (o, n) {

};
import { setElemPosition, } from '@meta2d/core';
import { deepClone, setElemPosition, } from '@meta2d/core';
import { deepSetValue } from '@meta2d/core';

@@ -37,4 +37,5 @@ import { getter } from '@meta2d/core/src/utils/object';

})(ReplaceMode || (ReplaceMode = {}));
var keyWords = ['fontSize', 'nameGap'];
export function echarts(pen) {
var _a;
var _a, _b;
var echarts = globalThis.echarts;

@@ -53,2 +54,6 @@ if (!pen.echarts || !echarts) {

}
keyWords =
((_a = pen.calculative.canvas.store.options.diagramOptions['chart']) === null || _a === void 0 ? void 0 : _a.keyWords) ||
keyWords;
console.log('keyWords');
if (!pen.onDestroy) {

@@ -63,3 +68,3 @@ pen.onDestroy = destory;

pen.onMouseEnter = move;
pen.onAdd = onAdd;
// pen.onAdd = onAdd;
pen.onRenderPenRaw = onRenderPenRaw;

@@ -83,3 +88,3 @@ }

// 2. 加载到div layer
(_a = pen.calculative.canvas.externalElements) === null || _a === void 0 ? void 0 : _a.parentElement.appendChild(div);
(_b = pen.calculative.canvas.externalElements) === null || _b === void 0 ? void 0 : _b.parentElement.appendChild(div);
setElemPosition(pen, div);

@@ -110,3 +115,3 @@ // 3. 解析echarts数据

pen.calculative.singleton.echartsReady = true;
pen.calculative.singleton.echart.setOption(pen.echarts.option, true);
pen.calculative.singleton.echart.setOption(updateOption(pen.echarts.option, pen.calculative.canvas.store.data.scale), true);
setTimeout(function () {

@@ -123,3 +128,3 @@ onRenderPenRaw(pen);

setTimeout(function () {
pen.calculative.singleton.echart.setOption(pen.echarts.option, true);
pen.calculative.singleton.echart.setOption(updateOption(pen.echarts.option, pen.calculative.canvas.store.data.scale), true);
setTimeout(function () { return onRenderPenRaw(pen); }, 300);

@@ -131,5 +136,5 @@ });

}
function onAdd(pen) {
pen.beforeScale = pen.calculative.canvas.store.data.scale;
}
// function onAdd(pen: ChartPen) {
// // pen.beforeScale = pen.calculative.canvas.store.data.scale;
// }
function destory(pen) {

@@ -153,43 +158,10 @@ if (pen.calculative.singleton && pen.calculative.singleton.div) {

setElemPosition(pen, pen.calculative.singleton.div);
var option = pen.echarts.option;
if (!pen.beforeScale) {
pen.beforeScale = pen.calculative.canvas.store.data.scale;
}
var ratio = pen.calculative.canvas.store.data.scale / pen.beforeScale;
if (option.grid) {
var props_1 = ['top', 'bottom', 'left', 'right'];
var _loop_1 = function (i) {
if (Array.isArray(option.grid)) {
option.grid.forEach(function (item) {
if (!isNaN(item[props_1[i]])) {
item[props_1[i]] *= ratio;
}
});
}
else {
if (!isNaN(option.grid[props_1[i]])) {
option.grid[props_1[i]] *= ratio;
}
}
};
for (var i = 0; i < props_1.length; i++) {
_loop_1(i);
}
}
if (option.dataZoom) {
var props_2 = ['right', 'top', 'width', 'height', 'left', 'bottom'];
var _loop_2 = function (i) {
option.dataZoom.forEach(function (item) {
if (!isNaN(item[props_2[i]])) {
item[props_2[i]] *= ratio;
}
});
};
for (var i = 0; i < props_2.length; i++) {
_loop_2(i);
}
}
deepSetValue(option, 'fontSize', ratio);
pen.calculative.singleton.echart.setOption(option, true);
pen.beforeScale = pen.calculative.canvas.store.data.scale;
// let option = pen.echarts.option;
// if (!pen.beforeScale) {
// pen.beforeScale = pen.calculative.canvas.store.data.scale;
// }
// let ratio: number = pen.calculative.canvas.store.data.scale / pen.beforeScale;
// updateOption(option, ratio);
pen.calculative.singleton.echart.setOption(updateOption(pen.echarts.option, pen.calculative.canvas.store.data.scale), true);
// pen.beforeScale = pen.calculative.canvas.store.data.scale;
pen.calculative.singleton.echart.resize();

@@ -203,3 +175,3 @@ }

pen.calculative.singleton.echartsReady &&
pen.calculative.singleton.echart.setOption(pen.echarts.option, true);
pen.calculative.singleton.echart.setOption(updateOption(pen.echarts.option, pen.calculative.canvas.store.data.scale), true);
}

@@ -557,2 +529,40 @@ function beforeValue(pen, value) {

}
function updateOption(_option, ratio) {
var option = deepClone(_option);
if (option.grid) {
var props_1 = ['top', 'bottom', 'left', 'right'];
var _loop_1 = function (i) {
if (Array.isArray(option.grid)) {
option.grid.forEach(function (item) {
if (!isNaN(item[props_1[i]])) {
item[props_1[i]] *= ratio;
}
});
}
else {
if (!isNaN(option.grid[props_1[i]])) {
option.grid[props_1[i]] *= ratio;
}
}
};
for (var i = 0; i < props_1.length; i++) {
_loop_1(i);
}
}
if (option.dataZoom) {
var props_2 = ['right', 'top', 'width', 'height', 'left', 'bottom'];
var _loop_2 = function (i) {
option.dataZoom.forEach(function (item) {
if (!isNaN(item[props_2[i]])) {
item[props_2[i]] *= ratio;
}
});
};
for (var i = 0; i < props_2.length; i++) {
_loop_2(i);
}
}
deepSetValue(option, keyWords, ratio);
return option;
}
//# sourceMappingURL=echarts.js.map

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