[Module] Chart - Gadget
Re: [Module] Chart - Gadget
Hi Thorsten,
Is there any chance you could add a stacked bar chart to this module?
Regards
Andy
Is there any chance you could add a stacked bar chart to this module?
Regards
Andy
Re: [Module] Chart - Gadget
Update for C-BackEnd
Part of ChartModule.pbi
Bugfix
Update PB v6.0 Alpha 3
Part of ChartModule.pbi
Bugfix
Update PB v6.0 Alpha 3
Code: Select all
;- ============================================================================
;- Module - Internal
;- ============================================================================
CompilerIf Not Defined(PB_Compiler_Backend, #PB_Constant)
#PB_Compiler_Backend = 0
#PB_Backend_C = 1
#PB_Backend_Asm = 0
CompilerEndIf
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
; Addition of mk-soft
Procedure OSX_NSColorToRGBA(NSColor)
Protected.cgfloat red, green, blue, alpha
Protected nscolorspace, rgba
nscolorspace = CocoaMessage(0, nscolor, "colorUsingColorSpaceName:$", @"NSCalibratedRGBColorSpace")
If nscolorspace
CocoaMessage(@red, nscolorspace, "redComponent")
CocoaMessage(@green, nscolorspace, "greenComponent")
CocoaMessage(@blue, nscolorspace, "blueComponent")
CocoaMessage(@alpha, nscolorspace, "alphaComponent")
rgba = RGBA(red * 255.9, green * 255.9, blue * 255.9, alpha * 255.)
ProcedureReturn rgba
EndIf
EndProcedure
Procedure OSX_NSColorToRGB(NSColor)
Protected.cgfloat red, green, blue
Protected r, g, b, a
Protected nscolorspace, rgb
nscolorspace = CocoaMessage(0, nscolor, "colorUsingColorSpaceName:$", @"NSCalibratedRGBColorSpace")
If nscolorspace
CocoaMessage(@red, nscolorspace, "redComponent")
CocoaMessage(@green, nscolorspace, "greenComponent")
CocoaMessage(@blue, nscolorspace, "blueComponent")
rgb = RGB(red * 255.0, green * 255.0, blue * 255.0)
ProcedureReturn rgb
EndIf
EndProcedure
CompilerEndIf
CompilerIf Defined(ModuleEx, #PB_Module)
Procedure.i GetGadgetWindow()
ProcedureReturn ModuleEx::GetGadgetWindow()
EndProcedure
CompilerElse
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
; Thanks to mk-soft
Import ""
PB_Object_EnumerateStart(PB_Objects)
PB_Object_EnumerateNext(PB_Objects, *ID.Integer)
PB_Object_EnumerateAbort(PB_Objects)
EndImport
CompilerIf #PB_Compiler_Backend = #PB_Backend_C
Global PB_Window_Objects
Procedure _WindowObjects()
!extern integer PB_Window_Objects;
!return PB_Window_Objects;
EndProcedure
PB_Window_Objects = _WindowObjects()
CompilerElse
Import ""
PB_Window_Objects
EndImport
CompilerEndIf
CompilerElse
ImportC ""
PB_Object_EnumerateStart(PB_Objects)
PB_Object_EnumerateNext(PB_Objects, *ID.Integer)
PB_Object_EnumerateAbort(PB_Objects)
PB_Window_Objects.i
EndImport
CompilerEndIf
Procedure.i GetGadgetWindow()
; Thanks to mk-soft
Define.i WindowID, Window, Result = #PB_Default
WindowID = UseGadgetList(0)
PB_Object_EnumerateStart(PB_Window_Objects)
While PB_Object_EnumerateNext(PB_Window_Objects, @Window)
If WindowID = WindowID(Window)
Result = Window
Break
EndIf
Wend
PB_Object_EnumerateAbort(PB_Window_Objects)
ProcedureReturn Result
EndProcedure
CompilerEndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: [Module] Chart - Gadget
Oh... very nice. I need to have a good look at this, see if I can stop working on my own graph_lib routines
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: [Module] Chart - Gadget
How can I use line-chart for as live chart ... realtime data insert ... I need multiline chart ... ??
Re: [Module] Chart - Gadget
Realtime? I don't think this is possible (and intended) with this module...
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: [Module] Chart - Gadget
Can be used, but is very slow and have huge flicker. Not the best solution.
Re: [Module] Chart - Gadget
can you suggest better? Thank you!
Hi, perhaps, but some flickering persists... here is how I did it:
Code: Select all
CompilerIf #PB_Compiler_IsMainFile
Enumeration
#Window
#Chart
EndEnumeration
If OpenWindow(#Window, 0, 0, 700, 500, "Example", #PB_Window_SystemMenu|#PB_Window_Tool|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
SmartWindowRefresh(#Window,1)
Chart::Gadget(#Chart, 10, 10, 680, 480, Chart::#LineChart|Chart::#DataSeries, #Window)
Chart::SetFlags(#Chart, Chart::#Legend, Chart::#Hide)
Chart::SetFlags(#Chart, Chart::#LineChart, Chart::#BezierCurve|Chart::#NoAutoAdjust) ; |Chart::#Descending|Chart::#NoAutoAdjust
Chart::SetAttribute(#Chart, Chart::#Maximum, 100)
Chart::SetAttribute(#Chart, Chart::#FontSize, 10)
Chart::SetFlags(#Chart, Chart::#LineChart, Chart::#OutOfRange)
Chart::SetAutoResizeFlags(#Chart, Chart::#ResizeWidth)
Chart::SetColor(#Chart, Chart::#BackColor, $ffffff)
Chart::SetColor(#Chart, Chart::#AxisColor, $ffffff)
Chart::AddDataSeries(#Chart, "1", $FF901E)
Chart::AddDataSeries(#Chart, "2", $0000FF)
Chart::AddDataSeries(#Chart, "3", $00D7FF)
AddWindowTimer(#Window, 123, 1000)
Define i.i = 0
Repeat
Event = WaitWindowEvent(1)
If Event = #PB_Event_Timer And EventTimer() = 123
i + 1
Chart::DisableReDraw(#Chart, #True)
Chart::AddSeriesItem(#Chart, "1", Str(i), Random(80, 60))
Chart::AddSeriesItem(#Chart, "2", Str(i), Random(60, 40))
Chart::AddSeriesItem(#Chart, "3", Str(i), Random(40, 20))
Chart::DisplayDataSeries(#Chart, "1")
Chart::DisplayDataSeries(#Chart, "2")
Chart::DisplayDataSeries(#Chart, "3")
If i > 30
Chart::RemoveSeriesItem(#Chart, "1", 0)
Chart::RemoveSeriesItem(#Chart, "2", 0)
Chart::RemoveSeriesItem(#Chart, "3", 0)
EndIf
Chart::DisableReDraw(#Chart, #False)
EndIf
Until Event = #PB_Event_CloseWindow
CloseWindow(#Window)
End
EndIf
CompilerEndIf
Re: [Module] Chart - Gadget
I don't know a complete solution like this Chart, but may be you can adapt and extend some of the various examples on this forum.
Example:
viewtopic.php?f=13&t=75772
Example:
viewtopic.php?f=13&t=75772
Re: [Module] Chart - Gadget
@ruslanx: I mean, yes, you can use it for realtime chart creating, but each time the whole picture is rendered completely new, so you'll encounter a lot of flickering, cpu consumption and maybe some more side effects.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: [Module] Chart - Gadget
Can't you do this optimised with an OpenGLGadget?
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: [Module] Chart - Gadget
@Thorsten: Do you still work on this module (in case of a minor error)?
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB