How to pass local variable into high charts json text

Hi, 

I am using a line chart where I have to show dynamic values on the x-axis and y-axis for the tick intervals depending on the data retrieved. 

So, I'm writing high charts json text in the Advanced format property. 

It works when I hardcode any value like 

X-axis :{

step:2

}

But I don't have to hardcode it, it should be dynamically calculated value which I am storing in to local variable in preparation. 

Please help on this! 

Solution

Hi Shweta,


Are you doing this in XAxisJSON or the HighchartsJSON properties of the Chart Widget.

These are just regular Text attributes, so you can do any text manipulations that you like.  So you can concatenate literals with variables with the + sign.


So that would be something like 

" X-axis :{ 

    step: " + localvariable + " 

   } "


I must say, though,  I don't really recognise your example json as correct syntax for highcharts, but probably you just quickly put something in the post.  For starters, there's no hyphen between X and axis, and I don't see a step property for xAxis, just tickInterval and labels.step.


Hope this helps,

Dorine

Solution

Follow this example! I generate my data from data base. (PS.: This example it's a line chart with 3 lines, but is the same for 1 line.



It's to Reactive, but if you are working on Web Traditional, in your preparation, you will GETDATA (the data from first Image that I show you, and after you just need to do what I have into OnInitialize (next image)

NOTE: You never make a flow like that, I just edited it to fit the image.

If you only want one line you don't have to make the Appends, the data comes straight, if you have multiple lines you have one append for each line. Now I will show you what I have in each action / function.

Since I have a chart with three lines, I have this twice more.


Since I have a chart with three lines, I have this twice more.


This action has to go to the References, to the OutSystems Charts module.



What each variable is (Attention, these are structures since they come from the OutSystems Charts module)






I hope this information helps you.


Cheers

Dorine Boudry wrote:

Hi Shweta,


Are you doing this in XAxisJSON or the HighchartsJSON properties of the Chart Widget.

These are just regular Text attributes, so you can do any text manipulations that you like.  So you can concatenate literals with variables with the + sign.


So that would be something like 

" X-axis :{ 

    step: " + localvariable + " 

   } "


I must say, though,  I don't really recognise your example json as correct syntax for highcharts, but probably you just quickly put something in the post.  For starters, there's no hyphen between X and axis, and I don't see a step property for xAxis, just tickInterval and labels.step.


Hope this helps,

Dorine


Thanks Dorine,

 It solved my problem but it's only working after i provide values above 10 only for Y-axis tick interval. It shows intervals according to it if it is less than 10. 

It would be great if you can suggest something on this.

Hi Shweta,

can you share an oml of what you are doing, it's hard to know what's wrong from such a brief description.

maybe you are doing something different in your code if less than 10, are you sure it is the value you think it is ?


Dorine