scatter chart with multiple sets of x,y data

39 views
Skip to first unread message

asx...@gmail.com

unread,
Nov 16, 2015, 2:12:13 AM11/16/15
to Google Visualization API
Using the scatter chart i would like to plot several sets of data with x,y points. When doing so I find that the first column of x points with the role domain sets the x axis and subsequent assignment of a column as role domain appears to be ignored with the next column defined as data (i.e. y axis values) are aligned to the first set of domain values.

e.q.

google.setOnLoadCallback(drawChart);
      function drawChart() {
        //var data = new google.visualization.DataTable();
 var data = new google.visualization.DataTable({
    cols: [{id: 'a', label: 'DomA', type: 'number', role: 'domain'},
               {id: 'b', label: 'DataA', type: 'number', role: 'data'},
               {id: 'c', label: 'DomB', type: 'number', role: 'domain'},
               {id: 'd', label: 'DataB', type: 'number', role: 'data'}],
    rows: [{c:[{v: 1}, {v: 2}  ,{v: 6},  {v: 1}]},
              {c:[{v: 2}, {v: 4}  ,{v: 7},  {v: 2}]},
               {c:[{v: 3}, {v: 6}  ,{v: 8},  {v: 3}]},
               {c:[{v: 4}, {v: 8}  ,{v: 9},  {v: 4}]},
               {c:[{v: 5}, {v: 10} ,{v: 10}, {v: 5}]}]
      }, 0.6);

additionally I would like to be able to display sets of x,y data with various lengths. In the example above I want to plot points {(1,2),(2,4),(4,8),(5,10)} and then points {(6,1),(7,2),(8,3),(9,4),(10,5)}.

Daniel LaLiberte

unread,
Nov 16, 2015, 8:59:46 AM11/16/15
to Google Visualization API
hi asximen,

The multiple-domain support is obviously lacking.   Your best bet is probably to not use multiple domains but instead use null values in the series where there is no value.  Here is your jsfiddle modified to do this:  https://jsfiddle.net/dlaliberte/eaqth466/2/

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/b99c59f5-e572-4c47-9c19-5de53a061890%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
dlaliberte@Google.com   5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA

asx...@gmail.com

unread,
Nov 16, 2015, 7:37:40 PM11/16/15
to Google Visualization API
Thanks Daniel,

Yes the method of using a null value will work.

In the more general case the domain values of the dataset could be different. I guess the solution in this case is to interpolate the data to fit the first defined domain set.


On Monday, November 16, 2015 at 10:59:46 PM UTC+9, Daniel LaLiberte wrote:
hi asximen,

The multiple-domain support is obviously lacking.   Your best bet is probably to not use multiple domains but instead use null values in the series where there is no value.  Here is your jsfiddle modified to do this:  https://jsfiddle.net/dlaliberte/eaqth466/2/
On Mon, Nov 16, 2015 at 2:12 AM, <asx...@gmail.com> wrote:
Using the scatter chart i would like to plot several sets of data with x,y points. When doing so I find that the first column of x points with the role domain sets the x axis and subsequent assignment of a column as role domain appears to be ignored with the next column defined as data (i.e. y axis values) are aligned to the first set of domain values.

e.q.

google.setOnLoadCallback(drawChart);
      function drawChart() {
        //var data = new google.visualization.DataTable();
 var data = new google.visualization.DataTable({
    cols: [{id: 'a', label: 'DomA', type: 'number', role: 'domain'},
               {id: 'b', label: 'DataA', type: 'number', role: 'data'},
               {id: 'c', label: 'DomB', type: 'number', role: 'domain'},
               {id: 'd', label: 'DataB', type: 'number', role: 'data'}],
    rows: [{c:[{v: 1}, {v: 2}  ,{v: 6},  {v: 1}]},
              {c:[{v: 2}, {v: 4}  ,{v: 7},  {v: 2}]},
               {c:[{v: 3}, {v: 6}  ,{v: 8},  {v: 3}]},
               {c:[{v: 4}, {v: 8}  ,{v: 9},  {v: 4}]},
               {c:[{v: 5}, {v: 10} ,{v: 10}, {v: 5}]}]
      }, 0.6);

additionally I would like to be able to display sets of x,y data with various lengths. In the example above I want to plot points {(1,2),(2,4),(4,8),(5,10)} and then points {(6,1),(7,2),(8,3),(9,4),(10,5)}.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.



--
dlali...@Google.com   5CC, Cambridge MA
daniel.l...@GMail.com 9 Juniper Ridge Road, Acton MA
Reply all
Reply to author
Forward
0 new messages