Shark986
unread,Apr 26, 2012, 6:44:06 AM4/26/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Visualization API
Hi All!!
I need to show a chart with theese informations:
- On the y-axis a 0-50 scale
- On the x-axis a list of combination of customer-year
- For every customer-year, more values of the 0-50 scale
- (if possible) A label for every 0-50 value
Example of data (without labels):
CustomerA-2010: 9, 10, 8, 15
CustomerA-2011: 10, 15, 12, 11, 14
CustomerB-2010: 12, 20, 15, 18, 19, 17
CustomerB-2011: 26, 21, 15, 16, 18, 17, 20
CustomerC-2011: 17
At this moment I'm using a ScatterChart, but i can't use the customer-
year combination for the x-axis (I have to use numbers), so I use a
legend to show that the columnX is a specific customer-year
combination.
This is the code I'm using:
var tab = new google.visualization.DataTable();
tab.addColumn('number', 'CustomerA-2010');
tab.addColumn('number', 'CustomerA-2011');
tab.addColumn('number', 'CustomerB-2010');
tab.addColumn('number', '0-50 Value');
var rows = "1,22°1,45°2,47°2,38°2,44°3,23".split("°");
var row;
for (var i in rows) {
row = rows[i].trim().split(",");
switch (row[0]) {
case '1':
tab.addRow(new Array(parseInt(row[0]),
parseFloat(row[1]), null, null));
break;
case '2':
tab.addRow(new Array(parseInt(row[0]), null,
parseFloat(row[1]), null));
break;
case '3':
tab.addRow(new Array(parseInt(row[0]), null,
null, parseFloat(row[1])));
break;
}
}
var opzioni = {
height: 450,
vAxis: { minValue: 0, maxValue: 50 },
hAxis: { minValue: 1, maxValue: 3 },
legend: 'bottom'
};
var chart = new
google.visualization.ScatterChart(document.getElementById('div_popup_content'));
chart.draw(tab, opzioni);
Is there a better solution?
I will appreciate any suggest!
PS: Excuse for my English!!