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

barChart failing in v2.1.5-SNAPSHOT but wokring in v2.1.4-SNAPSHOT #39

Open
GoogleCodeExporter opened this issue Jun 4, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?

Try to render a barGraph, and it will fail. A pieChart is still working.
The barGraph was working with a previous version of elycharts.

This is my template:

$.elycharts.templates['call_status_hours'] = {
    type: "line",
    margins: [10, 40, 40, 30],
    defaultSeries: {
      plotProps : {
          stroke : "none"
      },
      highlight: {
          newProps: {
          r: 8,
          opacity: 1
        },
        overlayProps: {
          fill: "white",
          opacity: 0.2
        }
      },
      tooltip: {
          height: 100,
          width: 120,
          frameProps: {
              opacity: 0.95,
              stroke: "#ccc"
          }
      }
    },
    series: series,
    defaultAxis: {
      labels: true
    },
    axis: {
      x: {
        labelsRotate: 45,
        labelsProps: {
          font: "11px Verdana"
        }
      }
    },
    features: {
      grid: {
        draw: true,
        forceBorder: true,
        ny: 5 // TODO: this is the parameter to set dynamically
      }
    },
    barMargins: 5
  };

This is my chart:

  $("#chart_call_status_hours")
      .chart({
      template: "call_status_hours",
      tooltips: tooltips,
      values: values,
      labels: labels,
      defaultSeries: {
        type: "bar",
        stacked: true
      }
  }).animate({opacity:1},1000);

The bar graph is not rendering, because there is an error: function colorize is 
failing when walking expandKeys:

  /**
   * Given an expandKey as array of array it sets the color to the nested tree unless it is already defined.
   * So [ [ 'parent', 'child' ], [ 'item' ] ] will try to put color in props.parent.child and props.item unless
   * they already exists.
   */
  colorize : function(env, props, expandKeys, color) {
    if (color) {
          console.log('expandKeys=%o',expandKeys);
      for (k in expandKeys) {
            console.log('doing k=%o -> expandKeys[k]=%o', k, expandKeys[k]);
        var p = props;
        var i = 0;
        for (i = 0; i < expandKeys[k].length - 1; i++) {
          if (!p[expandKeys[k][i]]) p[expandKeys[k][i]] = {};
          p = p[expandKeys[k][i]];
        }
        if (!p[expandKeys[k][expandKeys[k].length-1]]) p[expandKeys[k][expandKeys[k].length-1]] = color;
      }
    }
  },

It is failing because it is trying to walk key "firstObject":

doing k="firstObject" -> expandKeys[k]=undefined
Uncaught TypeError: Cannot read property 'length' of undefined

My data is:
expandKeys : 
0: Array[2]
0: "plotProps"
1: "stroke"
length: 2
__proto__: Array[0]
1: Array[2]
0: "plotProps"
1: "fill"
length: 2
__proto__: Array[0]
length: 2
__proto__: Array[0]

It seems to be walking the proto.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
v2.1.5-SNAPSHOT is wrong. v2.1.4-SNAPSHOT is working fine.

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 17 Feb 2014 at 8:10

@GoogleCodeExporter
Copy link
Author

Unfortunately the code you provided is missing the series, values, tooltips and 
labels variables.

I tried setting my own variable and the chart has been plotted correctly, so I 
assume the bug depends on those data.

Can you please provide the whole code or even better create a jsbin/jsfiddle 
proving the bug?

Original comment by [email protected] on 17 Feb 2014 at 12:04

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

No branches or pull requests

1 participant