Home Forums Chart Support Problem when re-rendering chart (negative scale) Reply To: Problem when re-rendering chart (negative scale)

#7481

OK so I have now made it like this, but the problem still exists that my ZERO point is shifted so the scale starts from a negative value all of a sudden! (see images in post 1).

This is my code now:


function reportRender(date_from, date_to) {
     var fetchURI = '?dateFrom=' + date_from + '&dateTo=' + date_to;

     $.getJSON("./reportdata.php" + fetchURI, function(reportdata) {
          var gdataByRegion = reportdata.by_region;
          var gdataByCertType = reportdata.alldata.certdata.certdata_totals;
          var regiondataCert = reportdata.alldata.certdata.certificates;

          var cTypeData = [];
          $.each(gdataByCertType, function (certType, certCount) {
               var certPercentage = Math.floor((parseInt(certCount) / parseInt(reportdata.staffcount_total)) * 100);

               cTypeData.push({
                    label: certType,
                    indexLabelFontColor: "black",
                    indexLabel: "{y} (" + certPercentage + "%)",
                    y: certCount
               });
          });

          var gdataByCertType = [{
                    type: "column",
                    dataPoints: cTypeData
          }]

// AS YOU CAN SEE I AM NOW JUST ADDING THE DATA HERE AS YOU SUGGESTED!
          chartByCertType.options.data = gdataByCertType;

// JUST DEBUG INFO TO SEE THAT DATA OBJECT IS POPULATED CORRECTLY (WHICH IT IS)
          console.log(chartByCertType);

          chartByCertType.render();
     });
}

So the question still remains: Why is the scale all of a sudden starting from negative values and not from ZERO as supposed to? It looks really weird.

A hint is that when I run the data first, this is how the data looks like for example:

Count A: 100
Count B: 200
Count C: 300

When I then filter on another date range the data might look like this:

Count A: 50
Count B: 20
Count C: 0

Count C will not be shown in the chart at all because it is a zero value. I think THIS is the problem, that as soon as a value is higher than zero first, it is all good, but when it goes to zero this bug appears.