Skip to content

Commit

Permalink
fix: Add legend to Trial metrics graph [DET-5723] (determined-ai#2663)
Browse files Browse the repository at this point in the history
  • Loading branch information
apizzini committed Jul 13, 2021
1 parent ebf0e92 commit 1840ea8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions webui/react/src/pages/TrialDetails/TrialChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ interface Props {

const STORAGE_PATH = 'trial-detail';

const getChartMetricLabel = (metric: MetricName): string => {
if (metric.type === 'training') return `[T] ${metric.name}`;
if (metric.type === 'validation') return `[V] ${metric.name}`;
return metric.name;
};

const TrialChart: React.FC<Props> = ({
defaultMetricNames,
metricNames,
Expand Down Expand Up @@ -75,7 +81,7 @@ const TrialChart: React.FC<Props> = ({
return {
axes: [
{ label: 'Batches' },
{ label: 'Metric Value' },
{ label: metrics.length === 1 ? getChartMetricLabel(metrics[0]) : 'Metric Value' },
],
height: 400,
legend: { show: false },
Expand All @@ -86,8 +92,8 @@ const TrialChart: React.FC<Props> = ({
},
series: [
{ label: 'Batch' },
...metrics.map((metricName, index) => ({
label: metricName.name,
...metrics.map((metric, index) => ({
label: getChartMetricLabel(metric),
spanGaps: true,
stroke: glasbeyColor(index),
width: 2,
Expand Down

0 comments on commit 1840ea8

Please sign in to comment.