Page 1 of 1

Realtime Bar Chart

Posted: Sun Sep 06, 2015 10:36 pm
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.

Re: Realtime Bar Chart

Posted: Sun Sep 06, 2015 10:41 pm
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

Re: Realtime Bar Chart

Posted: Sun Sep 06, 2015 10:47 pm
by nblackburn
Oops, that will be it, nice catch!

Re: Realtime Bar Chart

Posted: Fri Sep 25, 2015 5:49 am
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().