It is currently Thu Jul 18, 2019 2:48 pm

All times are UTC + 1 hour




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

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 809
Location: Germany
Bar Chart Gadget - Module (all OS / 64Bit / DPI)

Creating pie, bar charts (vertical/horizontal) 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 - Commands _____

; 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::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 label of the data series after the event
; 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() - sets the value of the item by label

;}

Download: ChartModule.pbi

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules (GitHub)

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


Last edited by Thorsten1867 on Tue Jun 18, 2019 3:06 pm, edited 5 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: 445
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: 582
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

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

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

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules (GitHub)

[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

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

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules (GitHub)

[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

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

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules (GitHub)

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


Last edited by Thorsten1867 on Sun Jun 16, 2019 6:22 pm, edited 3 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: 582
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

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

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules (GitHub)

[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: 582
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: 1033
Location: Germany::Berlin()
Very nice, thank you! Good job!

_________________
ImageImageImageImageImage


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

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

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

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules (GitHub)

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


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: 1692
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

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

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules (GitHub)

[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: 690
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

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

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules (GitHub)

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


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 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:  

 


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