View Full Version : Set chart axes title on create?

9 Feb 2012, 8:45 AM
I'm trying to just set my chart's axes once I initialize it via xtype in a window. The problem is, I want to have 2 of the same charts, but with different stores and different titles. I got the stores to work properly via a constructor setup but for whatever reason when I try and set the title the same way I do the stores it overrides the title for BOTH charts to whatever the LAST chart was set at. Is there a reason for this? My typical xtype call in my window would be:

items: [{
xtype: 'myChart',
axesTitle: 'Test1'
}, {
xtype: 'myChart',
axesTitle: 'Test2'
And I've tried in both my constructor and initComponent (just in case) to see if they would work and they both produce the same results. My code to set the title is simple enough for now:

if(this.axesTitle) {
this.axes[0].title = this.axesTitle;

I just end up with both my charts having a legend title of 'Test2' instead of 'Test1' and 'Test2'. What am I doing wrong?

9 Feb 2012, 9:34 AM
There should be a setTitle method on the axis

9 Feb 2012, 9:41 AM
Ah you'd think that (and I tried that too) but for me in both initComponent and constructor the axes are still both in their 'raw' pre-executed form. So all that is in this.axes[0] is the configuration items I passed to it.

9 Feb 2012, 10:00 AM
Ok so I've tried a few more things, and if I put a listener on the chart under initComponent, it only fires once even though I am creating the xtype twice. Am I doing something wrong here? It feels like its something simple I'm missing but I am just not seeing it.

9 Feb 2012, 10:24 AM
I've also tried abstracting out the event to my controller so the controller is listening to the charts afterrender/show/add/whatever and I'm still only getting the configuration of the object and not the object itself to call .setTitle(); I'm obviously doing something wrong but can't for the life of me tell what it is.

9 Feb 2012, 10:57 AM
Well. To make it work properly I had to move my logic to the controller, listen for the 'move' event ('Why?' might you ask? I'll tell you, no other event had a fully initialized object that I could call setTitle on) and then run setTitle. It works but I don't know why. I don't know if it matters that I stuck my charts in a tabset and had them in a second tab so possibly no other even would be fired (but why wouldn't the show even be fired at least? I don't know). So... in case anybody was wondering, that's how you can do it...