PDA

View Full Version : Query Chart axis



mbudm
18 Apr 2013, 4:21 PM
Hi there,

On an event listener I am changing the chart store data and want to update the chart axis titles as well.

Here's my axes config:


var axes = [
{
title:'Main axis title',
type:'Category',
position:'bottom',
fields:['size']
},
{
title:'Old axis title', /* changeable */
itemId:'streamPropertyAxis',
type:'Numeric',
position:'left',
fields:['streamProperty'],
minimum:0,
maximum:100,
minorTickSteps: 1
},
{
title:'Old axis title 2', /* changeable */
itemId:'minPropertyAxis',
type:'Numeric',
position:'right',
fields:['field2','field3']
}
]


In the event handler the following doesn't work ('this' scope is the panel that the chart is instantiated in):


this.down('#streamPropertyAxis').setTitle('new title')
this.down('#minPropertyAxis').setTitle('new title 2')


So I have had to use this alternative, which I'd prefer not too as it relies on a specifc array order:


this.down('chart').axes.items[1].setTitle('new title')
this.down('chart').axes.items[2].setTitle('new title 2')


Is there a reason why querying doesn't work? Surely the axes components are children of the panel that the chart is instantiated in?

slemmon
20 Apr 2013, 9:13 AM
Aside from making your own query for the axes what you've done may be as good as it gets. You can't do a query like down, up, or child on axes as they're not extended from Component. The ComponentQuery methods requires that the queried items be child Components of a parent Container.

mbudm
21 Apr 2013, 3:10 PM
Aside from making your own query for the axes what you've done may be as good as it gets. You can't do a query like down, up, or child on axes as they're not extended from Component. The ComponentQuery methods requires that the queried items be child Components of a parent Container.

Ah yes of course - the hierarchy:



HIERARCHY

Ext.Base
(http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.Base) Ext.chart.axis.Abstract
(http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.chart.axis.Abstract)Ext.chart.axis.Axis



I must admit I don't look at it too often as I just assume everything is a component, but I will remember to glance at it now.