skip 0's and negative values from chart

25 views
Skip to first unread message

Navneet Kaur Johal

unread,
Nov 16, 2019, 4:51:49 AM11/16/19
to Google Visualization API
var data = google.visualization.arrayToDataTable([
          ['Year', 'Massachusetts', 'National'],
          ['2010',  88,  76],
          ['2011',  0,  82],
          ['2012',  96,  86],
          ['2013',  100,  91],
          ['2014',  0,  94],
          ['2015',  -1,  98],
          ['2016',  100,  99],
          ['2017',  124,  100],
          ['2018',  125,  102]
        ]);

This is the data I am using to create a line chart, I do not want to show 0's and negative values on the chart. I just want to skip these values.

Message has been deleted

Ray Thomas

unread,
Nov 17, 2019, 8:12:50 PM11/17/19
to Google Visualization API
Try putting nulls or leaving the data out altogether where zero and negative values are and setting interpolateNulls to true.

You should end up with something looking like this:

var data = google.visualization.arrayToDataTable([
    ['Year', 'Massachusetts', 'National'],
          ['2010',  88,  76],
          ['2011',  null,  82],
          ['2012',  96,  86],
          ['2013',  100,  91],
          ['2014',  null,  94],
          ['2015',  null,  98],
          ['2016',  100,  99],
          ['2017',  124,  100],
          ['2018',  125,  102]]);

  var options = { interpolateNulls: true };

or 

var data = google.visualization.arrayToDataTable([
    ['Year', 'Massachusetts', 'National'],
          ['2010',  88,  76],
          ['2011',  ,  82],
          ['2012',  96,  86],
          ['2013',  100,  91],
          ['2014',  ,  94],
          ['2015',  ,  98],
          ['2016',  100,  99],
          ['2017',  124,  100],
          ['2018',  125,  102]]);

  var options = { interpolateNulls: true };

Without setting interpolateNulls to true the graph will draw but you will have gaps in the line.

Yves De Jesus

unread,
Nov 17, 2019, 8:30:27 PM11/17/19
to google-visua...@googlegroups.com
my data set actually looks like:

var data = google.visualization.arrayToDataTable([
          ['Building', 'EUI'],
          ['Telecommunications Building', 705.6],
          ['Kolthoff Hall', 431.9],
          ['SE Steam Plant', 418.1],
          ['Center For Magnetic Resonance Research', 409.1],
          ['Physics and Nanotechnology', 371.9],
          ['Lions Research/McGuire Translational Research Facility', 357.5],
          ['Cancer & Cardiovascular Research Building', 353.9],
          ['Jackson Hall', 350.6],
          ['Medical Biosciences Building', 350.0],
          ['Aquatic Center', 340.6],
          ['Dwan Variety Club Cardio Research Center', 338.7],
          ['Smith Hall', 322.3],
          ['Phillips-Wangensteen Building', 319.6],
          ['Molecular and Cellular Biology', 299.6],
          ['Thompson Center for Environmental Management', 293.2],
          ['Amundson Hall', 290.5],
          ['Walter Library', 280.5],
          ['Bierman Field Athletic Building', 249.2],
          ['Shepherd Laboratories', 249.0],
          ['Transportation & Safety Building', 244.8],
          ['Moos Health Sciences Tower', 235.4],
          ['Weaver-Densford Hall', 235.1],
          ['Diehl Hall', 228.5],
          ['Hasselmo Hall', 226.8],
          ['Tate Laboratory Of Physics', 224.5],
          ['Keller Hall', 224.1],
          ['Microbiology Research Facility', 224.0],
          ['Clinics and Surgery Center', 213.2],
          ['Bierman Field Clubhouse', 187.8],
          ['Mechanical Engineering', 187.3],
          ['Mayo Building & Additions', 177.3],
          ['Boynton Health Service', 172.2],
          ['Variety Club Research Center', 161.2],
          ['717 Delaware St. SE (MN Dept. of Health)', 160.1],
          ['Cooke Hall', 159.6],
          ['Office of Information Technology Bldg', 158.4],
          ['MAST Laboratory', 158.3],
          ['Recreation Center', 148.7],
          ['Student Recreational Sports Field', 143.7],
          ['Elliott Hall', 141.9],
          ['Centennial Hall', 137.1],
          ['Childrens Rehabilitation Center', 133.9],
          ['Siebert Stadium', 128.7],
          ['Pattee Hall', 127.7],
          ['Comstock Hall', 122.6],
          ['Sanford Hall', 120.2],
          ['Territorial Hall', 117.2],
          ['Frontier Hall', 116.6],
          ['Ridder Arena & Tennis Facility', 114.2],
          ['17th Avenue Residence Hall', 110.3],
          ['Akerman Hall' 106.7],
          ['Coffman Memorial Union', 104.7],
          ['Child Development', 104.4],
          ['Rapson Hall', 102.9],
          ['Yudof Hall', 100.6],
          ['Civil Engineering Building', 99.9],
          ['Peik Hall', 99.6],
          ['Murphy Hall', 98.9],
          ['Mariucci Arena', 97.7],
          ['Campus Substation', 90.8],
          ['Northrop Memorial Auditorium', 90.5],
          ['Landcare & Facilities Operations', 89.9],
          ['Appleby Hall', 89.6],
          ['Vincent Hall', 89.1],
          ['TCF Bank Stadium', 88.3],
          ['Ford Hall', 87.2],
          ['Morrill Hall', 85.6],
          ['Jones Hall', 84.7],
          ['Peik Gymnasium', 83.9],
          ['Gibson/Nagurski Football Practice Facility', 83.9],
          ['Scott Hall', 82.7],
          ['1901 University Avenue SE', 79.6],
          ['Weisman Art Museum', 78.3],
          ['Williamson Hall', 77.1],
          ['Johnston Hall', 75.5],
          ['Education Sciences', 71.9],
          ['Roy Wilkins Hall', 70.4],
          ['Boathouse', 69.8],
          ['Fraser Hall', 68.4],
          ['Recreation Center Expansion', 66.8],
          ['Armory', 66.0],
          ['Shevlin Hall', 63.6],
          ['MN Geological Survey', 62.8],
          ['Bruininks Hall', 62.3],
          ['Folwell Hall', 60.8],
          ['Lind Hall', 60.4],
          ['University Office Plaza', 60.3],
          ['Williams Arena and Sports Pavilion', 59.6],
          ['Burton Hall', 59.3],
          ['McNamara Alumni Center', 59.1],
          ['10 Church Street Building', 57.0],
          ['Nicholson Hall', 55.0],
          ['Nolte Center', 50.5],
          ['Donhowe Building', 47.5],
          ['Pillsbury Hall', 44.6],
          ['Field House', 43.3],
          ['Wulling Hall', 35.0],
          ['1425 University Avenue SE', 29.3],
          ['Pioneer Hall', 28.8],
          ['Keeler Apartments', 17.7],
          ['University Avenue Parking Ramp', 11.3],
          ['Church Street Garage', 11.1],
          ['Washington Avenue Pedestrian Bridge', 9.1],
          ['Fourth Street Parking Ramp', 6.6],
          ['East River Parkway Garage', 5.9],
          ['Eddy Hall', 4.6],
          ['Oak Street Parking Ramp', 1.7],
          ['Washington Avenue Parking Ramp', 1.4]


it gets cut off at the half-way point, so the visualization is incomplete.

--
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-visualizati...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/5ca2c2eb-0708-4ec4-a256-db525b533f0e%40googlegroups.com.


--
Yves
Reply all
Reply to author
Forward
0 new messages