0

I would like to change the color of bar chart in extjs. I can changing the bar with renderer in series, but now I would like to change the legend's color too. Here is the piece of code:

           .. series : [ {
                type : 'bar',
                axis : 'bottom',
                gutter : 0,
                groupGutter : 0,
                yField : this.fields,
                title : this.fieldTitles,
                colorArrayStyle : ['#FFF']
                stacked : true,
                fill: true,
                scope: this,
                renderer: function(sprite, record, attr, index, store) {
                    var color = fieldColors[index];                    
                    attr.fill = color;
                    return attr;
               }, ....

How can I change the legend's color?

Vahe Akhsakhalyan
  • 2,140
  • 3
  • 24
  • 38

2 Answers2

0

You should be able to do it by overriding the getLedengColor method.

rixo
  • 23,815
  • 4
  • 63
  • 68
0

In your controller:

Get the chart

var chart = Ext.getCmp('yourchart');

then:

chart.series.items[0].colorArrayStyle = ['#97d856', '#4a96db', '#f05665', '#fe9f2f','#fec27b'];

After that you should need to redraw the chart like this:

chart.redraw();