Skip to content

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

Description

@GoogleCodeExporter
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 gonva...@gmail.com on 17 Feb 2014 at 8:10

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions