Hi

I just made a Line chart. check the picture I've attached about displaying a line chart.

I've made:


Result: 

Please be patient xD, I am a beginner here.

If you explain more about the line chart and step to make it, I very appreciate it.

Thanks

Hi,

From what I gather, you want to display a count of occupied rooms, but there's a couple of things on your screenshots that don't look right:

 - you're using a manually calculated date counter and an If cycle when you could just do something like "Booking.CheckinDate <= AddDays(CurrDate(), 7)" and get all Bookings for the next 7 days;

 - you're building a DataPoint List with your occupancy percentage value, but then in the Chart widget on the screen, you're feeding your Query straight into the widget, and not using your DataPoint list. Try changing the SourceData property to use your list.

Afonso Carvalho wrote:

Hi,

From what I gather, you want to display a count of occupied rooms, but there's a couple of things on your screenshots that don't look right:

 - you're using a manually calculated date counter and an If cycle when you could just do something like "Booking.CheckinDate <= AddDays(CurrDate(), 7)" and get all Bookings for the next 7 days;

 - you're building a DataPoint List with your occupancy percentage value, but then in the Chart widget on the screen, you're feeding your Query straight into the widget, and not using your DataPoint list. Try changing the SourceData property to use your list.

Hello Alfanso, thanks for the reply.

Actually I still don't understand how to determine/fill line chart properties. Can u guide or any reference/documentation for fill line chart properties?

Thanks.


Your logic looks mostly right, it's just a matter of feeding the list that you created with your logic into the Charts widget SourceDataPointList property.

This video is a bit old now but it's still a good primer on the Charts components:

https://www.youtube.com/watch?v=AE7pbEcYIpA

Afonso Carvalho wrote:

Your logic looks mostly right, it's just a matter of feeding the list that you created with your logic into the Charts widget SourceDataPointList property.

This video is a bit old now but it's still a good primer on the Charts components:

https://www.youtube.com/watch?v=AE7pbEcYIpA

Sorry for late respond,

I saw the video that you shared, so we need SQL query in preparation for make line chart (?)

I made the change here :

Sorry for my little knowledge about outsystem.


You're feeding the widget correctly now, but what about the data? What do you see when you test the query?

Afonso Carvalho wrote:

You're feeding the widget correctly now, but what about the data? What do you see when you test the query?

Thanks for the fast reply,

here it is my test query :

It's not for the next 7 days, right?

Those should be occupied percentages, correct? They don't look accurate. Your query looks to be counting the bookings you have each day, but not the occupancy percentage. Instead of returning just the Count, you need to compare the booked rooms with the total of rooms, to know the percentage.

Something like this:

https://stackoverflow.com/questions/770579/how-to-calculate-percentage-with-a-sql-statement

Afonso Carvalho wrote:

Those should be occupied percentages, correct? They don't look accurate. Your query looks to be counting the bookings you have each day, but not the occupancy percentage. Instead of returning just the Count, you need to compare the booked rooms with the total of rooms, to know the percentage.

Something like this:

https://stackoverflow.com/questions/770579/how-to-calculate-percentage-with-a-sql-statement

Hi Alfonso, thanks for guiding me.

I get the logic for calculation like (all booking/100 * booking today) isn't it?

but I don't understand to calculate in the SQL statement, I tried to calculate with reference ur link but I get errors, can u guide me more?

Thanks

You can probably make this more efficient, but something like this:

SELECT (COUNT({Booking}.[CheckInDate]) * 100 / (/* SELECT THAT RETURNS YOUR TOTAL */))
FROM {Booking}
WHERE {Booking}.[CheckInDate] >= DATEADD(DAY, -7, GETDATE())
GROUP BY {Booking}.[CheckInDate]

Without knowing your data model, I'm not too sure on how to calculate occupancy - you need to find a way to obtain your total to divide with your current number of bookings.