Ensure comparison line Y axis scale matches main plot (#2884)

Previously, the comparison line could sometimes be displayed with a
different scale than the main plot due to the maxTicksLimit option not
being fixed and changing based on the data. This commit fixes the issue
by setting the maxTicksLimit value to 8 in the graph settings instead of
for each individual axis.

Additionally, a callback that attempted to dynamically change the Y axis
ticks while resizing has been removed. As the graph has a fixed height,
dynamically resizing the Y axis no longer makes sense.
pull/2893/head
Vini Brasil 4 years ago committed by GitHub
parent caeff41932
commit 990447ff74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -66,13 +66,15 @@ class LineGraph extends React.Component {
onResize: this.updateWindowDimensions,
elements: { line: { tension: 0 }, point: { radius: 0 } },
onClick: this.onClick.bind(this),
scale: {
ticks: { precision: 0, maxTicksLimit: 8 }
},
scales: {
y: {
min: 0,
suggestedMax: calculateMaximumY(dataSet),
ticks: {
callback: METRIC_FORMATTER[metric],
maxTicksLimit: 8,
color: this.props.darkTheme ? 'rgb(243, 244, 246)' : undefined
},
grid: {
@ -89,7 +91,6 @@ class LineGraph extends React.Component {
x: {
grid: { display: false },
ticks: {
maxTicksLimit: 8,
callback: function (val, _index, _ticks) {
if (this.getLabelForValue(val) == "__blank__") return ""
@ -215,7 +216,6 @@ class LineGraph extends React.Component {
*/
updateWindowDimensions(chart, dimensions) {
chart.options.scales.x.ticks.maxTicksLimit = dimensions.width < 720 ? 5 : 8
chart.options.scales.y.ticks.maxTicksLimit = dimensions.height < 233 ? 3 : 8
}
onClick(e) {

Loading…
Cancel
Save