stepped graph using AreaChart

44 views
Skip to first unread message

Radhouene

unread,
Oct 25, 2011, 10:24:29 AM10/25/11
to Google Visualization API
Hello,
i need to display a "stepped graph" using AreaChart. I tried to do it
but i didn't have any result. I tried to do someting like that:
data.addRow(["A", 1]);
data.addRow(["B", 1]);
data.addRow(["B", 2]);
data.addRow(["C", 2]);
data.addRow(["C", 3]);
data.addRow(["D", 3]);
data.addRow(["D", 4]);

i receive similar x values (A,B,B,C,C,D,D)
If anyone has solutions to this issue, please help me.

Thanks in Advance !!

asgallant

unread,
Oct 25, 2011, 12:16:18 PM10/25/11
to google-visua...@googlegroups.com
IIRC, you should be able to do that with an area chart, but not with string values for the first column (it only works with numbers).  With strings, the chart renders with each row having its own axis tick.  With numbers, it renders the chart in coordinate grid system, which is what you need to do.

Radhouene Gniwa

unread,
Oct 25, 2011, 12:37:41 PM10/25/11
to google-visua...@googlegroups.com
But, the first column should be a String. i you try some thing like this:
 data.addColumn('number', 'x');
  data.addColumn('number', 'Cats');
  data.addRow([1, 1]);
  data.addRow([2, 1]);
  data.addRow([2, 4]);
  data.addRow([3, 4]);
  data.addRow([3, 4]);
  data.addRow([4, 5]);
  data.addRow([4, 8]);
  data.addRow([5, 8]);
  data.addRow([5, 7]);
  data.addRow([6, 7]);
  data.addRow([6, 7]);

you will receive two Area.

2011/10/25 asgallant <drew_g...@abtassoc.com>
IIRC, you should be able to do that with an area chart, but not with string values for the first column (it only works with numbers).  With strings, the chart renders with each row having its own axis tick.  With numbers, it renders the chart in coordinate grid system, which is what you need to do.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/5Sqi4wGSglIJ.

To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

asgallant

unread,
Oct 25, 2011, 1:34:25 PM10/25/11
to google-visua...@googlegroups.com
You need to set the 'strictFirstColumnType' option to true to make this work:

function drawChart({
  var data new google.visualization.DataTable();

  data.addColumn('number''x');
  data.addColumn('number''Cats');
  data.addRow([11]);
  data.addRow([21]);
  data.addRow([24]);
  data.addRow([34]);
  data.addRow([34]);
  data.addRow([45]);
  data.addRow([48]);
  data.addRow([58]);
  data.addRow([57]);
  data.addRow([67]);
  data.addRow([67]);
  
  var chart new google.visualization.AreaChart(document.getElementById('chart_div'));
  chart.draw(data{
      strictFirstColumnTypetrue
  });
}

Radhouene Gniwa

unread,
Oct 25, 2011, 7:19:46 PM10/25/11
to google-visua...@googlegroups.com
Thanks a lot. That work .

2011/10/25 asgallant <drew_g...@abtassoc.com>

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.

EZChart

unread,
Oct 26, 2011, 1:39:04 AM10/26/11
to google-visua...@googlegroups.com
We have an experimental chart called SteppedArea which does this.

Note that this chart is not documented and we may stop supporting it at any time without notice.

EZChart

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
Reply all
Reply to author
Forward
0 new messages