Michael, Your domain data should generally be in ascending order, and then you can use the 'direction' option on the domain axis (hAxis for you) to switch the direction of that axis.
On Sat, Jun 6, 2015 at 9:08 AM, Michael S <[email protected]> wrote: > Hello! > > Please tell me how can i sort date descending. > > I give the date already sorted as descending (from 06 Jan till 03 Jan) but > API sorts this date acsending on graph (from 03 Jan till 06 Jan). > > I get: > > > <https://lh3.googleusercontent.com/-KiR96H_6qUA/VXLwg4uT4gI/AAAAAAAABho/vhtUpTgO41k/s1600/Screenshot_5.jpg> > > Here is my code > > <script type="text/javascript"> > google.load('visualization', '1', {packages: ['corechart', 'line']}); > google.setOnLoadCallback(drawTrendlines); > > function drawTrendlines() { > var data = new google.visualization.DataTable(); > data.addColumn('date', 'Time of Day'); > data.addColumn('number', 'Dogs'); > > data.addRows([ > [new Date ('Jun 06, 2015'), 0],[new Date ('Jun 05, 2015'), 4],[new > Date ('Jun 04, 2015'), 3],[new Date ('Jun 03, 2015'), 4] > > ]); > > data.sort([{column: 0, desc: true}, {column: 1, desc: true}]); > > var options = { > hAxis: { > format: 'd/M/yy', > }, > vAxis: { > title: 'Popularity' > }, > colors: ['#AB0D06', '#007329'], > trendlines: { > 0: {type: 'linear', color: '#111', opacity: .3} > } > }; > > var chart = new > google.visualization.LineChart(document.getElementById('chart_div1')); > chart.draw(data, options); > } > > </script> > > <div id="chart_div1"></div> > > > Thanks a lot! > > -- > 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 > http://groups.google.com/group/google-visualization-api. > For more options, visit https://groups.google.com/d/optout. > -- Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2> - 978-394-1058 [email protected] <[email protected]> 5CC, Cambridge MA [email protected] <[email protected]> 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 http://groups.google.com/group/google-visualization-api. For more options, visit https://groups.google.com/d/optout.
