cancel
Showing results for 
Search instead for 
Did you mean: 

Color change in BAR Chart according to condition

Former Member
0 Kudos

Hi all,

I need help in BAR chart as my confusion is i am creating a BAR chart for material and its one of property suppose i have 5 material and porperty value,

than i want to use some condition on value and assign color to each bar representing different material value . itz possible to assign dynamically values to BAR chart .

Thanks in Advance

Regards,

Praveen

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Praveen

Try this code it may help you . i have 3 colors which are pre defined in display template (pen's 30,31,32).i trying to set colors for bars based on the value

var rows=document.flowGrid.getGridObject().getRowCount();

for(r=1;r<=rows;r++)

{

a[r]=document.Chart.getChartObject().getYDataValueAt(r,1);

if(a[r]<95)

{

if(a[r]<=84)

{

b[r]=32;

PColor1[r]=document.Chart.getChartObject().getPenColor(b[r]);

}

if(a[r]>=85)

{

b[r]=30;

PColor1[r]=document.Chart.getChartObject().getPenColor(b[r]);

}

}

else

{

b[r]=31;

PColor1[r]=document.Chart.getChartObject().getPenColor(b[r]);

}

}

for(m=1;m<=rows;m++)

{

document.Chart.getChartObject().setPenColor(m,PColor1[m]);

}

document.stageWiseChart.refresh();

Former Member
0 Kudos

Hi Praveen,

I've been playing around with your scenario. If you are using the Chart Action in the Logic Editor, I found that you could change the color of one of the bars, based on a value, like this:

- Use a Query action to load your Query Template

- Add a Chart Action, but leave the Query Template blank in the Configuration screen. Use the Link Editor for that action instead to link the name of the Query Template from the Query Action block above. Choose the ChartType parameter as "Bar".

- In the Link Editor for the Chart Action, use the the stringif function to change the PenColor based on a value. For example, this links to PenColor.1 in the Chart Action:

stringif(IllumTagQuery_0.Results/Rowsets/Rowset/Row/AssetUtil1} > 95, "#0000FF", "#0EECC0") to IllumChart_0.PenColor.1

I don't know if this is what you are looking for, but I thought it worth considering.

Kind Regards,

Diana Hoppe

0 Kudos

Praveen,

Take a look at the help docs about setting pen colors.

Sam

Former Member
0 Kudos

Hi sam ,

i have to assign color to pen dynamically not in the display template or in more detail if i say i am using chart action in transaction and i have to assign color in chart action according to data i have .

regards,

praveen

Former Member
0 Kudos

To change a pen colour dynamically, you can use the following javascript

document.myGraph.getChartObject().setPenColor(INDEX,NEWVALUE);

Although this will change it for a whole series, not just one data point.

Former Member
0 Kudos

Hi Nick,

thanks for your reply but i have to change it for only one data( according to condition ) only not for whole chart .

regards

Praveen