Search code examples
amcharts

AmCharts hide/ remove categoryField


https://snag.gy/9etSHc.jpg ----- this is the image link with what i need to remove.

const chart = this.AmCharts.makeChart( 'chartavaliacao' + id + idf,
{
  'type': 'serial',
  'theme': 'light',
  'rotate': true,
  'colors': colorScheme,
  'dataProvider': this.dados,
  'graphs': this.grafico,
  'marginTop': 10,
  'marginLeft': 15,
  'marginBottom': 0,
  'addClassNames': true,

  'valueAxes':[{
    'unit': '%',
    'maximum': 100,
    'minimum': 0,
  }],
  'categoryField': 'categoria',    <<<<<<<<<<<<<<<<<< i need to remove this field from my graph
  'titles': [
    {
      'id': 'Title-1',
      'size': 15,
      'text': this.grouped ? this.titulo : ''
    }
  ],
  'listeners': [{
    'event': 'drawn',
    'method':  modifyAxis
  }, {
    'event': 'clickGraphItem',
    'method':  redireciona
  }]
}, 10);
}

I need to remove from my graph 'categoryField' but if i comment this show UNDEFINED. I tryed to put false and e got the same result.

someone can help with this question?


Solution

  • Not knowing what your modifyAxis code does, the safest possible way I can think of that will likely not interfere with it is to use a labelFunction that returns an empty string or single space:

    AmCharts.makeChart(..., {
      // ...
      categoryAxis: {
        labelFunction: function() {
          return " ";
        },
        // ...
      }
      // ...
    }