Page 1 of 7

[Module] Chart - Gadget

Posted: Tue Jun 11, 2019 7:20 pm
by Thorsten1867
Bar Chart Gadget - Module (all OS / 64Bit / DPI)

Creating pie, bar charts (vertical/horizontal), scatter plot and charts with data series:
  • automatic calculation of bar width (#PB_Default) and distance (#PB_Default) possible
  • automatic adjustment of maximum value (#PB_Default) possible
  • display of horizontal lines (Y-axis) possible
  • display of values, percentages or text in (or above) bar possible
  • support of left, right or double-click events for bars
  • automatic gadget size adjustments
Image

Code: Select all

; Chart::AddItem()             - similar to AddGadgetItem()
; Chart::AttachPopupMenu()     - attachs a popup menu to the chart
; Chart::DisableReDraw()       - disable/enable redrawing
; Chart::EventColor()          - returns the color after the event
; Chart::EventIndex()          - returns the item index after the event
; Chart::EventLabel()          - returns the item label after the event
; Chart::EventValue()          - returns the item value after the event
; Chart::Gadget()              - create a new gadget
; Chart::GetErrorMessage()     - get error message [DE/FR/ES/UK]
; Chart::GetItemColor()        - returns the color of the item
; Chart::GetItemLabel()        - get the label of the item
; Chart::GetItemState()        - similar to GetGadgetItemState()
; Chart::GetItemText()         - similar to GetGadgetItemText()
; Chart::GetLabelState()       - similar to GetGadgetItemState(), but 'label' instead of 'position'
; Chart::GetLabelColor()       - returns the color of the item
; Chart::RemoveItem()          - similar to RemoveGadgetItem()
; Chart::RemoveLabel()         - similar to RemoveGadgetItem(), but 'label' instead of 'position'
; Chart::SetAttribute()        - similar to SetGadgetAttribute()
; Chart::SetAutoResizeFlags()  - [#MoveX|#MoveY|#ResizeWidth|#ResizeHeight]
; Chart::SetColor()            - similar to SetGadgetColor()
; Chart::SetFlags()            - set flags for chart customization
; Chart::SetFont()             - similar to SetGadgetFont()
; Chart::SetItemState()        - similar to SetGadgetItemState()
; Chart::SetItemText()         - similar to SetGadgetItemText()
; Chart::SetLabelState()       - similar to SetGadgetItemState(), but 'label' instead of 'position'
; Chart::SetMargins()          - define top, left, right and bottom margin
; Chart::ToolTipText()         - defines the text for tooltips (#Percent$ / #Value$ / #Label$ / #Serie$)
; Chart::UpdatePopupText()     - updates the menu item text before the popup menu is displayed

; --- Data Series ---

; Chart::AddDataSeries()       - add a new data series
; Chart::AddSeriesItem()       - add a new item to the data series
; Chart::DisplayDataSeries()   - displays the data series
; Chart::EventDataSeries()     - returns the value of the item by index
; Chart::GetSeriesColor()      - returns the color of the data series
; Chart::GetSeriesItemState()  - returns the value of the item by index
; Chart::GetSeriesLabelState() - returns the value of the item by label
; Chart::RemoveSeriesItem()    - removes the item by index
; Chart::RemoveSeriesLabel()   - removes the item by label
; Chart::RemoveDataSeries()    - removes the data series
; Chart::SetSeriesItemState()  - sets the value of the item by index
; Chart::SetSeriesLabelState() 

; --- Scatter Plot ---

; Chart::AddScatterPlot()       - add a new scatter plot
; Chart::AddScatterItem()       - add a new item to the scatter plot
; Chart::DisplayScatterPlot()   - displays the scatter plot
; Chart::EventScatterPlot()     - returns the label of the scatter plot after the event
; Chart::EventDataX()           - returns dataX after the event 
; Chart::EventDataY()           - returns dataY after the event 
; Chart::GetScatterColor()      - returns the color of the scatter plot
; Chart::GetScatterItem()       - returns the value of the item by index [#DataX/#DataY]
; Chart::GetScatterLabelData()  - returns the value of the item by label [#DataX/#DataY]
; Chart::RemoveScatterPlot()    - removes the item by index
; Chart::RemoveScatterItem()    - removes the item by label
; Chart::RemoveScatterLabel()   - removes the data series
; Chart::SetScatterItem()       - sets the values of the item by index
; Chart::SetScatterLabelData()  - sets the values of the item by label
Download: ChartModule.pbi

Re: [Module] Bar Chart - Gadget

Posted: Wed Jun 12, 2019 8:22 am
by VB6_to_PBx
Thorsten1867 , thank you very much, your Bar Chart Gadget Module looks and works great ! :D

Re: [Module] Bar Chart - Gadget

Posted: Wed Jun 12, 2019 11:45 am
by Lord
Hi!
automatic adjustment of maximum value (#PB_Default) possible
A "#PB_default" in "Chart::Gadget(") at "Maximum" doesn't show the first bar, when
a value of 135 is set for "Value" in "Chart::AddItem()".
Tried this with changing the values for the Gadget in your "CompilerDefault" part:

Code: Select all

      CompilerDefault
        Chart::Gadget(#Chart, 10, 10, 280, 180, 0, #PB_Default, Chart::#Border|Chart::#ShowLines|Chart::#ColoredLabels|Chart::#ShowValue|Chart::#AutoResize, #Window)
        Chart::SetAttribute(#Chart, Chart::#ScaleLines, 5)
and

Code: Select all

Chart::AddItem(#Chart, "Bar 1", 135, $FF901E):Debug chart::GetErrorMessage(#chart)
The error message is "Value greater than maximum" and the bar just disappears.
Isn't "#PB_default" meant to adjust the graph according to the maximum value?

Re: [Module] Bar Chart - Gadget

Posted: Wed Jun 12, 2019 12:16 pm
by Thorsten1867
I just tried it again and it worked.

(Do you have the latest version? Is "#Example = 0" set?)

Re: [Module] Bar Chart - Gadget

Posted: Wed Jun 12, 2019 1:11 pm
by Thorsten1867
Update:
  • Added: Attribute '#AdjustMaximum' (#True/#False) to adjust the maximum value, if necessary. (= Default)
If you use 'Chart::SetAttribute(#Chart, Chart::#AdjustMaximum, #False)', then only a percentage is displayed instead of the bar.

Re: [Module] Bar Chart - Gadget

Posted: Wed Jun 12, 2019 4:49 pm
by Thorsten1867
Update:
  • Added: Support of negative values
  • Added: Attribute '#ScaleSpacing' (#Single/#Double) for the automatic calculation of the number of scale lines
Image

Re: [Module] Bar Chart - Gadget

Posted: Wed Jun 12, 2019 6:24 pm
by Lord
Thorsten1867 wrote:...
(Do you have the latest version? Is "#Example = 0" set?)
I downloaded the modul just before I tried.
As CompilerDefault defaults to anything but not 1 to 6, a 0 was set for #Example.

Re: [Module] Bar Chart - Gadget

Posted: Wed Jun 12, 2019 6:57 pm
by Thorsten1867
The new version should avoid this problem.

Re: [Module] Bar Chart - Gadget

Posted: Wed Jun 12, 2019 7:17 pm
by Lord
Thorsten1867 wrote:The new version should avoid this problem.
Now it seems to work properly.

Re: [Module] Bar Chart - Gadget

Posted: Wed Jun 12, 2019 8:03 pm
by RSBasic
Very nice, thank you! Good job!

Re: [Module] Bar Chart - Gadget

Posted: Sun Jun 16, 2019 6:27 pm
by Thorsten1867
Update:
  • HinzugefĆ¼gt: Pie Charts
Image

( Finding out whether the mouse clicked in a circle sector was a real mathematical challenge. 8) )

Re: [Module] Chart - Gadget

Posted: Sun Jun 16, 2019 10:11 pm
by Andre
Well done, thank you! :D

Re: [Module] Chart - Gadget

Posted: Tue Jun 18, 2019 10:45 am
by Thorsten1867
Update:
  • Diagram added for data series
  • Support for popup menus (Chart & Legend) with automatic update of menu item texts (e.g. #Label$ / #Series$)
  • Simplified supply of event data
  • SetAttribute() is partially replaced by SetFlags().
Image

Re: [Module] Chart - Gadget

Posted: Tue Jun 18, 2019 11:46 am
by zikitrake
Wow :shock: Another impressive module.
Do you plan to add linear charts to it?
I was thinking about using the fantastic @uwekel code: viewtopic.php?f=14&t=59038,
but yours, as it also has Pie charts, would be more useful to me.

Thanks!

Re: [Module] Chart - Gadget

Posted: Tue Jun 18, 2019 12:26 pm
by Thorsten1867
A chart with horizontal bars and a line chart are planned.