-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix column scaling ("Multiply by a number") bugs #43668
Fix column scaling ("Multiply by a number") bugs #43668
Conversation
Multiply by a number
, bugs"Multiply by a number"
) bugs
"Multiply by a number"
) bugs
Codenotify: Notifying subscribers in CODENOTIFY files for diff 8659846...8888d47.
|
|
4ecef1d
to
73a8d70
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Could you add some more specs similar to the line chart one you created before merging? Ideally one for the scatter plot and waterfall chart would be nice, since they use different codepaths
const options = getFormattingOptionsWithoutScaling({ | ||
column, | ||
...columnSettings, | ||
jsx: false, | ||
compact: settings["graph.label_value_formatting"] === "compact", | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we moved scaling to be a simple dataset transformation, we can disregard any scaling property thereafter.
Eventually it would be nice to have scaling only be relevant in the dataset transformation to make it so that value formatters do not even need to consider it.
i.e. Handle the scaling in one place, dataset transformations, rather than having to account for it in all formatting contexts. This way ECharts can know the exact dataset values to determine ranges instead of the unscaled values. Plus we would not have to maintain scaling in value formatting anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since value scaling is being applied as a dataset transformation, we want to make sure it is not double applied by the value formatting that occurs in tool-tips.
export function scaleDataset( | ||
dataset: ChartDataset, | ||
seriesModels: SeriesModel[], | ||
settings: ComputedVisualizationSettings, | ||
): ChartDataset { | ||
const transformFn = (datum: Datum) => { | ||
const transformedRecord = { ...datum }; | ||
for (const seriesModel of seriesModels) { | ||
const scale = getColumnScaling(seriesModel.column, settings); | ||
|
||
const key = seriesModel.dataKey; | ||
if (key in datum) { | ||
const scaledValue = Number.isFinite(datum[key]) | ||
? (datum[key] as number) * scale | ||
: null; | ||
transformedRecord[key] = scaledValue; | ||
} | ||
} | ||
return transformedRecord; | ||
}; | ||
|
||
return dataset.map(datum => { | ||
return transformFn(datum); | ||
}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only need to use the scale factor once for transforming the dataset and then we can disregard the fact that it was ever scaled thereon after. Eventually it would nice to rip out the additional scaling in the value formatter, so that we do not have to maintain that across many different contexts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Porting the value scaling to RowCharts since they are not implemented as an ECharts chart yet.
@JesseSDevaney Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone? |
* return empty string so non-empty labels do not get hidden by empty labels * fix function name * apply scaling in transformed dataset * add missing option to OptionsType * fix double scaling * add column scaling to waterfall transformed dataset * add column value scaling to dataset transform * fix stacked bar segment labels not responding to column scaling * fix tooltip values displayed * since scaling as added to transformedDataset, use transformedDataset for formatters * revert changes to display percentage instead of absolute value * fix stacked data labels * add loki variant for custom y-axis range with column scaling * fix stack segmented label formatters compact calculation * scale original dataset and use that instead of modifying transformedDataset * update loki snapshots * fix scatter plot dataset scaling * fix tooltip values being double scaled * add E2E test to validate behavior * add helper for not duplicating the column scaling * port multiple y-axis metrics with column scaling fixes to RowChart * add waterfall and scatterplot loki variants * fix type errors and failing unit tests * fix failing unit tests * update loki snapshots
* Fix column scaling ("Multiply by a number") bugs (#43668) * return empty string so non-empty labels do not get hidden by empty labels * fix function name * apply scaling in transformed dataset * add missing option to OptionsType * fix double scaling * add column scaling to waterfall transformed dataset * add column value scaling to dataset transform * fix stacked bar segment labels not responding to column scaling * fix tooltip values displayed * since scaling as added to transformedDataset, use transformedDataset for formatters * revert changes to display percentage instead of absolute value * fix stacked data labels * add loki variant for custom y-axis range with column scaling * fix stack segmented label formatters compact calculation * scale original dataset and use that instead of modifying transformedDataset * update loki snapshots * fix scatter plot dataset scaling * fix tooltip values being double scaled * add E2E test to validate behavior * add helper for not duplicating the column scaling * port multiple y-axis metrics with column scaling fixes to RowChart * add waterfall and scatterplot loki variants * fix type errors and failing unit tests * fix failing unit tests * update loki snapshots * update loki snapshots --------- Co-authored-by: Jesse Devaney <22608765+JesseSDevaney@users.noreply.github.com>
Issues Fixed
Manual Y axis min/max don't take the "Multiply by" factor into account (#12214)
Demo
2024-06-04.17-18-46.mp4
How to Verify
"Linear"
y-axis scale["Log", "Pow"]
["Bar", "Area", "Combo", "Scatter", "Waterfall", "Stacked Bar", "Stacked Area"]
Acceptance Criteria
multiply by
factor should still work as expectedUsing scaling on a question with multiple y-axis columns breaks tool-tips and y-axis label formatting (#43536)
Demo
2024-06-04.17-24-28.mp4
How to Verify
["Sum of Total", "Sum of Subtotal"]
) and one breakout ("Created at: Year"
)"Show values for data points"
"Both"
)Acceptance Criteria