Hi Daniel, 

I saw your post.. even 3 years after. It helps for me, thank you.

I have a question, how can I put two lines into one graph but this two 
lines have different date range, I mean, for example, one line has 7 days 
but another only have 2 days.

I tried it in your way, but got error message for column number. Do you 
have a solution for this.

Thanks,
James

On Tuesday, February 25, 2014 at 11:34:25 PM UTC+8, Daniel LaLiberte wrote:
>
> I believe what you want would work if you use the 'domain' role (see 
> https://developers.google.com/chart/interactive/docs/roles ). For each 
> date regardless of year, you would have two domain columns, one for one 
> year, and one for the prior year, and two columns for the values on those 
> dates.
>
> Here is an example of how this can be done:
>
> function drawVisualization() {
>   // Create and populate the data table.
>         var data = new google.visualization.DataTable();
>         data.addColumn({type: 'date', role: 'domain'}, '2009 Quarter');
>         data.addColumn('number', '2009 Sales');
>         data.addColumn({type: 'date', role: 'domain'}, '2008 Quarter');
>         data.addColumn('number', '2008 Sales');
>         data.addRows([
>           [new Date(2009, 0, 1), 1000, new Date(2008, 0, 1), 800],
>           [new Date(2009, 1, 1), 800, new Date(2008, 1, 1), 600],
>           [new Date(2009, 2, 1), 765, new Date(2008, 2, 1), 987],
>           [new Date(2009, 3, 1), 555, new Date(2008, 3, 1), 1500]
>         ]);
>
>   // Create and draw the visualization.
>   new google.visualization.LineChart(document.getElementById(
> 'visualization')).
>       draw(data, {width: 500, height: 400,
>                   focusTarget: 'category'}
>           );
> }
>
>
>
> On Tue, Feb 25, 2014 at 5:20 AM, KWeb <[email protected] 
> <javascript:>> wrote:
>
>> I'm trying to create a line chart which has this current year's (or 
>> months) data and then to compare it to last year's (or months) data - 
>> similar to the functionality you have in Google Analytics where you can 
>> compare site traffic for this year against last year (see below screen shot)
>>
>>
>> <https://lh6.googleusercontent.com/-LSmPkGdrgiE/UwxtwLLZAzI/AAAAAAAAAI0/Q4-gxTP6pwg/s1600/Chart.jpg>
>> I can't seem to work out how to plot these 2 sets of data on the same 
>> chart because one would have dates from a different range to the other set.
>>
>> Any pointers/advice would be really appreciated.
>>
>> Thanks
>>
>> -- 
>> 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 [email protected] 
>> <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at 
>> http://groups.google.com/group/google-visualization-api.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> -- 
> Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2> 
>  - 978-394-1058
> [email protected] <javascript:>   5CC, Cambridge MA
> [email protected] <javascript:> 9 Juniper Ridge Road, Acton MA
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/326dbb80-ac78-4ff5-98b0-b042109fdcd0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to