I have a search page with two time input variables "From" and "To". Once the user searches between two timestamps, I have an aggregated table with filters that show the results of the table using the two input fields.
I would like to be able to display the results in a column chart using the the time input fields as the x axis. For example if the user inputs from 09:00 to 11:00, I would like the x axis in the chart to have a column chart for each hourly timestamp.
Any help would be great, thanks
Hello Yats,
When using Charts you can create a list to be used as source.
In this List you can set your Label, Series and Value for each item.
If I understood right what you want. What you have to do in this case is to format your chart's source list with your own logic in a way that instead of using just one point when the Label is, for example 09:00 to 11:00, you use 3 points:
One with Label 09:00, other with Label 10:00 and other with 11:00.
Let me know if you understood and if this helped.
Cheers and Regards,
RR :)
Thank you for your response Raphael Ranieri
From my understanding, you're saying initialise a list using listappend. I have added a new variable and added the input variable as the Element.
However when I go back to the chart and specify the label using the variable with the list, it doesn't display each timestamp.
Hello again Yats,
I will try to explain with more details.
Your chats will always receive a DataPoint Lis as Source. You can see here:
This DataPoint type is a structure from the charts Module, and will always have these attributes:
One of them as you can see is the Label one, and is a text, so you can put whatever you want, even a Time Stamp for example.
As long your Data series name is the same, all your records will display in the same axis.
I made a sample for you were I do a chart with 2 axis and time stamps as Labels, see here:
For it I just Appended All items from an Aggregate in a DataPoint List, formatting it the way I wanted.
See:
Note that I used ListAppenAll and not ListAppend as you showed in your print screen.
ListAppendAll will Append all elements from one List, to another, while ListAppend will append just one element. So to continue use ListAppend you would need a for each loop to append all items also.
Anyway, when I added all elements I mapped the Datetime attribute from my aggregate to the Label of my DataPointList which resulted on having the DateTimes as Labels in my screen as you can see!I attached the .oml for you also.
It is a reactive sample, but should work in the same way as a Traditional web app.
See if this helps, if you still have questions, feel free to ask again and we will try to give an even better explanation for your case.
Thank you for this but I think what I need it slightly different .
Using the same datasource I have two search inputs that filter the results between the two set times for example from 08:00 to 10:00 it displays all results within that timeframe. This works fine in displaying results in a table based on the two time inputs the user uses.
However in a chart, as the time values in between is not specified e.g 9:00 it is only showing the total results within the time inputs so 08:00 to 10:00. However I would like the chart to breakdown the results to show each hour as a separate column. I tried adding both input parameters in a list using your method above and it doesn't display as expected. I think I need a way to group the time before in aggregate possibly?
I hope that explains it better as to what i'm looking for.
Yats,
The idea I think will be not group the values, but to separate them.
For example, if now you have one point in your list with Value: 10 and Label: '08:00 to 10:00', you can try to run some logic to separate it and created instead of just one point, 3 points with the same value(Or maybe an Average to not show as a straight line).
So you will have a list with these elements:
Value: 10 and Label: '08:00'
Value: 10 and Label: '09:00'
Value: 10 and Label: '10:00'
Or if you have just 2 points:
and one is with label '09:00' is missing , you can create just it.
This logic to create the points you will have to implement when you apply your search.
Looping each element to see if there is a value for that time, like the '09:00' that you said it hasn't and create it manually.
If you create it and append to your Source List, it should show in the Chart.
Each point of the list will be a point in the chart. This is the reason you must create it manually. Because otherwise it will not appear.
If you tried this and did't work, is possible to share your .oml so I can try to see why it is not working?
Or if I didn't understand right, I'm sorry. In this case can you share some prints for me understand a little better?
Yes I think you've understood, I have attached .oml.
Thats the part i'm stuck on is adding the logic to separate the inputted values
Thanks again
Here you go Yats,I attached a .oml that will work as you expect.
I understood a little better your user case, you want the sum of values in each hour, and if it don't exist you want to show the label with value 0 is that right?
For example, if you put 08:00 to 10:00, since you don't have any value in DB for this time, it will show 3 points with value 0
If you put 00:00 to 23:00 it will show you all items and will create the hours that you don't have values as 0:
I changed a little bit your aggregate and create this logic that will add the points you don't have in your preparation.
Let me know if you have any question on how I did it or if this helped!
Thank you very much for helping, yes this is exactly it!
I was wondering if you could help with another issue i'm having with the same file.
I would like to click on one of the hourly values and it show a more filtered down graph of the results within that hour in a new page as single points rather than the sum. I have tried using DataPoint_GetClicked but it shows the Sum as the value and the hour as the label.
I am trying to show all the values within that time that is selected from the graph. I have attached an OML of my work so far.