Page 5 of 7

Re: [Module] Chart - Gadget

Posted: Thu Mar 05, 2020 11:48 am
by cyril
Thanks Thorsten1867

Your help is appreciated ;)

Re: [Module] Chart - Gadget

Posted: Sat Mar 07, 2020 11:14 am
by Thorsten1867
I took a look at the code and actually it should already work.
Have you ever tried this:

Code: Select all

Chart::SetAttribute(#Chart, Chart::#Decimals, 2)

Re: [Module] Chart - Gadget

Posted: Sat Mar 07, 2020 1:00 pm
by cyril
Yes, i used it in my ChartCreate code posted previously.

but I still get rounded value for the YAxis in my charts.

I'm using this test code, and the value are rounded too

Code: Select all

XIncludeFile "ChartModule.pbi"

Enumeration 
  #Window
  #Chart
EndEnumeration

If OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 400, 200, "Chart decimal test", #PB_Window_ScreenCentered)
        Chart::Gadget(#Chart, 10, 10, 295, 180, Chart::#ScatterPlot|Chart::#Border|Chart::#ToolTips|Chart::#AutoResize|Chart::#ShowLines, #Window)
        Chart::SetAttribute(#Chart, Chart::#MaximumY, 50)
        Chart::SetAttribute(#Chart, Chart::#MinimumY, 40)
        Chart::SetAttribute(#Chart, Chart::#MinimumX, Date(2019, 1, 1, 8, 0, 0))
        Chart::SetAttribute(#Chart, Chart::#MaximumX, Date(2019, 1, 1, 13, 0, 0))
       
        Chart::AddAxisLabel(#Chart,  "8:00", Date(2019, 1, 1,  8, 0, 0))
        Chart::AddAxisLabel(#Chart,  "9:00", Date(2019, 1, 1,  9, 0, 0))
        Chart::AddAxisLabel(#Chart, "10:00", Date(2019, 1, 1, 10, 0, 0))
        Chart::AddAxisLabel(#Chart, "11:00", Date(2019, 1, 1, 11, 0, 0))
        Chart::AddAxisLabel(#Chart, "12:00", Date(2019, 1, 1, 12, 0, 0))
        Chart::AddAxisLabel(#Chart, "13:00", Date(2019, 1, 1, 13, 0, 0))
        Chart::SetFlags(#Chart, Chart::#AxisX, Chart::#Time|Chart::#Labels)

        Chart::SetAttribute(#Chart, Chart::#Decimals, 2)
        Chart::ToolTipText(#Chart, Chart::#Scatter$ + ": " + Chart::#Value$)
        
        
        If Chart::AddScatterPlot(#Chart, "Scatter 1", $FF901E)
          Chart::AddScatterItem(#Chart, "Scatter 1", "08:30",  Date(2019, 1, 1,  8, 30, 0), 45.33)
          Chart::AddScatterItem(#Chart, "Scatter 1", "10:30",  Date(2019, 1, 1,  10, 30, 0), 46.55)
          Chart::AddScatterItem(#Chart, "Scatter 1", "11::30", Date(2019, 1, 1,  11, 30, 0), 46.27)
          Chart::AddScatterItem(#Chart, "Scatter 1", "12::30", Date(2019, 1, 1,  12, 30, 0), 46.77)
        EndIf
        Chart::DisplayScatterPlot(#Chart, "Scatter 1", #True)
        
        Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
The tooltip show rounded value too. And the chart seems to be using rounded value too.

Am I doing something wrong ?

Re: [Module] Chart - Gadget

Posted: Sat Mar 07, 2020 1:32 pm
by cyril
I've updated my test code to show the rounding more clearly ;)

Re: [Module] Chart - Gadget

Posted: Sat Mar 07, 2020 1:38 pm
by Thorsten1867

Code: Select all

Chart::SetAttribute(#Chart, Chart::#MaximumY, 48.5)

Re: [Module] Chart - Gadget

Posted: Sat Mar 07, 2020 2:04 pm
by Thorsten1867
Bugfixes

Re: [Module] Chart - Gadget

Posted: Sat Mar 07, 2020 3:08 pm
by cyril

Code: Select all

XIncludeFile "ChartModule.pbi"

Enumeration 
  #Window
  #Chart
EndEnumeration

If OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 400, 200, "Chart decimal test", #PB_Window_ScreenCentered)
        Chart::Gadget(#Chart, 10, 10, 295, 180, Chart::#ScatterPlot|Chart::#Border|Chart::#ToolTips|Chart::#AutoResize|Chart::#ShowLines, #Window)
        Chart::SetAttribute(#Chart, Chart::#MaximumY, 47)
        Chart::SetAttribute(#Chart, Chart::#MinimumY, 45)
        Chart::SetAttribute(#Chart, Chart::#MinimumX, Date(2019, 1, 1, 8, 0, 0))
        Chart::SetAttribute(#Chart, Chart::#MaximumX, Date(2019, 1, 1, 13, 0, 0))
       
        Chart::AddAxisLabel(#Chart,  "8:00", Date(2019, 1, 1,  8, 0, 0))
        Chart::AddAxisLabel(#Chart,  "9:00", Date(2019, 1, 1,  9, 0, 0))
        Chart::AddAxisLabel(#Chart, "10:00", Date(2019, 1, 1, 10, 0, 0))
        Chart::AddAxisLabel(#Chart, "11:00", Date(2019, 1, 1, 11, 0, 0))
        Chart::AddAxisLabel(#Chart, "12:00", Date(2019, 1, 1, 12, 0, 0))
        Chart::AddAxisLabel(#Chart, "13:00", Date(2019, 1, 1, 13, 0, 0))
        Chart::SetFlags(#Chart, Chart::#AxisX, Chart::#Time|Chart::#Labels)

        Chart::SetAttribute(#Chart, Chart::#Decimals, 2)
        Chart::ToolTipText(#Chart, Chart::#Scatter$ + ": " + Chart::#Value$)
        
        
        If Chart::AddScatterPlot(#Chart, "Scatter 1", $FF901E)
          Chart::AddScatterItem(#Chart, "Scatter 1", "08:30",  Date(2019, 1, 1,  8, 30, 0), 45.33)
          Chart::AddScatterItem(#Chart, "Scatter 1", "10:30",  Date(2019, 1, 1,  10, 30, 0), 46.55)
          Chart::AddScatterItem(#Chart, "Scatter 1", "11::30", Date(2019, 1, 1,  11, 30, 0), 46.27)
          Chart::AddScatterItem(#Chart, "Scatter 1", "12::30", Date(2019, 1, 1,  12, 30, 0), 46.77)
        EndIf
        Chart::DisplayScatterPlot(#Chart, "Scatter 1", #True)
        
        Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Re: [Module] Chart - Gadget

Posted: Sat Mar 07, 2020 3:17 pm
by cyril
Here is an image showing the rounding of value.
Image

Re: [Module] Chart - Gadget

Posted: Sun Mar 08, 2020 9:58 am
by Thorsten1867
Update: Floats for item data

Re: [Module] Chart - Gadget

Posted: Sun Mar 08, 2020 1:31 pm
by cyril
Thanks for the update Thorsten1867.

I finally got it working :)

Re: [Module] Chart - Gadget

Posted: Sun Mar 15, 2020 7:39 pm
by cyril
Hello Thorsten

I'm having a problem with tooltips using a scatterplot graph.

I'm using:

Code: Select all

Chart::ToolTipText(#Gadget_Chart, Chart::#Scatter$ + ": " + Chart::#Time$ + " - " + Chart::#DataY$ + " pounds")
But the tooltip is still something like: "128.888888888" instead of "Weight: 01/03/2020 - 128.89 pounds".

I also tried with

Code: Select all

Chart::ToolTipText(#Gadget_Chart, Chart::#Scatter$ + ": " + Chart::#Time$ + " - " + Chart::#Value$ + " pounds")
The complete initialization code i'm using is:

Code: Select all

Chart::Gadget(#Gadget_Chart, x, y, width, height, Chart::#ScatterPlot|Chart::#Border|Chart::#ShowLines|Chart::#ToolTips|Chart::#AutoResize, #Window_Main)
Chart::SetFlags(#Gadget_Chart, Chart::#AxisX, Chart::#Time|Chart::#Labels)
Chart::SetAttribute(#Gadget_Chart, Chart::#Decimals, 2)
Chart::SetMask(#Gadget_Chart, Chart::#AxisX, "%dd/%mm/%yyyy")
Chart::ToolTipText(#Gadget_Chart, Chart::#Scatter$ + ": " + Chart::#Time$ + " - " + Chart::#DataY$ + " pounds")
What am I doing wrong ?

Re: [Module] Chart - Gadget

Posted: Fri Mar 20, 2020 2:39 pm
by cyril
Here is a sample code that shows the problem:

Code: Select all

XIncludeFile "ChartModule.pbi"

Enumeration
  #Window
  #Chart
EndEnumeration

If OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 400, 200, "Chart decimal test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
        Chart::Gadget(#Chart, 10, 10, 380, 180, Chart::#ScatterPlot|Chart::#Border|Chart::#ToolTips|Chart::#AutoResize|Chart::#ShowLines, #Window)
        Chart::SetAttribute(#Chart, Chart::#MaximumY, 47)
        Chart::SetAttribute(#Chart, Chart::#MinimumY, 45)
        Chart::SetAttribute(#Chart, Chart::#MinimumX, Date(2019, 1, 1, 8, 0, 0))
        Chart::SetAttribute(#Chart, Chart::#MaximumX, Date(2019, 1, 1, 13, 0, 0))
       
        Chart::AddAxisLabel(#Chart,  "8:00", Date(2019, 1, 1,  8, 0, 0))
        Chart::AddAxisLabel(#Chart,  "9:00", Date(2019, 1, 1,  9, 0, 0))
        Chart::AddAxisLabel(#Chart, "10:00", Date(2019, 1, 1, 10, 0, 0))
        Chart::AddAxisLabel(#Chart, "11:00", Date(2019, 1, 1, 11, 0, 0))
        Chart::AddAxisLabel(#Chart, "12:00", Date(2019, 1, 1, 12, 0, 0))
        Chart::AddAxisLabel(#Chart, "13:00", Date(2019, 1, 1, 13, 0, 0))
        Chart::SetFlags(#Chart, Chart::#AxisX, Chart::#Time|Chart::#Labels)

        Chart::SetAttribute(#Chart, Chart::#Decimals, 2)
        Chart::ToolTipText(#Chart, Chart::#Scatter$ + ": " + Chart::#Time$ + " - " + Chart::#Value$ + " pounds")
       
       
        If Chart::AddScatterPlot(#Chart, "Scatter 1", $FF901E)
          Chart::AddScatterItem(#Chart, "Scatter 1", "08:30",  Date(2019, 1, 1,  8, 30, 0), 45.33)
          Chart::AddScatterItem(#Chart, "Scatter 1", "10:30",  Date(2019, 1, 1,  10, 30, 0), 46.55)
          Chart::AddScatterItem(#Chart, "Scatter 1", "11::30", Date(2019, 1, 1,  11, 30, 0), 46.27)
          Chart::AddScatterItem(#Chart, "Scatter 1", "12::30", Date(2019, 1, 1,  12, 30, 0), 46.77)
        EndIf
        Chart::DisplayScatterPlot(#Chart, "Scatter 1", #True)
       
        Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
When hovering over a point, only the value is displayed (with no rounding) instead of what was specified using Chart::ToolTipText.

Re: [Module] Chart - Gadget

Posted: Fri Mar 20, 2020 6:52 pm
by Thorsten1867
Bugfixes

Re: [Module] Chart - Gadget

Posted: Fri Mar 20, 2020 7:13 pm
by cyril
Thank you Thorsten :)

It's working great !

Re: [Module] Chart - Gadget

Posted: Sat Mar 21, 2020 4:26 pm
by Lord
Hi!

Sometimes it would be desirable if the x-axis labels were arranged vertically,
especially for longer texts.
Is this possible with the chart gadget?

Example:
Image