Skip to content
This repository has been archived by the owner on Apr 19, 2021. It is now read-only.

Adjust Redash graphs to drawn datasets close to the max value properly #178

Closed
armenzg opened this issue Oct 11, 2018 · 5 comments
Closed

Comments

@armenzg
Copy link
Contributor

armenzg commented Oct 11, 2018

In this page (NOTE: Code yet to land) we can see that one of the lines goes to the top of the graph but it looks odd:
image

Here's the documentation:
http://www.chartjs.org/docs/latest/axes/cartesian/linear.html

If we pass a max value to the ticks larger that the highest value for that dataset we get to see the line properly drawn, however, the last two tick labels are too close:
image

A suggestedMax of 31000 will extend the Y axis to 35000:
image

We want a generic way to do this.

Here's a diff where I hardcoded the values:

armenzg@armenzg-mbp frontend$ git diff
diff --git a/src/containers/RedashContainer/index.jsx b/src/containers/RedashContainer/index.jsx
index 54debb4..8184562 100644
--- a/src/containers/RedashContainer/index.jsx
+++ b/src/containers/RedashContainer/index.jsx
@@ -30,6 +30,7 @@ const chartJsOptions = ({
         {
           ticks: {
             beginAtZero: true,
+            max: 31000,
             reverse,
           },
         },
@uu1t
Copy link

uu1t commented Oct 12, 2018

The same issue is reported in chartjs/Chart.js#4202 and fixed in chartjs/Chart.js#5321 but not yet released.

Using that commit will resolve this:
screen shot 2018-10-12 at 12 16 05

Diff:

diff --git a/package.json b/package.json
index fd3ea90..bebc445 100644
--- a/package.json
+++ b/package.json
@@ -37,7 +37,7 @@
     "@material-ui/icons": "^3.0.1",
     "@mozilla-frontend-infra/perf-goggles": "^2.0.1",
     "aggregatejs": "^0.0.5",
-    "chart.js": "^2.7.2",
+    "chart.js": "chartjs/Chart.js#7c3e934",
     "classnames": "^2.2.5",
     "d3": "^4.10.0",
     "lodash": "^4.17.2",
diff --git a/yarn.lock b/yarn.lock
index 9f5e772..773efac 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2058,10 +2058,9 @@ chardet@^0.7.0:
   resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
   integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==
 
-chart.js@^2.7.2:
+chart.js@chartjs/Chart.js#7c3e934:
   version "2.7.2"
-  resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-2.7.2.tgz#3c9fde4dc5b95608211bdefeda7e5d33dffa5714"
-  integrity sha512-90wl3V9xRZ8tnMvMlpcW+0Yg13BelsGS9P9t0ClaDxv/hdypHDr/YAGf+728m11P5ljwyB0ZHfPKCapZFqSqYA==
+  resolved "https://codeload.github.com/chartjs/Chart.js/tar.gz/7c3e934062c2679d6e06905b342f6432dd7d87f6"
   dependencies:
     chartjs-color "^2.1.0"
     moment "^2.10.2"

@armenzg
Copy link
Contributor Author

armenzg commented Oct 12, 2018

oh wow! I didn't know you could include a revision from GitHub.

I have a PR with your proposed fix and gave you credit in it.
Do you prefer to do the PR yourself so the code lands under your name?
Or are you OK if I land it?
#180

@armenzg
Copy link
Contributor Author

armenzg commented Oct 12, 2018

Also, let me know if you would be interested on contributing.

@uu1t
Copy link

uu1t commented Oct 13, 2018

No problem if you merge #180.

@armenzg
Copy link
Contributor Author

armenzg commented Oct 15, 2018

Thank you @uu1t !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants