cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Axis Min/Max on Charts

Former Member
0 Kudos

Hi all,

I have a requirement to display 3 different metrics on a chart, with each metric having a different minimum value on the y-axis. The user will select the metric they want to see and the chart will display that metric. The problem is two metrics are percents and the other is in dollars. I want to use the same chart for all 3 metrics to reduce the file size and computing necessary to have 3 chart components. I know in Xcelsius we could dynamically change min/max values. In Design Studio I don't see a scripting option to dynamically change the min/max values, but is there a workaround anyone has figured out? If not, does anyone know when this functionality might be available?

Thanks,

John Cintolo

Accepted Solutions (1)

Accepted Solutions (1)

Karol-K
Advisor
Advisor
0 Kudos

Hello John,

On design time you can make it in Additional Properties. You need to scroll down and search for the scaling, dependent on chart type you will find it one or two times.

On run time you can use scripting:

CHART_1.setAxisScaling(chartAxisScaling, minValue, maxValue)

The scripting is avaiolable in release 1.3 SP1 for sure, so if you do not see it perhaps you have older release.

Regards, Karol

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi John,

When you change the Data selection, the Chart should automatically take up proper scaling. But if you still want both auto and Manual you can do this with a if condition. for eg:

if(chart is showing Percent measure)

{

{

CHART_1.setAxisScaling(chartAxisScaling.Y_AXIS, 0, 100);

}

else

{

CHART_11.removeAxisScaling(ChartAxisScaling.Y_AXIS);

}

}

This way you can leverage both auto and Manual Axis scaling

Regards,

Fazith Ali Z.

Arjun_KT
Participant
0 Kudos

Hello Sheik,

Is there any way to find the Max value dynamically ie; @ run time?

Best Regards

Arjun KT

Former Member
0 Kudos

Hi Arjun,

I am not sure there is any direct way,

If you have an assumption of which Dimension will have the Highest Value, you can get that data using getDataAsString Function and then assign your max value for axes based on that.

Regards,

Fazith Ali Z

Arjun_KT
Participant
0 Kudos

Hello Sheik,

Thank you for the reply .

Yes if we know the max value then we can set it.but when we filter that data source then the value will be changing and we need to find that on the fly.

Am trying to find a solution for that.

Thanks & Regards

Arjun KT

Former Member
0 Kudos

Hi Arjun

Like I asked is there a possibility that one value is always maximum,

i.e. Let's say you have three countries, US CANADA & MEXICO, if you know that US will always have the highest value, you can take that into account for the Max value.

If that is not the case, then you have to take all the three values and then check if they are working, luckily you have foreach function now which you can use.

But the Chart scales automatically is there any particualar reason you want to set it manually?

Regards,

Fazith Ali Z.

Arjun_KT
Participant
0 Kudos

Hello Sheik,

Thank You for the reply, I can not determine which is the Max value with out loading data. So I used for each function and found the Max value .

When the chart scales automatically the values in Y-axis is repeating many times. Like below

So in order to set Max value in the setAxisScaling , I need to find the Max value on the fly and this chart will under go filtering as well from a Dimension filter.

But now  I have a formula to find the Max value using Foreach Function , which is using in the initial load.

DS_1.sortByMeasure("vehicle_count",false);

var v1 = DS_1.getMembers("State", 100);

var i = 0;

var e = "";

var v2 =0;

var v3= 0;

v1.forEach(function(element, index) {

  e = element.text;

  v3= Convert.stringToInt( DS_1.getDataAsString("vehicle_count",{"State": e}));

if (i == index) {

v2= Convert.stringToInt( DS_1.getDataAsString("vehicle_count",{"State": e}));

}

else {

  if(v2<v3){v2=v3;}

  }

});


TEXT_1.setText("maxn"+v2);

Hope this is one of way to find Max value via scripting .

Regards

Arjun KT

Former Member
0 Kudos

Dear Arjun,

I think you found the right way to solve this problem which I have as well.

I try to reproduce your steps.

Could you give me more details about this?

Did you really solve the problem?

Where did you define this script? In a global variable?

Any information is very appreciated.

The initial question from John Cintolo was answered.

Shall I create a new discussion?

Regards,

Deniz

0 Kudos

Hello Deniz,

in DS 1.6SP2 you can use the following coding:

If your chart item has the name CH_1:

var xyz = CH1.getAxisScalingMin(ChartAxisScaling.Y_AXIS);

try this code anywhere in you application where you can access an event (for example in a button).

hope this helps.

Kind regards Thomas