Update Plot benchmarks to use the latest set of dependencies.
Test: Tested locally.
Change-Id: I107bef5e39f023f8397d29f906a376f832b0d16c
diff --git a/development/plot-benchmarks/src/lib/App.svelte b/development/plot-benchmarks/src/lib/App.svelte
index f1ace88..ca22bb0 100644
--- a/development/plot-benchmarks/src/lib/App.svelte
+++ b/development/plot-benchmarks/src/lib/App.svelte
@@ -15,7 +15,7 @@
})
);
- function onFilesChanged(event) {
+ function onFilesChanged(event: CustomEvent) {
const detail: FileMetadata[] = event.detail;
if (detail) {
const enabled = detail.filter((metadata) => metadata.enabled === true);
diff --git a/development/plot-benchmarks/src/lib/Chart.svelte b/development/plot-benchmarks/src/lib/Chart.svelte
index 175da99..edf6584 100644
--- a/development/plot-benchmarks/src/lib/Chart.svelte
+++ b/development/plot-benchmarks/src/lib/Chart.svelte
@@ -34,13 +34,13 @@
const onUpdate = (chart: Chart) => {
$chart = chart;
// Bad typings.
- const legend = chart.options.plugins.legend as any;
+ const legend = chart.options.plugins?.legend as any;
$items = legend.labels.generateLabels(chart);
};
const plugins = {
tooltip: {
callbacks: {
- label: (context: TooltipItem<typeof chartType>): string | null => {
+ label: (context: TooltipItem<typeof chartType>): string | void | string[] => {
// TODO: Configure Tooltips
// https://www.chartjs.org/docs/latest/configuration/tooltip.html
const label = context.dataset.label;
@@ -51,7 +51,7 @@
return `${label}: ${fx} F(${frequency})`;
} else {
// Fallback to default behavior
- return undefined;
+ return;
}
},
},
@@ -131,7 +131,7 @@
{/if}
</article>
-{#if $items}
+{#if $chart && $items}
<Legend chart={$chart} items={$items} />
{/if}
diff --git a/development/plot-benchmarks/src/lib/Legend.svelte b/development/plot-benchmarks/src/lib/Legend.svelte
index ef239f5..2795fb2 100644
--- a/development/plot-benchmarks/src/lib/Legend.svelte
+++ b/development/plot-benchmarks/src/lib/Legend.svelte
@@ -5,12 +5,14 @@
const handlerFactory = (item: LegendItem) => {
return (event: Event) => {
- // https://www.chartjs.org/docs/latest/samples/legend/html.html
- chart.setDatasetVisibility(
- item.datasetIndex,
- !chart.isDatasetVisible(item.datasetIndex)
- );
- chart.update();
+ if (item.datasetIndex !== undefined) {
+ // https://www.chartjs.org/docs/latest/samples/legend/html.html
+ chart.setDatasetVisibility(
+ item.datasetIndex,
+ !chart.isDatasetVisible(item.datasetIndex)
+ );
+ chart.update();
+ }
};
};
</script>
diff --git a/development/plot-benchmarks/src/main.ts b/development/plot-benchmarks/src/main.ts
index a3355b1..93a3c3f 100644
--- a/development/plot-benchmarks/src/main.ts
+++ b/development/plot-benchmarks/src/main.ts
@@ -2,7 +2,7 @@
import App from './lib/App.svelte';
const app = new App({
- target: document.getElementById('app'),
+ target: document.getElementById('app')!!,
});
export default app;
diff --git a/development/plot-benchmarks/src/transforms/standard-mappers.ts b/development/plot-benchmarks/src/transforms/standard-mappers.ts
index df74b8f9..970e20b 100644
--- a/development/plot-benchmarks/src/transforms/standard-mappers.ts
+++ b/development/plot-benchmarks/src/transforms/standard-mappers.ts
@@ -232,5 +232,8 @@
}
export function isSampled(label: string | null | undefined): boolean {
- return label && label.indexOf(SAMPLED_SUFFIX) >= 0;
+ if (label) {
+ return label.indexOf(SAMPLED_SUFFIX) >= 0;
+ }
+ return false;
}
diff --git a/development/plot-benchmarks/src/wrappers/benchmarks.ts b/development/plot-benchmarks/src/wrappers/benchmarks.ts
index 9bbc015..225859fb 100644
--- a/development/plot-benchmarks/src/wrappers/benchmarks.ts
+++ b/development/plot-benchmarks/src/wrappers/benchmarks.ts
@@ -13,11 +13,11 @@
}
metric(label: string): Standard | undefined {
- return this.benchmark?.metrics[label];
+ return this.benchmark?.metrics?.[label];
}
sampled(label: string): Sampled | undefined {
- return this.benchmark?.sampledMetrics[label];
+ return this.benchmark?.sampledMetrics?.[label];
}
metricLabels(): string[] {
@@ -39,7 +39,7 @@
return this.benchmark.name;
}
- private static labels(collection: MetricsCollection | null): string[] {
+ private static labels(collection: MetricsCollection | undefined): string[] {
const labels: string[] = [];
if (collection) {
for (const key in collection) {
diff --git a/development/plot-benchmarks/src/wrappers/session.ts b/development/plot-benchmarks/src/wrappers/session.ts
index 80209dd..2a37139 100644
--- a/development/plot-benchmarks/src/wrappers/session.ts
+++ b/development/plot-benchmarks/src/wrappers/session.ts
@@ -17,10 +17,10 @@
*/
export class Session {
// className -> BenchmarkWrapper[]
- public classGroups: Record<string, IndexedWrapper[]>;
+ public classGroups: Record<string, IndexedWrapper[]> = {};
// BenchmarkWrapper[]
- public benchmarks: IndexedWrapper[];
- public fileNames: Set<string>;
+ public benchmarks: IndexedWrapper[] = [];
+ public fileNames: Set<string> = new Set();
constructor(public files: FileMetadata[]) {
this.initialize();