Realtime Bar Chart

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
nblackburn
User
User
Posts: 67
Joined: Mon Aug 19, 2013 1:22 am
Location: United Kingdom
Contact:

Realtime Bar Chart

Post by nblackburn »

Fellow people of the internet,

As some of you may know, i bought PureBasic some time ago but never really have done much with it so i wanted to make something this weekend to give back to the community.

Using the awesome vector library available in the latest update to PureBasic, i have created a realtime bar chart which can be used within your applications. The code has been licensed under MIT so if you find it useful, please feel free to include it in your own projects or share any improvements with everyone.
Problems
  • Needs more functionality
  • Needs refactoring
Disclaimer: This is my first serious attempt so it's far from perfect and should be treat as a proof of concept as the code could be improved in areas.
Last edited by nblackburn on Sun Sep 06, 2015 10:49 pm, edited 1 time in total.
Image
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: Realtime Bar Chart

Post by eddy »

nblackburn wrote: Uses a lot of CPU
Replace this line

Code: Select all

Event=WindowEvent() 
with this one:

Code: Select all

Event=WaitWindowEvent() ;<------ wait for incoming events and save CPU usage
Last edited by eddy on Sun Sep 06, 2015 10:48 pm, edited 1 time in total.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
nblackburn
User
User
Posts: 67
Joined: Mon Aug 19, 2013 1:22 am
Location: United Kingdom
Contact:

Re: Realtime Bar Chart

Post by nblackburn »

Oops, that will be it, nice catch!
Image
User avatar
deseven
Enthusiast
Enthusiast
Posts: 367
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Realtime Bar Chart

Post by deseven »

Why are you using vector library for that since you only use simple boxes? You can try to use 2Ddrawing only, should be faster i guess.

Also, reduce the StartDrawing()/StartVectorDrawing() calls to remove flickering. For example you can clear the CanvasGadget like that:

Code: Select all

Procedure ClearCanvas(Canvas)
  
  AddPathBox(0,0,GadgetWidth(Canvas),GadgetHeight(Canvas))
  VectorSourceColor($ffffffff)
  FillPath()
  
EndProcedure
and move its call in UpdateBars() under StartVectorDrawing().
Post Reply