@pie-element/charting 12.1.3 → 12.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/configure/CHANGELOG.md +6 -0
- package/configure/package.json +4 -4
- package/docs/demo/generate.js +8 -5
- package/lib/index.js +42 -3
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [12.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting@12.1.3...@pie-element/charting@12.1.4) (2026-06-17)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
|
|
11
|
+
- **graphing, charting:** render title/label math on first paint via observer PIE-688 ([95a4c0a](https://github.com/pie-framework/pie-elements/commit/95a4c0a018cf74a24324edc7536013eb271d7c00))
|
|
12
|
+
|
|
6
13
|
## [12.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting@12.1.2...@pie-element/charting@12.1.3) (2026-06-12)
|
|
7
14
|
|
|
8
15
|
### Bug Fixes
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [11.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@11.1.3...@pie-element/charting-configure@11.1.4) (2026-06-17)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
|
|
11
|
+
|
|
6
12
|
## [11.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@11.1.2...@pie-element/charting-configure@11.1.3) (2026-06-12)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
package/configure/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/charting-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "11.1.
|
|
4
|
+
"version": "11.1.4",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"@mui/icons-material": "^7.3.4",
|
|
13
13
|
"@mui/material": "^7.3.4",
|
|
14
14
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
15
|
-
"@pie-lib/charting": "7.0.
|
|
16
|
-
"@pie-lib/config-ui": "13.0.
|
|
17
|
-
"@pie-lib/editable-html-tip-tap": "2.1.
|
|
15
|
+
"@pie-lib/charting": "7.0.8",
|
|
16
|
+
"@pie-lib/config-ui": "13.0.8",
|
|
17
|
+
"@pie-lib/editable-html-tip-tap": "2.1.6",
|
|
18
18
|
"@pie-lib/math-rendering": "5.0.2",
|
|
19
19
|
"@pie-lib/render-ui": "6.1.2",
|
|
20
20
|
"debug": "^4.1.1",
|
package/docs/demo/generate.js
CHANGED
|
@@ -42,9 +42,10 @@ exports.model = (id, element) => ({
|
|
|
42
42
|
editable: false,
|
|
43
43
|
},
|
|
44
44
|
],
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
domain: {
|
|
46
|
+
label:
|
|
47
|
+
'<div>Math in the bottom label: <span data-latex="" data-raw="3x^2">\\(3x^2\\)</span>\u200b</div>',
|
|
48
|
+
},
|
|
48
49
|
graph: {
|
|
49
50
|
width: 480,
|
|
50
51
|
height: 480,
|
|
@@ -53,11 +54,13 @@ exports.model = (id, element) => ({
|
|
|
53
54
|
promptEnabled: true,
|
|
54
55
|
rationale: 'Rationale goes here!',
|
|
55
56
|
range: {
|
|
56
|
-
label:
|
|
57
|
+
label:
|
|
58
|
+
'<div>Math in the left label: <span data-latex="" data-raw="\\frac{\\pi}{2}">\\(\\frac{\\pi}{2}\\)</span>\u200b</div>',
|
|
57
59
|
max: 3,
|
|
58
60
|
min: 0,
|
|
59
61
|
labelStep: 1,
|
|
60
62
|
},
|
|
61
|
-
|
|
63
|
+
title:
|
|
64
|
+
'<div>Math in the title: <span data-latex="" data-raw="\\frac{x}{y}">\\(\\frac{x}{y}\\)</span>\u200b</div>',
|
|
62
65
|
rubricEnabled: false,
|
|
63
66
|
});
|
package/lib/index.js
CHANGED
|
@@ -20,6 +20,29 @@ var _mathRendering = require("@pie-lib/math-rendering");
|
|
|
20
20
|
class Graphing extends HTMLElement {
|
|
21
21
|
constructor() {
|
|
22
22
|
super();
|
|
23
|
+
// The title and axis labels are injected synchronously via dangerouslySetInnerHTML,
|
|
24
|
+
// but createRoot().render() commits asynchronously, so a queueMicrotask(renderMath)
|
|
25
|
+
// would run before the LaTeX spans are in the DOM and leave raw LaTeX on first render.
|
|
26
|
+
// Observing the DOM and typesetting after each commit keeps math in sync regardless of timing.
|
|
27
|
+
(0, _defineProperty2.default)(this, "_scheduleMathRender", () => {
|
|
28
|
+
if (this._mathRenderPending) return;
|
|
29
|
+
this._mathRenderPending = true;
|
|
30
|
+
requestAnimationFrame(() => {
|
|
31
|
+
if (this._mathObserver) {
|
|
32
|
+
this._mathObserver.disconnect();
|
|
33
|
+
}
|
|
34
|
+
(0, _mathRendering.renderMath)(this);
|
|
35
|
+
this._mathRenderPending = false;
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
if (this._mathObserver) {
|
|
38
|
+
this._mathObserver.observe(this, {
|
|
39
|
+
childList: true,
|
|
40
|
+
subtree: true
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}, 50);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
23
46
|
(0, _defineProperty2.default)(this, "isComplete", answer => Array.isArray(answer) && answer.length > 0);
|
|
24
47
|
(0, _defineProperty2.default)(this, "changeAnswers", answer => {
|
|
25
48
|
this._session.answer = answer;
|
|
@@ -27,6 +50,22 @@ class Graphing extends HTMLElement {
|
|
|
27
50
|
this._render();
|
|
28
51
|
});
|
|
29
52
|
this._root = null;
|
|
53
|
+
this._mathObserver = null;
|
|
54
|
+
this._mathRenderPending = false;
|
|
55
|
+
}
|
|
56
|
+
_initMathObserver() {
|
|
57
|
+
if (this._mathObserver) return;
|
|
58
|
+
this._mathObserver = new MutationObserver(this._scheduleMathRender);
|
|
59
|
+
this._mathObserver.observe(this, {
|
|
60
|
+
childList: true,
|
|
61
|
+
subtree: true
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
_disconnectMathObserver() {
|
|
65
|
+
if (this._mathObserver) {
|
|
66
|
+
this._mathObserver.disconnect();
|
|
67
|
+
this._mathObserver = null;
|
|
68
|
+
}
|
|
30
69
|
}
|
|
31
70
|
set model(m) {
|
|
32
71
|
this._model = m;
|
|
@@ -45,12 +84,14 @@ class Graphing extends HTMLElement {
|
|
|
45
84
|
return this._session;
|
|
46
85
|
}
|
|
47
86
|
connectedCallback() {
|
|
87
|
+
this._initMathObserver();
|
|
48
88
|
this._render();
|
|
49
89
|
}
|
|
50
90
|
_render() {
|
|
51
91
|
if (!this._model || !this._session) {
|
|
52
92
|
return;
|
|
53
93
|
}
|
|
94
|
+
this._initMathObserver();
|
|
54
95
|
const modelClone = {
|
|
55
96
|
...this._model,
|
|
56
97
|
data: this._model.data ? [...this._model.data] : this._model.data
|
|
@@ -64,11 +105,9 @@ class Graphing extends HTMLElement {
|
|
|
64
105
|
this._root = (0, _client.createRoot)(this);
|
|
65
106
|
}
|
|
66
107
|
this._root.render(el);
|
|
67
|
-
queueMicrotask(() => {
|
|
68
|
-
(0, _mathRendering.renderMath)(this);
|
|
69
|
-
});
|
|
70
108
|
}
|
|
71
109
|
disconnectedCallback() {
|
|
110
|
+
this._disconnectMathObserver();
|
|
72
111
|
if (this._root) {
|
|
73
112
|
this._root.unmount();
|
|
74
113
|
}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_main","_piePlayerEvents","_mathRendering","Graphing","HTMLElement","constructor","_defineProperty2","default","answer","Array","isArray","length","_session","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","isComplete","_render","_root","model","m","_model","ModelSetEvent","session","s","connectedCallback","modelClone","data","el","React","createElement","Main","categories","onAnswersChange","changeAnswers","createRoot","render","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_main","_piePlayerEvents","_mathRendering","Graphing","HTMLElement","constructor","_defineProperty2","default","_mathRenderPending","requestAnimationFrame","_mathObserver","disconnect","renderMath","setTimeout","observe","childList","subtree","answer","Array","isArray","length","_session","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","isComplete","_render","_root","_initMathObserver","MutationObserver","_scheduleMathRender","_disconnectMathObserver","model","m","_model","ModelSetEvent","session","s","connectedCallback","modelClone","data","el","React","createElement","Main","categories","onAnswersChange","changeAnswers","createRoot","render","disconnectedCallback","unmount","exports"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport Main from './main';\nimport { SessionChangedEvent, ModelSetEvent } from '@pie-framework/pie-player-events';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nexport { Main as Component };\n\nexport default class Graphing extends HTMLElement {\n constructor() {\n super();\n this._root = null;\n this._mathObserver = null;\n this._mathRenderPending = false;\n }\n\n // The title and axis labels are injected synchronously via dangerouslySetInnerHTML,\n // but createRoot().render() commits asynchronously, so a queueMicrotask(renderMath)\n // would run before the LaTeX spans are in the DOM and leave raw LaTeX on first render.\n // Observing the DOM and typesetting after each commit keeps math in sync regardless of timing.\n _scheduleMathRender = () => {\n if (this._mathRenderPending) return;\n this._mathRenderPending = true;\n\n requestAnimationFrame(() => {\n if (this._mathObserver) {\n this._mathObserver.disconnect();\n }\n renderMath(this);\n this._mathRenderPending = false;\n setTimeout(() => {\n if (this._mathObserver) {\n this._mathObserver.observe(this, { childList: true, subtree: true });\n }\n }, 50);\n });\n };\n\n _initMathObserver() {\n if (this._mathObserver) return;\n this._mathObserver = new MutationObserver(this._scheduleMathRender);\n this._mathObserver.observe(this, { childList: true, subtree: true });\n }\n\n _disconnectMathObserver() {\n if (this._mathObserver) {\n this._mathObserver.disconnect();\n this._mathObserver = null;\n }\n }\n\n set model(m) {\n this._model = m;\n\n if (this._session && this.isComplete(this._session.answer)) {\n this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), true, !!this._model));\n } else {\n this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), false, !!this._model));\n }\n\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n connectedCallback() {\n this._initMathObserver();\n this._render();\n }\n\n isComplete = (answer) => Array.isArray(answer) && answer.length > 0;\n\n changeAnswers = (answer) => {\n this._session.answer = answer;\n\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete(this._session.answer)));\n\n this._render();\n };\n\n _render() {\n if (!this._model || !this._session) {\n return;\n }\n\n this._initMathObserver();\n\n const modelClone = {\n ...this._model,\n data: this._model.data ? [...this._model.data] : this._model.data,\n };\n\n const el = React.createElement(Main, {\n model: modelClone,\n categories: this._session.answer,\n onAnswersChange: this.changeAnswers,\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(el);\n }\n\n disconnectedCallback() {\n this._disconnectMathObserver();\n if (this._root) {\n this._root.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AA,GAAAJ,QAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "12.1.
|
|
7
|
+
"version": "12.1.4",
|
|
8
8
|
"description": "",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"postpublish": "../../scripts/postpublish"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@mui/icons-material": "^7.3.4",
|
|
16
16
|
"@mui/material": "^7.3.4",
|
|
17
17
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
18
|
-
"@pie-lib/charting": "7.0.
|
|
18
|
+
"@pie-lib/charting": "7.0.8",
|
|
19
19
|
"@pie-lib/correct-answer-toggle": "4.0.4",
|
|
20
20
|
"@pie-lib/math-rendering": "5.0.2",
|
|
21
21
|
"@pie-lib/render-ui": "6.1.2",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"author": "",
|
|
28
28
|
"license": "ISC",
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "395c1eeab967e1201bc5904cfe3cc63914ebbb4a",
|
|
30
30
|
"main": "lib/index.js",
|
|
31
31
|
"module": "src/index.js"
|
|
32
32
|
}
|