It is currently Thu May 28, 2020 12:59 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 90 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: [Module] Chart - Gadget
PostPosted: Tue Jun 11, 2019 7:20 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1262
Location: Germany
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:
; 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

_________________
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 10 x64] [PB V5.7x]


Last edited by Thorsten1867 on Fri Dec 20, 2019 3:12 pm, edited 10 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Bar Chart - Gadget
PostPosted: Wed Jun 12, 2019 8:22 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon May 09, 2011 9:36 am
Posts: 500
Thorsten1867 , thank you very much, your Bar Chart Gadget Module looks and works great ! :D

_________________
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Bar Chart - Gadget
PostPosted: Wed Jun 12, 2019 11:45 am 
Offline
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 644
Hi!

Quote:
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:
      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:
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?

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Bar Chart - Gadget
PostPosted: Wed Jun 12, 2019 12:16 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1262
Location: Germany
I just tried it again and it worked.

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

_________________
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 10 x64] [PB V5.7x]


Last edited by Thorsten1867 on Wed Jun 12, 2019 1:12 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Bar Chart - Gadget
PostPosted: Wed Jun 12, 2019 1:11 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1262
Location: Germany
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.

_________________
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 10 x64] [PB V5.7x]


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Bar Chart - Gadget
PostPosted: Wed Jun 12, 2019 4:49 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1262
Location: Germany
Update:
  • Added: Support of negative values
  • Added: Attribute '#ScaleSpacing' (#Single/#Double) for the automatic calculation of the number of scale lines
Image

_________________
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 10 x64] [PB V5.7x]


Last edited by Thorsten1867 on Fri Dec 20, 2019 3:14 pm, edited 4 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Bar Chart - Gadget
PostPosted: Wed Jun 12, 2019 6:24 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 644
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.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Bar Chart - Gadget
PostPosted: Wed Jun 12, 2019 6:57 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1262
Location: Germany
The new version should avoid this problem.

_________________
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 10 x64] [PB V5.7x]


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Bar Chart - Gadget
PostPosted: Wed Jun 12, 2019 7:17 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 644
Thorsten1867 wrote:
The new version should avoid this problem.
Now it seems to work properly.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Bar Chart - Gadget
PostPosted: Wed Jun 12, 2019 8:03 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1110
Location: Gernsbach (Germany)
Very nice, thank you! Good job!

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Bar Chart - Gadget
PostPosted: Sun Jun 16, 2019 6:27 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1262
Location: Germany
Update:
  • Hinzugefügt: Pie Charts
Image

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

_________________
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 10 x64] [PB V5.7x]


Last edited by Thorsten1867 on Fri Dec 20, 2019 3:15 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Chart - Gadget
PostPosted: Sun Jun 16, 2019 10:11 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 6:14 pm
Posts: 1825
Location: Germany (Saxony, Deutscheinsiedel)
Well done, thank you! :D

_________________
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Chart - Gadget
PostPosted: Tue Jun 18, 2019 10:45 am 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1262
Location: Germany
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

_________________
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 10 x64] [PB V5.7x]


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Chart - Gadget
PostPosted: Tue Jun 18, 2019 11:46 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 25, 2004 2:15 pm
Posts: 721
Location: Spain
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!

_________________
PB 5.7x, PureVision User.


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] Chart - Gadget
PostPosted: Tue Jun 18, 2019 12:26 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1262
Location: Germany
A chart with horizontal bars and a line chart are planned.

_________________
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 10 x64] [PB V5.7x]


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 90 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye