ScatterChart and Line/Bar charts have a completely different data format. For the first there are two continuous axis x,y and the second has only a single continuous axis y where the first column usually holds labels of type string.
Swapping between Scatter and Line over the same data should usually not make sense. HTH, ChartMan On Fri, Aug 13, 2010 at 10:52 PM, Adam <[email protected]> wrote: > Hi, > > I am working on an application that displays the same data using > different graph types. I am using the Image Chart API in the > Visualization API for this as you can use a common DataTable and then > swap the chart type to draw various different styles of charts. > > This works great for Line charts and Bar charts. You can keep > everything the same and just switch the type and the graphs will look > perfect. Doing this for Scatter charts though and the result has no > similarities to the line/bar versions. The axes are labelled wrong, > points are misplaced and coloured wrong, and the legend disappears. > > Why does the image version of the scatter chart behave so differently > and is there an easy way to make it look the same as the line/bar > versions using the same data? > > I am using the following code in the Visualization Playground: > > function drawVisualization() { > var options = {}; > options.cht = 's'; > options.colors = ['#144BE3', '#8BE8E7']; > options.legend = 'right'; > options.width = 600; > > var dataTable = new google.visualization.DataTable({"cols": > [{"id":"x","label":"Date","type":"date"}, > {"id":"A","label":"A","type":"number"}, > {"id":"B","label":"B","type":"number"}],"rows":[{"c":[{"v":new > Date(1072940400000),"f":"2004"},{"v":4.4495715227422545},{"v": > 3.5833249217724843}]},{"c":[{"v":new Date(1104562800000),"f":"2005"}, > {"v":3.0806647750304013},{"v":4.3118232152481752}]},{"c":[{"v":new > Date(1136098800000),"f":"2006"},{"v":4.1568627450980395},{"v": > 4.4964463569114734}]},{"c":[{"v":new Date(1167634800000),"f":"2007"}, > {"v":4.5918771277016868},{"v":4.1087382351535995}]}]},0.6); > var chart = new > google.visualization.ImageChart(document.getElementById('visualization')); > chart.draw(dataTable, options); > } > > I am generating the datatable format from serializing c# objects to > json and this same data works for all other charts in the > visualization api. > > Switching the line: > > options.cht = 's'; > > to: > > options.cht = 'bvg'; > > will result in a correctly rendered bar graph with correct years as > the axes and correct colors/points/legends. This also works for a cht > of 'lc' for line charts. The Image Chart visualization says that it is > a generic wrapper for all types in the chart api so I am wondering why > the scatter graph renders so differently. > > What has to be change in my code to get the scatter charts to look the > same? > > Thanks, > > -Adam > > -- > You received this message because you are subscribed to the Google Groups > "Google Visualization API" group. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-visualization-api%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-visualization-api?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. 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.
