AnsweredAssumed Answered

D3 chart not working properly

Question asked by Gerardo Garcia Lima on Feb 27, 2017
Latest reply on Mar 2, 2017 by Matt Marum

Hi everyone,

 

I'm using a D3 Chart to show some data and it looks good but when i try to hide one option it won't hide correctly

 

 

You can see how data shows correctly here, but if i want to remove one of the groups it will remove the correct color but the wrong label

 

In this example I wanted to delete "Cita de cierre" but the label deleted was "Contactado" even when the correct color was removed.

 

 

The dataset i'm using is this:

 

{
   "properties":{
      "title":"Total de prospectos consolidados: 3",
      "total":3,
      "scale":3,
      "units":"$"
   },
   "data":[
      {
         "key":"Cita de seguimiento",
         "count":"0",
         "values":[
            {
               "series":0,
               "label":"",
               "value":"0",
               "x":0,
               "y":0,
               "y0":0
            }
         ]
      },
      {
         "key":"Cita de entrega de póliza",
         "count":"1",
         "values":[
            {
               "series":1,
               "label":"",
               "value":"1",
               "x":0,
               "y":0,
               "y0":0
            }
         ]
      },
      {
         "key":"Ingreso de solicitud",
         "count":"0",
         "values":[
            {
               "series":2,
               "label":"",
               "value":"0",
               "x":0,
               "y":0,
               "y0":0
            }
         ]
      },
      {
         "key":"Cita de cierre",
         "count":"0",
         "values":[
            {
               "series":3,
               "label":"",
               "value":"0",
               "x":0,
               "y":0,
               "y0":0
            }
         ]
      },
      {
         "key":"Cita inicial",
         "count":"0",
         "values":[
            {
               "series":4,
               "label":"",
               "value":"0",
               "x":0,
               "y":0,
               "y0":0
            }
         ]
      },
      {
         "key":"Contactado",
         "count":"1",
         "values":[
            {
               "series":5,
               "label":"",
               "value":"1",
               "x":0,
               "y":0,
               "y0":0
            }
         ]
      },
      {
         "key":"Nuevo",
         "count":"1",
         "values":[
            {
               "series":6,
               "label":"",
               "value":"1",
               "x":0,
               "y":0,
               "y0":0
            }
         ]
      }
   ]
}

 

That data will get to the chart with this

 

renderChart: function () {
        if (!this.isChartReady()) {
            return;
        }
        this.$('svg#' + this.cid).children().remove();
        d3.select('svg#' + this.cid).datum(this.results).transition().duration(500).call(this.chart);
        this.chart_loaded = _.isFunction(this.chart.update);
        this.displayNoData(!this.chart_loaded);
    },

// this.results has all data.

 

Hope someone has an idea of what's happening here.

 

Thank you very mutch!

 

 

I'm using SugarCRM Enterprise, Versión 7.5.2.2 (Build 1014)

Outcomes