I have a page that displays 5 columns of data. When I add a 6th column an
error. I have tried several fixed based on the thought that my data was bad
(addslashes, etc)
Here is the code that works:
var data = new google.visualization.DataTable();
data.addRows(<?php echo $howmany;?>);
data.addColumn('string', 'Group', 'Group');
data.addColumn('string', 'SKU', 'SKU');
data.addColumn('string', 'Description', 'Description');
data.addColumn('string', 'UOM', 'UOM');
data.addColumn('number', 'Quantity', 'Quantity');
<?php
if ($howmany > 0)
{
$counter = 0;
while($row = mysql_fetch_array($resultDlr))
{
echo 'data.setValue(' . $counter . ', 0, \'' .
$row['prodgroup'] . '\');';
echo 'data.setValue(' . $counter . ', 1, \'' .
$row['sku'] . '\');';
echo 'data.setValue(' . $counter . ', 2, \'' .
addslashes($row['description']) . '\');';
echo 'data.setValue(' . $counter . ', 3, \'' .
$row['uom'] . '\');';
echo 'data.setValue(' . $counter . ', 4, ' .
$row['qty'] . ');';
$counter = $counter + 1;
}
}
?>
var table2 = new
google.visualization.Table(document.getElementById('chart_divT'));
var formatter = new google.visualization.NumberFormat(
{});
formatter.format(data, 4);
table2.draw(data, {showRowNumber: false, width: '800px',
page: 'enable', pageSize: 20, 'allowHtml': true, 'cssClassNames':
cssClassNames});
when I add one column, the code is this, and it breaks:
var data = new google.visualization.DataTable();
data.addRows(<?php echo $howmany;?>);
data.addColumn('string', 'Group', 'Group');
data.addColumn('string', 'SKU', 'SKU');
data.addColumn('string', 'Description', 'Description');
data.addColumn('string', 'UOM', 'UOM');
data.addColumn('number', 'Quantity', 'Quantity');
*data.addColumn('string', 'ETA', 'ETA');*
<?php
if ($howmany > 0)
{
$counter = 0;
while($row = mysql_fetch_array($resultDlr))
{
echo 'data.setValue(' . $counter . ', 0, \'' .
$row['prodgroup'] . '\');';
echo 'data.setValue(' . $counter . ', 1, \'' .
$row['sku'] . '\');';
echo 'data.setValue(' . $counter . ', 2, \'' .
addslashes($row['description']) . '\');';
echo 'data.setValue(' . $counter . ', 3, \'' .
$row['uom'] . '\');';
echo 'data.setValue(' . $counter . ', 4, ' .
$row['qty'] . ');';
* echo 'data.setValue(' . $counter . ', 5, \'' .
$row['eta'] . '\');';*
$counter = $counter + 1;
}
}
?>
var table2 = new
google.visualization.Table(document.getElementById('chart_divT'));
var formatter = new google.visualization.NumberFormat(
{});
formatter.format(data, 4);
table2.draw(data, {showRowNumber: false, width: '800px',
page: 'enable', pageSize: 20, 'allowHtml': true, 'cssClassNames':
cssClassNames});
The only possible values from the db for field ETA are stored as strings:
NA
Jan 12, 2013
Dec 18, 2012
Dec 13, 2012
Dec 22, 2012
Dec 01, 2012
Dec 12, 2012
The error I get is: Uncaught SyntaxError: Unexpected token ILLEGAL
and in Chrome, the source looks like this, showing that the first single
quote around the first ETA is black and not red, which seems to be messing
up the syntax of what I am writing out.
data.setValue(0, 0, 'CTOP');data.setValue(0, 1, 'PFBC-3096');data.setValue(0,
2, 'Prefinished Butcher Block');data.setValue(0, 3, 'PIECE');data.setValue(0,
4, 17.00);data.setValue(0, 5, ' ');
Please help !!
Tony
--
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/-/4sBoSl2AO04J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.