PDA

View Full Version : Can I create gradients object dynamicly?



mgtneven
28 Dec 2011, 3:22 AM
Hi,

I'm a new daveloper in extjs framework, I need to use gradients in mt chart, but don't want to write them hard-coded, like this:

gradients: [
{
'id': 'v-1',
'angle': 0,
stops: {
0: {
color:'#8855BB'
},
50:{
color:'#875cFB'
},
100: {
color:'#8154cB'
}
}
}]

but I want to create it as a new array of objects, something like this:

var gradients=new Array();
gradients[0]=new object(?) {
'id': 'v-1',
'angle': 0,
stops: {
0: {
color:'#8855BB'
},
50:{
color:'#875cFB'
},
100: {
color:'#8154cB'
}
}
}

Can someone explain me how can I do such thing?

Many thanks.

jay@moduscreate.com
28 Dec 2011, 6:43 AM
Your syntax is wrong:


var gradients=new Array();
gradients[0]= {
'id': 'v-1',
'angle': 0,
stops: {
0: {
color:'#8855BB'
},
50:{
color:'#875cFB'
},
100: {
color:'#8154cB'
}
}
}

mgtneven
28 Dec 2011, 6:53 AM
Yes I know it's wrong... but I wanted to explain my needs.

Is there any way to do it, like this?

Thanks.

mgtneven
9 Jan 2012, 11:26 PM
I use the way of:
Ext.Object.fromQueryString(...)
to create my gradients array dynamically,

but it seems to be too much long and awkward...

It there any other way to create an array of gradients by constructor or any other way?

Many thanks.