Re: [visualization-api] Make the vAxis go from higher numbers to lower numbers

27 views
Skip to first unread message

Daniel LaLiberte

unread,
Dec 1, 2016, 10:07:31 AM12/1/16
to Google Visualization API
Just add vAxis: { direction: -1 }

On Thu, Dec 1, 2016 at 5:08 AM, Tiago Peres <tiagomar...@gmail.com> wrote:

Hello! How can I make the vAxis go from 10 to 0?

As you can see, it was not enough what I did here.




// Callback that draws the pie chart for No Hedge Fund's chart.
function draw0hedgeChart() {
  var data = new google.visualization.DataTable();
  data.addColumn('number', 'X');
  data.addColumn('number', 'Y');

    //here we enter the data
  data.addRows([
   [ 9.87,      6.53],
  ]);

    //variables such as title, axis, width and height of the scatterplot
    var options = {
        colors: ['#000000'],
        legend: 'none',
          title: 'Risk vs. Return with 0% Hedge Fund',
          hAxis: {title: 'Risk', minValue: 7, maxValue: 10, gridlineColor: '#fff'},
          vAxis: {title: 'Return', minValue: 10, maxValue: 0, gridlineColor: '#fff'},    /////////////////////////////////// Here is wherewant to make the axis navigate from the value 10, going to 0
          width:900,
          height:500
        };


  var container = document.getElementById('chart0_div'); //here we define the id of the element. This name is what we must use in a div to make the chart appear
  var chart = new google.visualization.ScatterChart(container);

  google.visualization.events.addListener(chart, 'ready', function () {
    var layout = chart.getChartLayoutInterface();
     
    for (var i = 0; i < data.getNumberOfRows(); i++) {
       
        var xPos = layout.getXLocation(data.getValue(i, 0));
        var yPos = layout.getYLocation(data.getValue(i, 1));

        var widget0 = container.appendChild(document.createElement('img'));
        widget0.src = 'img/0.png';
        widget0.className = 'chart0';

        // (overlay the dot)
        widget0.style.top = (yPos - 50) + 'px';
        widget0.style.left = (xPos - 50) + 'px';
     
    }
  });

  chart.draw(data, options);
}       

--
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.
To post to this group, send email to google-visualization-api@googlegroups.com.
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/09a061ad-965f-4a74-8666-88fd25602019%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Bill Rebey

unread,
Dec 5, 2016, 9:30:55 AM12/5/16
to Google Visualization API
Daniel, this sounds like precisely the same problem that you've been trying to help me with in the question above, titled "Material Bar Charts Always Render in Sorted, Ascending Order. How do I Get Descending Order?", except that my issue is with Bar charts, and yours is with ScatterChart.

Have you gotten anywhere with this?  I'm guessing that the solution to this problem will be very similar to the solution to mine...


Daniel LaLiberte

unread,
Dec 5, 2016, 10:11:54 AM12/5/16
to Google Visualization API
You'll need to use the 'classic' charts in order to use the direction: -1 option.  And to use your domain values not for their values but just keep the same order as in the datatable, change those values to strings or add the type: 'category' option to your domain axis.

On Mon, Dec 5, 2016 at 9:30 AM, Bill Rebey <bill...@gmail.com> wrote:
Daniel, this sounds like precisely the same problem that you've been trying to help me with in the question above, titled "Material Bar Charts Always Render in Sorted, Ascending Order. How do I Get Descending Order?", except that my issue is with Bar charts, and yours is with ScatterChart.

Have you gotten anywhere with this?  I'm guessing that the solution to this problem will be very similar to the solution to mine...


--
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.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages