2012-06-07 27 views
15

tengo el siguiente código:Gráficos de Google - evitar mostrar valores negativos en el eje Y

function drawVisualization() { 
    // Create and populate the data table. 
    var data = google.visualization.arrayToDataTable([ 
    ['Year', 'People'], 
    ['2010',0] 
    ]); 

    // Create and draw the visualization. 
    new google.visualization.ColumnChart(document.getElementById('visualization')). 
     draw(data, 
      {title:"Yearly Coffee Consumption by Country", 
      width:600, height:400, 
      hAxis: {title: "Year"}, 
      backgroundColor: 'none' 
      } 
    ); 
} 

Lo que me da el siguiente cuadro chart

¿Cómo puedo hacer para evitar que se muestre valores negativos en el eje Y? He intentado agregar vAxis: {minValue:0} sin ningún tipo de suerte.

Hay un parque infantil/caja de arena para estas tablas: Google Charts Playground

Respuesta

51

Es necesario configurar viewWindowMode tan explícito

vAxis: {viewWindowMode: "explicit", viewWindow:{ min: 0 }} 
+0

Ahora esto en el o su mano parece arreglar mi problema. ¡Gracias! – slarti42uk

+4

esta es la respuesta correcta –

+0

'viewWindowMode:" explicit "' ya no es necesaria ya que ahora está en desuso. https://developers.google.com/chart/interactive/docs/gallery/linechart#configuration-options – etoxin

3

viewWindowMode: "explicit" está en desuso en la versión actual que utiliza: vaxis.viewWindow.min:

vAxis: { 
    viewWindow: { 
     min: 0 
    } 
} 
+0

Dicho correctamente, 'viewWindowMode:" explicit "' está en desuso. [Soure] (https://developers.google.com/chart/interactive/docs/gallery/linechart#configuration-options) – mshakeel

Cuestiones relacionadas