ululalbab / google-motion-charts-with-r

Automatically exported from code.google.com/p/google-motion-charts-with-r
0 stars 0 forks source link

gvisMotionChart doesn't seem to recognize Date despite date.format give #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
> gvisData
        Stock       Date     Price
1  ftsemib.mi 2004-12-31 100.00000
2  ftsemib.mi 2005-03-31 104.52707
3  ftsemib.mi 2005-06-30 104.65974
4  ftsemib.mi 2005-09-30 112.52953
5  ftsemib.mi 2005-12-31 115.53571
6  ftsemib.mi 2006-03-31 122.73242
7        gold 2004-12-31 100.00000
8        gold 2005-03-31  93.31369
9        gold 2005-06-30  94.37897
10       gold 2005-09-30 116.02448
11       gold 2005-12-31 135.56210
12       gold 2006-03-31 161.32140
13     ucg.mi 2004-12-31 100.00000
14     ucg.mi 2005-03-31 107.11974
15     ucg.mi 2005-06-30 113.26861
16     ucg.mi 2005-09-30 121.68285
17     ucg.mi 2005-12-31 151.13269
18     ucg.mi 2006-03-31 155.01618
19     trn.mi 2004-12-31 100.00000
20     trn.mi 2005-03-31  96.73203
21     trn.mi 2005-06-30 104.57516
22     trn.mi 2005-09-30 104.57516
23     trn.mi 2005-12-31 104.57516
24     trn.mi 2006-03-31 108.49673
> 
> M <- gvisMotionChart(gvisData, idvar="Stock", timevar="Date", date.format = 
"%Y-%m-%d")

> M

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
 "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<%@include file="../src/simpleHead.rsp"%>
<body>
<%@include file="../src/simpleHeader.rsp"%>
 <!-- MotionChart generated in R 2.12.0 by googleVis 0.2.3 package -->
<!-- Tue Feb  1 14:23:42 2011 -->

<script type="text/javascript" src="http://www.google.com/jsapi">
</script>
<script type="text/javascript">
google.load("visualization", "1", { packages:["motionchart"] });
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
var datajson = [
 [
 "ftsemib.mi",
new Date(2004,11,31),
   100 
],
[
 "ftsemib.mi",
new Date(2005,2,31),
104.53 
],
...
[
 "trn.mi",
new Date(2006,2,31),
 108.5 
] 
];
data.addColumn('string','Stock');
data.addColumn('date','Date');
data.addRows(datajson);
var chart = new google.visualization.MotionChart(
   document.getElementById('MotionChart_2011-02-01-14-23-42')
);
var options ={};
options["width"] =    600;
options["height"] =    500;
chart.draw(data,options);
}
</script>
<div id="MotionChart_2011-02-01-14-23-42" style="width: 600px; height: 500px;">
</div>
 Data: gvisData, Chart ID: MotionChart_2011-02-01-14-23-42
<BR>
R version 2.12.0 (2010-10-15),
<a href="http://code.google.com/apis/visualization/terms.html">
Google Terms of Use</a>
<BR>
<BR>

<%@include file="../src/simpleFooter.rsp"%>
</body>
</html>

What is the expected output? What do you see instead?
the provided html code doesn't load the expected graph in firefox 4, Price is 
not considered (no data.addColumn statement)

What version of the product are you using? On what operating system?
googleVis-0.2.3 on OSX 10.6.5

Please provide any additional information below.
Using

M <- gvisMotionChart(Fruits, idvar="Fruit", timevar="Date", 
date.format="%Y-%m-%d")

doesn't work either (note Date instead of Year)

Original issue reported on code.google.com by matteo.z...@gmail.com on 1 Feb 2011 at 1:28

GoogleCodeExporter commented 9 years ago
Sorry, the title is misleading and Fruits with Date instead of Year works. 

The issue is solved by adding a data.addColumn statement for Price manually.

Original comment by matteo.z...@gmail.com on 1 Feb 2011 at 1:42

GoogleCodeExporter commented 9 years ago
The issue was invalid. 

Original comment by markus.g...@googlemail.com on 5 Feb 2011 at 3:37