Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Gk0Wk committed Oct 23, 2023
1 parent 7a915dc commit 0411e50
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
20 changes: 0 additions & 20 deletions src/echarts/addons/Gk0Wk/Function/Function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,10 @@ const addon: IScriptAddon<void> = {
// 采样
const points = [];
const step = (maxX - minX) / Math.min(resolution, 1e5);
let minY = Infinity;
let maxY = -Infinity;
for (let x = minX; x <= maxX; x += step) {
const y = func(x);
points.push([x, y]);
if (!Number.isNaN(y) && Number.isFinite(y)) {
minY = Math.min(minY, y);
maxY = Math.max(maxY, y);
}
}
if (!Number.isFinite(minY)) {
minY = 0;
}
if (!Number.isFinite(maxY)) {
maxY = 0;
}
minY -= Math.max(1e-8, maxY - minY) * 5e-3;
maxY += Math.max(1e-8, maxY - minY) * 5e-3;
minX -= Math.max(1e-8, maxX - minX) * 5e-3;
maxX += Math.max(1e-8, maxX - minX) * 5e-3;
myChart.setOption({
animation: false,
grid: {
Expand All @@ -61,15 +45,11 @@ const addon: IScriptAddon<void> = {
tooltip: { trigger: 'axis' },
xAxis: {
name: 'x',
min: minX,
max: maxX,
minorTick: { show: true },
minorSplitLine: { show: true },
},
yAxis: {
name: addonAttributes.yaxis || 'f(x)',
min: minY,
max: maxY,
minorTick: { show: true },
minorSplitLine: { show: true },
},
Expand Down
2 changes: 1 addition & 1 deletion src/echarts/plugin.info
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.2.9",
"version": "0.2.10",
"type": "application/json",
"title": "$:/plugins/Gk0Wk/echarts",
"plugin-type": "plugin",
Expand Down

0 comments on commit 0411e50

Please sign in to comment.