Skip to content

Commit

Permalink
fix: select metric based on config search metric then fallback to fir…
Browse files Browse the repository at this point in the history
…st available metric (#1162)
  • Loading branch information
Caleb Hoyoul Kang authored Aug 31, 2020
1 parent c9531f0 commit c11eda5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions webui/react/src/pages/TrialDetails/TrialChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ interface Props {
}

const TrialChart: React.FC<Props> = ({ metricNames, validationMetric, ...props }: Props) => {
const [ metric, setMetric ] = useState<MetricName | undefined>(
validationMetric ? { name: validationMetric, type: MetricType.Validation } : undefined,
);
const defaultMetric = metricNames.find(metricName => {
return metricName.name === validationMetric && metricName.type === MetricType.Validation;
});
const fallbackMetric = metricNames && metricNames.length !== 0 ? metricNames[0] : undefined;
const [ metric, setMetric ] = useState<MetricName | undefined>(defaultMetric || fallbackMetric);

const data: Partial<PlotData>[] = useMemo(() => {
const textData: string[] = [];
Expand Down

0 comments on commit c11eda5

Please sign in to comment.