Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Change line color range and rendering order #2759

Merged
merged 3 commits into from
Aug 7, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/webui/src/components/trial-detail/Para.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,27 @@ class Para extends React.Component<ParaProps, ParaState> {
const scale = this.convertToD3Scale(v);
if (k === primaryMetricKey && scale !== undefined && scale.interpolate) {
// set color for primary metrics
colorScale = this.convertToD3Scale(v, false)
.range(['green', 'red'])
colorScale = this.convertToD3Scale(v, false);
colorScale.range([0, 1]); // fake a range to perform invert
const [scaleMin, scaleMax] = colorScale.domain();
const pivot = colorScale.invert(0.5);
colorScale.domain([scaleMin, pivot, scaleMax])
.range(['#90EE90', '#FFC400', '#CA0000'])
.interpolate(d3.interpolateHsl);
colorDim = k;
convertedTrials.sort((a, b) => EXPERIMENT.optimizeMode === 'minimize' ? a[k] - b[k] : b[k] - a[k]);
// filter top trials
if (percent != 1) {
const keptTrialNum = Math.max(Math.ceil(convertedTrials.length * percent), 1);
convertedTrials.sort((a, b) => EXPERIMENT.optimizeMode === 'minimize' ? a[k] - b[k] : b[k] - a[k]);
convertedTrials = convertedTrials.slice(0, keptTrialNum);
const domain = d3.extent(convertedTrials, item => item[k]);
scale.domain([domain[0], domain[1]]);
if (colorScale !== undefined) {
colorScale.domain(domain);
}
}
// reverse the converted trials to show the top ones upfront
convertedTrials.reverse();
}
dimensions.push([k, {
type: 'number',
Expand Down