Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: adjust for interactive graph #23

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {parse, compare} from "./kas/src";
import {init, Widgets, Renderer, Dependencies} from "./perseus/src";
import Interactive2 from "./perseus/src/interactive2";
import KhanUtils from "./perseus/src/util";
import KhanAnswerTypesUtils from "./perseus/src/util/answer-types";
import {similar} from "./perseus/src/util/geometry";
import GraphUtils from "./perseus/src/util/graphie";
import KhanMath from "./perseus/src/util/math";

Expand All @@ -20,6 +22,8 @@ export interface PerseusCore {
KhanUtils: typeof KhanUtils;
KhanAnswerTypesUtils: typeof KhanAnswerTypesUtils;
KhanMath: typeof KhanMath;
Interactive2: typeof Interactive2;
similar: typeof similar;
parseTex: (
tex: string,
options?: TexOptions,
Expand Down Expand Up @@ -47,6 +51,8 @@ export {
KhanUtils,
KhanAnswerTypesUtils,
KhanMath,
Interactive2,
similar as similarCoords,
};

export type {WidgetExports} from "./perseus/src";
2 changes: 1 addition & 1 deletion packages/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@junyiacademy/perseus-core",
"version": "1.0.36",
"version": "1.0.37",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"license": "MIT",
Expand Down
25 changes: 15 additions & 10 deletions packages/perseus/src/util/graphie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1303,16 +1303,17 @@ GraphUtils.createGraphie = function (el: any) {
unityLabels = [unityLabels, unityLabels];
}

if (smartLabelPositioning) {
const minusIgnorer = function (lf: any) {
return function (a) {
return (lf(a) + "").replace(/-(\d)/g, "\\llap{-}$1");
};
};

xLabelFormat = minusIgnorer(xLabelFormat);
yLabelFormat = minusIgnorer(yLabelFormat);
}
// comment for 讓座標軸上的數字可以不用以 latex 呈現
// if (smartLabelPositioning) {
// const minusIgnorer = function (lf: any) {
// return function (a) {
// return (lf(a) + "").replace(/-(\d)/g, "\\llap{-}$1");
// };
// };

// xLabelFormat = minusIgnorer(xLabelFormat);
// yLabelFormat = minusIgnorer(yLabelFormat);
// }

this.init({
range: realRange,
Expand Down Expand Up @@ -1550,6 +1551,7 @@ GraphUtils.createGraphie = function (el: any) {
[x, axisCenter[1]],
xLabelFormat(x),
xAxisPosition,
false,
);
}
}
Expand All @@ -1566,6 +1568,7 @@ GraphUtils.createGraphie = function (el: any) {
[x, axisCenter[1]],
xLabelFormat(x),
xAxisPosition,
false,
);
}
}
Expand All @@ -1586,6 +1589,7 @@ GraphUtils.createGraphie = function (el: any) {
[axisCenter[0], y],
yLabelFormat(y),
yAxisPosition,
false,
);
}
}
Expand All @@ -1602,6 +1606,7 @@ GraphUtils.createGraphie = function (el: any) {
[axisCenter[0], y],
yLabelFormat(y),
yAxisPosition,
false,
);
}
}
Expand Down
Loading