Private mNbMaxSamples, mNbMaxCurves As Int
Public CurveX(10000) As Double
Public CurveY(10, 10000) As Double
Public CurveYName(10) As String
Public CurveYUnit(10) As String
Public CurveColor(4) As Int ' <====
Private CurveStrokeWidth(4) As Int
Private SingleCurveNames = True As Boolean
Private mDisplayCurveUnit = True As Boolean
Not in my mind. You can superimpose up to 4 curves, the colors are meant for those four curves.Should this dimension be changed to ten?
Sure, they should be the same. Updated in the first post in the xGraph thread.I also noticed that the b4xlib version of the library isn't the same as the bas file. Should they be the same?
I will set the CurveStrokeWidth array to Public.I might have a crack at providing different stroke widths.
Filter is a big chapter, but, I will add a Smooth method.I might also have a crack at filter functions for smoothing, rms or removal of means to add on to the integration and derivative functions.
This kind of display is based on bar display, I will not implement it in the xGraph class.I had FFT's and histograms for data presentation all within the one set of axis.
I finally added a property UseCustomColors, custom colors and custom widths for curves.
This means that by default, UseCustomColors = False, the 'standard' four colors for the displayed curves are used, like before.
Setting UseCustomColors = True allows to use a specific color and width for each curve.
The 'standard' CurveColor(4) and CurveWidth(4) and CurveCustomColor(NumberMaxCurves) and CurveCustomWidth(NumberMaxCurves) are public arrays.
NumberMaxCurves can be defined in the Designer or in the code, like before.
As written in my previous post, I added also a Smooth method.
Can you please test the attached B4J project before I update it in the xGraph thread.
I finally added a property UseCustomColors, custom colors and custom widths for curves.
This means that by default, UseCustomColors = False, the 'standard' four colors for the displayed curves are used, like before.
Setting UseCustomColors = True allows to use a specific color and width for each curve.
The 'standard' CurveColor(4) and CurveWidth(4) and CurveCustomColor(NumberMaxCurves) and CurveCustomWidth(NumberMaxCurves) are public arrays.
NumberMaxCurves can be defined in the Designer or in the code, like before.
As written in my previous post, I added also a Smooth method.
Can you please test the attached B4J project before I update it in the xGraph thread.
'======================================================================================
private Sub initX1
xGraph1.GraphWithMissingData = True
xGraph1.SetCurveName(0, "Voltage RMS", False)
xGraph1.SetScaleManu(0, 200, 260)
xGraph1.CurveCustomColor(0) = 0xFFFF0000
xGraph1.CurveCustomWidth(0) = 2dip
xGraph1.SetCurveName(1, "VMax", False)
xGraph1.SetScaleManu(1, 200, 260)
xGraph1.CurveCustomColor(1) = 0xFF4F4F4F
xGraph1.CurveCustomWidth(1) = 1dip
xGraph1.SetCurveName(2, "VMin", False)
xGraph1.SetScaleManu(2, 200, 260)
xGraph1.CurveCustomColor(2) = 0xFF4F4F4F
xGraph1.CurveCustomWidth(2) = 1dip
xGraph1.SetCurveName(3, "Frequency Hz", False)
xGraph1.SetScaleManu(3, 49, 52)
xGraph1.CurveCustomColor(3) = 0xFF006EFF
xGraph1.CurveCustomWidth(3) = 2dip
xGraph1.SetCurveName(4, "Freq Max", False)
xGraph1.SetScaleManu(4, 49, 52)
xGraph1.CurveCustomColor(4) = 0xFF4F4F4F
xGraph1.CurveCustomWidth(4) = 1dip
xGraph1.SetCurveName(5, "Freq Min", False)
xGraph1.SetScaleManu(5, 49, 52)
xGraph1.CurveCustomColor(5) = 0xFF4F4F4F
xGraph1.CurveCustomWidth(5) = 1dip
xGraph1.CurvesToDisplay.Initialize2(Array As Int(0, 1, 2, 3, 4, 5))
xGraph1.NbSamples = 7200
xGraph1.NbMaxSamples = 7200
...
End Sub
I finally added a property UseCustomColors, custom colors and custom widths for curves.
This means that by default, UseCustomColors = False, the 'standard' four colors for the displayed curves are used, like before.
Setting UseCustomColors = True allows to use a specific color and width for each curve.
The 'standard' CurveColor(4) and CurveWidth(4) and CurveCustomColor(NumberMaxCurves) and CurveCustomWidth(NumberMaxCurves) are public arrays.
NumberMaxCurves can be defined in the Designer or in the code, like before.
As written in my previous post, I added also a Smooth method.
Can you please test the attached B4J project before I update it in the xGraph thread.
and use it to display or not display the Y axis annotations and it works OK Viz:CurveYAxisAnnoEnable
Public CurveCustomWidth(10) As Int
Public CurveYAxisAnnoEnable(10) As Boolean 'RJG Line 100
Public CurveColor(4) As Int
If CurveYAxisAnnoEnable(nc) = True Then ' RJG Mod Line 677
If nc Mod 2 = 0 Then
xcvsGraph.DrawText(txt, Graph.Left - dx, y, Texts.ScaleFont, col, "RIGHT")
Else
xcvsGraph.DrawText(txt, Graph.Right + dx, y, Texts.ScaleFont, col, "LEFT")
End If
End If ' End RJG Mod
I finally added a property UseCustomColors, custom colors and custom widths for curves.
This means that by default, UseCustomColors = False, the 'standard' four colors for the displayed curves are used, like before.
Setting UseCustomColors = True allows to use a specific color and width for each curve.
The 'standard' CurveColor(4) and CurveWidth(4) and CurveCustomColor(NumberMaxCurves) and CurveCustomWidth(NumberMaxCurves) are public arrays.
NumberMaxCurves can be defined in the Designer or in the code, like before.
As written in my previous post, I added also a Smooth method.
Can you please test the attached B4J project before I update it in the xGraph thread.
#Event: Touch (Parameters() As Int)
#RaisesSynchronousEvents: Touch(Parameters())
#Event: CursorPositionChanged (CursorIndex As Int, XIndex As Int)
#RaisesSynchronousEvents: CursorPositionChanged (CursorIndex As Int, XIndex As Int)
'RJG
#Event: ZoomChanged (zib As Int, zie As Int)
#RaisesSynchronousEvents: ZoomChanged (zib As Int, zie As Int)
Case 1 'Up'
...
' RJG Zoom Changed Callback Line 346
If xui.SubExists(mCallBack, mEventName & "_ZoomChanged", 2) Then
CallSubDelayed3(mCallBack, mEventName & "_ZoomChanged", ZoomIBegin, Index)
End If
Case 2 'Move'
...
' RJG Zoom Changed Callback Line 395
If xui.SubExists(mCallBack, mEventName & "_ZoomChanged", 2) Then
CallSubDelayed3(mCallBack, mEventName & "_ZoomChanged", ScaleX.IBegin, ScaleX.IEnd)
End If
Public zoomCursorHeight As Int
...
'Draws the zoom cursor
Private Sub DrawZoomCursor
ZoomScale = xpnlCursor.Width / ScaleX.NbSamples
xcvsCursor.ClearRect(RectZoomCursor)
If Zoomed = True Then
RectZoomCursor.Initialize(ScaleX.IBegin * ZoomScale, xpnlCursor.Height - zoomCursorHeight, ScaleX.IEnd * ZoomScale, xpnlCursor.Height) 'RJG
xcvsCursor.DrawRect(RectZoomCursor, xui.Color_ARGB(180, 180, 180, 180), True, 1)
End If
xcvsCursor.Invalidate
End Sub
Hi Klaus,Hi Rob,
I will look at your additions tomorrow.
Thank you for sharing them.
xGraph1.SetGraphToSynchronize(xGraph2) 'synchronizes xGraph2 with xGraph1
xGraph2.SetGraphToSynchronize(xGraph1) 'synchronizes xGraph1 with xGraph2
Haven't you seen the Snapshot routine in the demo program !?Another function that might be handy is a way to "print" the chart to an image or pdf.
Attached you find the latest version.
It includes a synchronization of two xGraph objects.
You don't need to add much code for the synchronization, just two lines:
All the rest is managed insides the xGraph class.B4X:xGraph1.SetGraphToSynchronize(xGraph2) 'synchronizes xGraph2 with xGraph1 xGraph2.SetGraphToSynchronize(xGraph1) 'synchronizes xGraph1 with xGraph2
Below you see a blue line on top of the upper xGraph, this indicates the selected object
All the functions in the bottom part of the demp program apply to the selected xGraph.
To select the xGraph, just click on it, the colored top line will move to the other xGraph.
This is done in the xGraph1_Touch and xGraph2_Touch event routines with:
SelectGraph(xGraph2, xui.Color_Red)
SelectGraph(xGraph1, xui.Color_Blue)
The 'standard' cursor, the additional cursors and the zoom cursor moves are synchronized.
When you move one of them in one graph it is also moved in the other.
The ZoomChanged event routine is no more needed.
It works, of course, only if the X coordinates are the same!
View attachment 103564
I am not yet really convinced of this principle, duplicate data.
The best way would be to include directly in the class the possibility to display two graphs, but this is another challenge.
The scale routine has been improved, when the Y scales of all the displayed curves are the same, only one scale is displayed.
Can you please test it.
Haven't you seen the Snapshot routine in the demo program !?
With xGraph.Snapshot you get a bitmap and then you can do whatever you want with it.
The Snapshot routine in the demo program saves the bitmap into a file. It is just an example of what can be done.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?