Skip to content
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

Chart shows the measure name, not the measure label #55

Open
bdauvergne opened this issue Nov 20, 2015 · 2 comments
Open

Chart shows the measure name, not the measure label #55

bdauvergne opened this issue Nov 20, 2015 · 2 comments
Assignees
Labels
Milestone

Comments

@bdauvergne
Copy link

I think that in a chat the y-axis should be labeled using the measure label. I can work on it if I'm given some direction.

@devvmh
Copy link
Contributor

devvmh commented Dec 29, 2015

I'd love to see this happen @bdauvergne, but I don't have time to really dig in to it. I experimented today and came up with this, which hopefully is the direction you're looking for? Fork the repository, make these changes, and see where you get.

You'll still need to read through a LOT of javascript files and use your browser developer tools to set breakpoints, etc, to finish it.

diff --git a/src/web/static/js/cubesviewer/cubesviewer.views.cube.chart.js b/src/web/static/js/cubesviewer/cubesviewer.views.cube.chart.js
index aca1462..50aa527 100644
--- a/src/web/static/js/cubesviewer/cubesviewer.views.cube.chart.js
+++ b/src/web/static/js/cubesviewer/cubesviewer.views.cube.chart.js
@@ -305,6 +305,35 @@ function cubesviewerViewCubeChart() {

   };

+  this.findLabel = function(view, name) {
+    //check for a label in aggregates first
+    //then check in dimensions
+    to_return = "";
+    $(view.cube.aggregates).each(function(idx, agg) {
+      if (name === agg.name) {
+        to_return = agg.label || agg.name;
+        return false; //break
+      }
+    });
+    if (to_return !== "") {
+      return to_return;
+    }
+
+    $(view.cube.dimensions).each(function(idx, dim) {
+      if (name === dim.name) {
+        to_return = dim.label || dim.name;
+        return false; //break
+      }
+    });
+    if (to_return !== "") {
+      return to_return;
+    }
+
+    //fallback to using the name
+    return name;
+  };
+
        /**
         * Draws a vertical bars chart.
         */
@@ -320,11 +349,12 @@ function cubesviewerViewCubeChart() {
            $(dataRows).each(function(idx, e) {
                serie = [];
                for (var i = 1; i < colNames.length; i++) {
+                       var label = this.findLabel(view, colNames[i]);
                        var value = e[colNames[i]];
                        if (value != undefined) {
-                               serie.push( { "x": colNames[i], "y":  value } );
+                               serie.push( { "x": label, "y":  value } );
                        } else {
-                               serie.push( { "x": colNames[i], "y":  0} );
+                               serie.push( { "x": label, "y":  0} );
                        }
                }
                var series = { "values": serie, "key": e["key"] != "" ? e["key"] : view.params.yaxis };
@@ -335,7 +365,7 @@ function cubesviewerViewCubeChart() {
                }
                d.push(series);
                serieCount++;
-           });
+           }.bind(this));
            d.sort(function(a,b) { return a.key < b.key ? -1 : (a.key > b.key ? +1 : 0) });

            /*

@jjmontesl jjmontesl added the bug label Apr 8, 2016
@jjmontesl jjmontesl modified the milestones: 2.0.x, 2.1.x Apr 30, 2016
@jjmontesl
Copy link
Owner

This shall be fixed by 2174b95, still in the devel branch.

Will keep this open until 2.0 is out and resolution is confirmed.

@jjmontesl jjmontesl modified the milestones: 2.1.x, 2.0.x May 23, 2016
@jjmontesl jjmontesl self-assigned this May 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants