Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

367
Views
Gráficos de Google: evite mostrar valores negativos en el eje

Incluso incluyendo vAxis: {minValue:0} no funcionó

¿Cómo puedo hacer para evitar mostrar valores negativos en el eje y?

Esto sucede cuando no existe ningún valor. En este caso no quiero que aparezcan valores negativos en el eje

 google.charts.load('current', {packages: ['corechart','bar'],'language': 'pt'}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var arrayToData = [['Date','','Data',{role: 'style'},{role:'tooltip', 'p': {'html': true}}]]; arrayToData.push(['01/06', 0,0,'','']); arrayToData.push(['02/06', 0,0,'','']); arrayToData.push(['03/06', 0,0,'','']); var data = new google.visualization.arrayToDataTable(arrayToData); var options = google.charts.Bar.convertOptions( { tooltip: {isHtml: true}, chartArea: { height: '100%', width: '100%', top: 38, left: 15, right: 100, bottom: 48 }, vAxis: { viewWindow:{ min: 0 } }, yAxis:{ viewWindowMode: "explicit", viewWindow:{ min: 0 } }, series: { 0: {enableInteractivity: false,targetAxisIndex: 0, visibleInLegend: false, pointSize: 0, lineWidth: 0,type: 'line',textStyle: {fontSize: 0}}, 1: { targetAxisIndex: 1, } }, vAxes: { 0: {textPosition: 'none'}, 1: {}, }, }); var chart = new google.visualization.ColumnChart(document.getElementById('chart_div')); chart.draw(data, options); }
 <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <div id="chart_div"></div>

He probado varias alternativas y ninguna ha tenido éxito.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

intente usar la opción de ticks ...

 vAxis: { ticks: [0, 1, 2] },

ver siguiente fragmento de trabajo...

 google.charts.load('current', {packages: ['corechart','bar'],'language': 'pt'}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var arrayToData = [['Date','','Data',{role: 'style'},{role:'tooltip', 'p': {'html': true}}]]; arrayToData.push(['01/06', 0,0,'','']); arrayToData.push(['02/06', 0,0,'','']); arrayToData.push(['03/06', 0,0,'','']); var data = new google.visualization.arrayToDataTable(arrayToData); var options = { tooltip: {isHtml: true}, chartArea: { height: '100%', width: '100%', top: 38, left: 15, right: 100, bottom: 48 }, vAxis: { ticks: [0, 1, 2] }, series: { 0: {enableInteractivity: false,targetAxisIndex: 0, visibleInLegend: false, pointSize: 0, lineWidth: 0,type: 'line',textStyle: {fontSize: 0}}, 1: { targetAxisIndex: 1, } }, vAxes: { 0: {textPosition: 'none'} }, }; var chart = new google.visualization.ColumnChart(document.getElementById('chart_div')); chart.draw(data, options); }
 <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <div id="chart_div"></div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!