Skip to content

Commit f17bfc8

Browse files
siwei-zhang-workSiwei Zhangbhufmann
authored
Update parsing of sampling to match tsp specification (#354)
Update parsing of sampling to match tsp specification The tsp-typescript-client was modified to comply to tsp specification for sampling, update accordingly here. Account for new xRanges and xCategories for generic xy output component. Contributes to fix: eclipse-tracecompass-incubator/org.eclipse.tracecompass.incubator#236 Upgrade to tsp-typescript-client v0.9.0. Signed-off-by: Bernd Hufmann <[email protected]> Co-authored-by: Siwei Zhang <[email protected]> Co-authored-by: Bernd Hufmann <[email protected]>
1 parent b0c90c2 commit f17bfc8

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

base/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"src"
1717
],
1818
"dependencies": {
19-
"tsp-typescript-client": "^0.8.0"
19+
"tsp-typescript-client": "^0.9.0"
2020
},
2121
"devDependencies": {
2222
"@typescript-eslint/eslint-plugin": "^6.0.0",

react-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"react-virtualized": "^9.21.0",
3737
"timeline-chart": "^0.4.2",
3838
"traceviewer-base": "0.9.1",
39-
"tsp-typescript-client": "^0.8.0"
39+
"tsp-typescript-client": "^0.9.0"
4040
},
4141
"devDependencies": {
4242
"@testing-library/react": "^15.0.6",

react-components/src/components/generic-xy-output-component.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ export class GenericXYOutputComponent extends AbstractTreeOutputComponent<Generi
320320

321321
const style = (series[0] as any)?.style?.values?.['series-type'] as string | undefined;
322322
const st = style?.toLowerCase();
323-
const xv = series[0].xValues as Sampling;
324-
this.isTimeAxis = isTimestampSampling(xv);
323+
this.isTimeAxis = !!series[0].xValues;
325324
this.mode = st === 'scatter' ? ChartMode.SCATTER : st === 'line' ? ChartMode.LINE : ChartMode.BAR;
326325

327326
const xy = this.buildXYData(series, this.mode);
@@ -342,9 +341,9 @@ export class GenericXYOutputComponent extends AbstractTreeOutputComponent<Generi
342341
}
343342

344343
private buildBarChartData(seriesObj: XYSeries[]): GenericXYData {
345-
const xValues = seriesObj[0].xValues;
344+
const xValues = seriesObj[0].xValues ?? seriesObj[0].xRanges ?? seriesObj[0].xCategories;
346345
const unit = seriesObj[0]?.xValuesDescription?.unit || '';
347-
const labels = this.buildLabels(xValues, unit);
346+
const labels = this.buildLabels(xValues as Sampling, unit);
348347
const datasets: GenericXYData['datasets'] = seriesObj.map(s => {
349348
const color = this.colors.get(s.seriesName);
350349
return {
@@ -361,9 +360,9 @@ export class GenericXYOutputComponent extends AbstractTreeOutputComponent<Generi
361360
}
362361

363362
private buildLineOrScatterChartData(seriesObj: XYSeries[], mode: ChartMode): GenericXYData {
364-
const xValues = seriesObj[0].xValues;
363+
const xValues = seriesObj[0].xValues ?? seriesObj[0].xRanges ?? seriesObj[0].xCategories;
365364
const unit = seriesObj[0]?.xValuesDescription?.unit || '';
366-
const labels = this.buildLabels(xValues, unit);
365+
const labels = this.buildLabels(xValues as Sampling, unit);
367366

368367
const datasets: GenericXYData['datasets'] = seriesObj.map(s => {
369368
const color = this.colors.get(s.seriesName);
@@ -388,7 +387,7 @@ export class GenericXYOutputComponent extends AbstractTreeOutputComponent<Generi
388387

389388
private buildLabels(xValues: Sampling, unit: string): string[] {
390389
if (isRangeSampling(xValues)) {
391-
return xValues.map(range => `[${range[0]} ${unit}, ${range[1]} ${unit}]`);
390+
return xValues.map(range => `[${range.start} ${unit}, ${range.end} ${unit}]`);
392391
} else if (isCategorySampling(xValues)) {
393392
return xValues.map(val => `${val} ${unit}`);
394393
} else if (isTimestampSampling(xValues)) {

0 commit comments

Comments
 (0)