markdown-up 3.3.4 → 3.3.6
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/lib/app.js +10 -0
- package/lib/lineChart.js +20 -2
- package/package.json +1 -1
package/lib/app.js
CHANGED
|
@@ -108,6 +108,7 @@ export class MarkdownUp {
|
|
|
108
108
|
this.url = (options !== null ? options.url : null) ?? 'README.md';
|
|
109
109
|
this.runtimeWindowResize = null;
|
|
110
110
|
this.runtimeTimeoutId = null;
|
|
111
|
+
this.renderCount = 0;
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
|
|
@@ -121,6 +122,9 @@ export class MarkdownUp {
|
|
|
121
122
|
|
|
122
123
|
|
|
123
124
|
async render(forceRender = false) {
|
|
125
|
+
// Increase the render count enable so we can detect a render the middle of a runtime update
|
|
126
|
+
this.renderCount += 1;
|
|
127
|
+
|
|
124
128
|
// Parse the hash parameters and render the application element model
|
|
125
129
|
let result;
|
|
126
130
|
let isError = false;
|
|
@@ -427,12 +431,18 @@ export class MarkdownUp {
|
|
|
427
431
|
|
|
428
432
|
// Create the markdown-script runtime
|
|
429
433
|
const runtime = new MarkdownScriptRuntime(scriptOptions);
|
|
434
|
+
const {renderCount} = this;
|
|
430
435
|
scriptOptions.globals = {...markdownScriptFunctions};
|
|
431
436
|
if (this.globals !== null) {
|
|
432
437
|
Object.assign(scriptOptions.globals, this.globals);
|
|
433
438
|
}
|
|
434
439
|
scriptOptions.runtime = runtime;
|
|
435
440
|
scriptOptions.runtimeUpdateFn = () => {
|
|
441
|
+
// Did a render occur in the middle of this runtime update?
|
|
442
|
+
if (this.renderCount !== renderCount) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
|
|
436
446
|
// Did script set the document title?
|
|
437
447
|
if (runtime.documentTitle !== null) {
|
|
438
448
|
this.window.document.title = runtime.documentTitle;
|
package/lib/lineChart.js
CHANGED
|
@@ -41,6 +41,9 @@ struct LineChart
|
|
|
41
41
|
# The color encoding field
|
|
42
42
|
optional string color
|
|
43
43
|
|
|
44
|
+
# The color encoding value order
|
|
45
|
+
optional string[len > 0] colorOrder
|
|
46
|
+
|
|
44
47
|
# The X-axis tick marks
|
|
45
48
|
optional LineChartAxisTicks xTicks
|
|
46
49
|
|
|
@@ -180,6 +183,7 @@ export function lineChartElements(data, lineChart, options = null) {
|
|
|
180
183
|
const xField = lineChart.x;
|
|
181
184
|
const yFields = lineChart.y;
|
|
182
185
|
const colorField = lineChart.color ?? null;
|
|
186
|
+
const colorOrder = lineChart.colorOrder ?? null;
|
|
183
187
|
|
|
184
188
|
// Sort the rows by the X field
|
|
185
189
|
data.sort((row1, row2) => {
|
|
@@ -219,7 +223,21 @@ export function lineChartElements(data, lineChart, options = null) {
|
|
|
219
223
|
}
|
|
220
224
|
|
|
221
225
|
// Add the points
|
|
222
|
-
|
|
226
|
+
let colorValues;
|
|
227
|
+
if (colorOrder !== null) {
|
|
228
|
+
colorValues = Array.from(colorValueSet.values()).sort((cv1, cv2) => {
|
|
229
|
+
const ix1 = colorOrder.indexOf(cv1);
|
|
230
|
+
const ix2 = colorOrder.indexOf(cv2);
|
|
231
|
+
if (ix1 !== -1 && ix2 !== -1) {
|
|
232
|
+
return ix1 < ix2 ? -1 : 1;
|
|
233
|
+
} else if (ix1 === -1 && ix2 === -1) {
|
|
234
|
+
return cv1 < cv2 ? -1 : 1;
|
|
235
|
+
}
|
|
236
|
+
return ix1 !== -1 ? -1 : 1;
|
|
237
|
+
});
|
|
238
|
+
} else {
|
|
239
|
+
colorValues = Array.from(colorValueSet.values()).sort();
|
|
240
|
+
}
|
|
223
241
|
const colorValueCount = colorValues.length;
|
|
224
242
|
for (let ixColorValue = 0; ixColorValue < colorValueCount; ixColorValue += 1) {
|
|
225
243
|
const colorValue = colorValues[ixColorValue];
|
|
@@ -364,7 +382,7 @@ export function lineChartElements(data, lineChart, options = null) {
|
|
|
364
382
|
const labelWidth = label.length * chartFontWidthRatio * colorLegendFontSize;
|
|
365
383
|
return labelWidth > labelMax ? labelWidth : labelMax;
|
|
366
384
|
}, 0);
|
|
367
|
-
const colorLegendX = yFields.length === 1 &&
|
|
385
|
+
const colorLegendX = yFields.length === 1 && colorField === null ? null : Math.max(
|
|
368
386
|
chartWidth - chartBorderSize - colorLegendLabelWidth - colorLegendSampleWidth,
|
|
369
387
|
0.6 * chartWidth
|
|
370
388
|
);
|