@pie-lib/charting 5.32.6-esmbeta.2 → 5.32.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/CHANGELOG.md +20 -0
- package/lib/axes.js +18 -4
- package/lib/axes.js.map +1 -1
- package/lib/chart.js +9 -1
- package/lib/chart.js.map +1 -1
- package/lib/plot/common/plot.js +21 -5
- package/lib/plot/common/plot.js.map +1 -1
- package/package.json +6 -12
- package/src/axes.jsx +19 -4
- package/src/chart.jsx +8 -0
- package/src/plot/common/plot.jsx +56 -15
- package/esm/index.js +0 -63630
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -1
package/src/axes.jsx
CHANGED
|
@@ -7,6 +7,8 @@ import Checkbox from '@material-ui/core/Checkbox';
|
|
|
7
7
|
import { types } from '@pie-lib/plot';
|
|
8
8
|
import { color } from '@pie-lib/render-ui';
|
|
9
9
|
import { AlertDialog } from '@pie-lib/config-ui';
|
|
10
|
+
import { renderMath } from '@pie-lib/math-rendering';
|
|
11
|
+
|
|
10
12
|
import { TickCorrectnessIndicator } from './common/correctness-indicators';
|
|
11
13
|
import { bandKey, getTickValues, getRotateAngle } from './utils';
|
|
12
14
|
import MarkLabel from './mark-label';
|
|
@@ -352,10 +354,23 @@ export class RawChartAxes extends React.Component {
|
|
|
352
354
|
componentDidMount() {
|
|
353
355
|
if (this.hiddenLabelRef) {
|
|
354
356
|
const boundingClientRect = this.hiddenLabelRef.getBoundingClientRect();
|
|
355
|
-
this.
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
357
|
+
const hiddenEl = this.hiddenLabelRef.current;
|
|
358
|
+
|
|
359
|
+
// same logic used in dropdown.jsx for hidden labels width calculation
|
|
360
|
+
if (hiddenEl) {
|
|
361
|
+
const containsLatex = hiddenEl.querySelector('[data-latex], [data-raw]');
|
|
362
|
+
const hasMathJax = hiddenEl.querySelector('mjx-container');
|
|
363
|
+
const mathHandled = hiddenEl.querySelector('[data-math-handled="true"]');
|
|
364
|
+
|
|
365
|
+
if (containsLatex && (!mathHandled || !hasMathJax)) {
|
|
366
|
+
renderMath(this.hiddenLabelRef);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
this.setState({
|
|
370
|
+
height: Math.floor(boundingClientRect.height),
|
|
371
|
+
width: Math.floor(boundingClientRect.width),
|
|
372
|
+
});
|
|
373
|
+
}
|
|
359
374
|
}
|
|
360
375
|
}
|
|
361
376
|
|
package/src/chart.jsx
CHANGED
|
@@ -270,6 +270,14 @@ export class Chart extends React.Component {
|
|
|
270
270
|
const rootCommon = cloneDeep(common);
|
|
271
271
|
rootCommon.graphProps.size.height += top + increaseHeight;
|
|
272
272
|
|
|
273
|
+
// for plot evaluations we need extra space because we render correctness icon below x axis
|
|
274
|
+
const isPlotEvaluation = (chartType === 'dotPlot' || chartType === 'linePlot') && correctData?.length;
|
|
275
|
+
const needsExtraHeight = isPlotEvaluation && labels.bottom;
|
|
276
|
+
|
|
277
|
+
if (needsExtraHeight) {
|
|
278
|
+
rootCommon.graphProps.size.height += 25;
|
|
279
|
+
}
|
|
280
|
+
|
|
273
281
|
return (
|
|
274
282
|
<div className={classNames(classes.chart, classes.chartBox, className)}>
|
|
275
283
|
<Root
|
package/src/plot/common/plot.jsx
CHANGED
|
@@ -68,19 +68,27 @@ export class RawPlot extends React.Component {
|
|
|
68
68
|
this.setDragValue(next);
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
renderCorrectnessIcon = (barX, barWidth, correctVal, correctness, classes, scale) =>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
renderCorrectnessIcon = (barX, barWidth, correctVal, correctness, classes, scale, pointHeight, pointDiameter) => {
|
|
72
|
+
let iconY;
|
|
73
|
+
|
|
74
|
+
if (correctVal === 0) {
|
|
75
|
+
// if correct value is 0, position icon on the horizontal axis
|
|
76
|
+
iconY = scale.y(0) - ICON_SIZE / 2;
|
|
77
|
+
} else {
|
|
78
|
+
const shapeIndex = correctVal - 1; // the index of the shape representing the correct value
|
|
79
|
+
const shapeCenterY = scale.y(shapeIndex) - (pointHeight - pointDiameter) / 2 - pointDiameter / 2;
|
|
80
|
+
iconY = shapeCenterY - ICON_SIZE / 2; // center the icon
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<foreignObject x={barX + barWidth / 2 - ICON_SIZE / 2} y={iconY} width={ICON_SIZE} height={ICON_SIZE}>
|
|
85
|
+
<Check
|
|
86
|
+
className={classNames(classes.correctnessIcon, classes.correctIcon, classes.smallIcon)}
|
|
87
|
+
title={correctness.label}
|
|
88
|
+
/>
|
|
89
|
+
</foreignObject>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
84
92
|
|
|
85
93
|
render() {
|
|
86
94
|
const {
|
|
@@ -157,6 +165,21 @@ export class RawPlot extends React.Component {
|
|
|
157
165
|
const correctVal = parseFloat(correctData[index] && correctData[index].value);
|
|
158
166
|
if (isNaN(correctVal)) return null;
|
|
159
167
|
const selectedVal = v;
|
|
168
|
+
|
|
169
|
+
// special case: if correct value is 0, only show the icon on the axis
|
|
170
|
+
if (correctVal === 0) {
|
|
171
|
+
return this.renderCorrectnessIcon(
|
|
172
|
+
barX,
|
|
173
|
+
barWidth,
|
|
174
|
+
correctVal,
|
|
175
|
+
correctness,
|
|
176
|
+
classes,
|
|
177
|
+
scale,
|
|
178
|
+
pointHeight,
|
|
179
|
+
pointDiameter,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
160
183
|
if (selectedVal > correctVal) {
|
|
161
184
|
// selected is higher than correct: overlay the correct last segment
|
|
162
185
|
const overlayValues = [];
|
|
@@ -183,7 +206,16 @@ export class RawPlot extends React.Component {
|
|
|
183
206
|
scale={scale}
|
|
184
207
|
dottedOverline={true}
|
|
185
208
|
/>
|
|
186
|
-
{this.renderCorrectnessIcon(
|
|
209
|
+
{this.renderCorrectnessIcon(
|
|
210
|
+
barX,
|
|
211
|
+
barWidth,
|
|
212
|
+
correctVal,
|
|
213
|
+
correctness,
|
|
214
|
+
classes,
|
|
215
|
+
scale,
|
|
216
|
+
pointHeight,
|
|
217
|
+
pointDiameter,
|
|
218
|
+
)}
|
|
187
219
|
</>
|
|
188
220
|
);
|
|
189
221
|
}
|
|
@@ -208,7 +240,16 @@ export class RawPlot extends React.Component {
|
|
|
208
240
|
dottedOverline: true,
|
|
209
241
|
}),
|
|
210
242
|
)}
|
|
211
|
-
{this.renderCorrectnessIcon(
|
|
243
|
+
{this.renderCorrectnessIcon(
|
|
244
|
+
barX,
|
|
245
|
+
barWidth,
|
|
246
|
+
correctVal,
|
|
247
|
+
correctness,
|
|
248
|
+
classes,
|
|
249
|
+
scale,
|
|
250
|
+
pointHeight,
|
|
251
|
+
pointDiameter,
|
|
252
|
+
)}
|
|
212
253
|
</>
|
|
213
254
|
);
|
|
214
255
|
})()}
|