hello
I have two windows, one in each chart window.
The increment of the X axis is 30 seconds.
I want 10 pixels for 30 seconds.
X minimum is 27/04/2013 3:33:00 p.m..
PROCEDURE FORMLOAD ()
CALCULBOTTOMAXIS ()
.....
PROCEDURE OnResize ()
CALCULBOTTOMAXIS ()
....
PROCEDURE CALCULBOTTOMAXIS ()
StartPos is int = TChart1 >> Axis >> Bottom >> IStartPos EndPos is int = TChart1 >> Axis >> Bottom >> IEndPos lr30Sec is a real = TChart1 >> GetDateTimeStep (dtThirtySeconds) pixels is an integer = 10
MaxDateHeure MinDateHeure + = (((EndPos - StartPos) / pixels) * lr30Sec)
TChart1 >> Axis >> Bottom >> Maximum = gfrMaxDateHeure
before increasing the size of the window the two scales are correct
after having increased the size of the window the scales are not identical
do you have a solution to keep 10 pixels for 30 seconds
the scale of x-axis change after increase the size of window
the scale of x-axis change after increase the size of window
- Attachments
-
- AFTER INCREASE SIZE OF WINDOWS.PNG (22.75 KiB) Viewed 18520 times
-
- BEFORE INCREASE SIZE OF WINDOWS.PNG (24.44 KiB) Viewed 18513 times
Re: the scale of x-axis change after increase the size of window
Bonjour Jean,
If I'm not wrong, you asked how to keep the axes ratio when the window is being resized, and we suggested you to do something like in the following example:
The above may not be precise enough. Have you tried to find an alternative calculation for the new axes maximum, still at the OnResize event?
If I'm not wrong, you asked how to keep the axes ratio when the window is being resized, and we suggested you to do something like in the following example:
Code: Select all
Dim bMax, lMax As Double
Dim bEnd, lEnd, bSize As Integer
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.Panel.MarginUnits = muPixels
TChart1.AddSeries scFastLine
TChart1.Series(0).XValues.DateTime = True
TChart1.Series(0).FillSampleValues
TChart1.Tools.Add tcColorband
TChart1.Tools.Items(0).asColorband.Axis = TChart1.Axis.Bottom
TChart1.Tools.Items(0).asColorband.StartValue = 5
TChart1.Tools.Items(0).asColorband.EndValue = 15
TChart1.Environment.InternalRepaint
bMax = TChart1.Axis.Bottom.Maximum
lMax = TChart1.Axis.Left.Maximum
bEnd = TChart1.Axis.Bottom.IEndPos
bSize = bEnd - TChart1.Axis.Bottom.IStartPos
lEnd = TChart1.Axis.Left.IEndPos
End Sub
Private Sub TChart1_OnResize()
Dim ratio, posMax As Double
TChart1.Axis.Bottom.AutomaticMaximum = False
If TChart1.Axis.Bottom.IsDateTime Then
ratio = (TChart1.Axis.Bottom.IEndPos - TChart1.Axis.Bottom.IStartPos) / bSize
posMax = TChart1.Axis.Bottom.CalcXPosValue(bMax) * ratio
TChart1.Axis.Bottom.Maximum = TChart1.Axis.Bottom.CalcPosPoint(posMax)
Else
TChart1.Axis.Bottom.Maximum = TChart1.Axis.Bottom.IEndPos * bMax / bEnd
End If
TChart1.Axis.Left.AutomaticMaximum = False
TChart1.Axis.Left.Maximum = TChart1.Axis.Left.IEndPos * lMax / lEnd
End Sub
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: the scale of x-axis change after increase the size of window
Hello
Ok you have answered the previous question: maintain the scale when the window size changes.
But this time it is another question:
When I close my program I record the size and position of the window.
And I return the size and position when I open the program.
In this case the minimum of the X-axis is always the current time, and the maximum is determined by the size of the X-axis
As the increment of the X axis is 30 seconds I set to 10 pixels for 30 seconds. So I can calculate the number of ticks and the maximum of the axis.
lnStartPos is int = TChart1 >> Axis >> Bottom >> IStartPos
lnEndPos is int = TChart1 >> Axis >> Bottom >> IEndPos
lr30Sec is a real = Round (TChart1 >> GetDateTimeStep (dtThirtySeconds), 7)
lnPixel is int = 10
gfrMinDateHeure = pg_DateHeureVersReel (gfdhMinDateHeure)
gfrMaxDateHeure = Round (gfrMinDateHeure + (((lnEndPos - lnStartPos) / lnPixel) * lr30Sec), 7)
NB: I use Windev I've written a function to convert the date windev to TeeChart Date
Here is my question:
I have two windows, one in each window TeeChart.
when I change the window size and TeeChart,
the scales of techart two are not identical.
reminder:
with your answer to my previous question, if I increase the size of the window I do not change but the maximum scale of the X axis changes.
Ok you have answered the previous question: maintain the scale when the window size changes.
But this time it is another question:
When I close my program I record the size and position of the window.
And I return the size and position when I open the program.
In this case the minimum of the X-axis is always the current time, and the maximum is determined by the size of the X-axis
As the increment of the X axis is 30 seconds I set to 10 pixels for 30 seconds. So I can calculate the number of ticks and the maximum of the axis.
lnStartPos is int = TChart1 >> Axis >> Bottom >> IStartPos
lnEndPos is int = TChart1 >> Axis >> Bottom >> IEndPos
lr30Sec is a real = Round (TChart1 >> GetDateTimeStep (dtThirtySeconds), 7)
lnPixel is int = 10
gfrMinDateHeure = pg_DateHeureVersReel (gfdhMinDateHeure)
gfrMaxDateHeure = Round (gfrMinDateHeure + (((lnEndPos - lnStartPos) / lnPixel) * lr30Sec), 7)
NB: I use Windev I've written a function to convert the date windev to TeeChart Date
Here is my question:
I have two windows, one in each window TeeChart.
when I change the window size and TeeChart,
the scales of techart two are not identical.
reminder:
with your answer to my previous question, if I increase the size of the window I do not change but the maximum scale of the X axis changes.
Re: the scale of x-axis change after increase the size of window
Hello,
So, if I understood it correctly, you save&restore the size of the two windows but the axis scale is lost. What I'm not sure to understand is if the scale is lost just after restoring the application or once you resize the window in the restored application.
If the charts have a wrong scales after restoring, what happens if you resize the windows? Do they get correct? This would indicate the calculation is correctly done in the resize event but not in the startup (restore) of the application. Check you are setting the axes scales at the application startup, considering the restored window size.
Also note forcing a chart repaint before getting the axis size may help here. In the example above I had to do it:
If the charts have a wrong scales after restoring, and resizing the windows doesn't help, it revise the calculations and debug the application to see where's exactly the problem. Maybe you'll need to save&restore the axes scales in a similar way as you saved&restored the windows sizes, if possible.
If the charts are correct after restoring, but they get wrong after resizing, I'd revise the calculations and debug the application to see where the error exactly is.
So, if I understood it correctly, you save&restore the size of the two windows but the axis scale is lost. What I'm not sure to understand is if the scale is lost just after restoring the application or once you resize the window in the restored application.
If the charts have a wrong scales after restoring, what happens if you resize the windows? Do they get correct? This would indicate the calculation is correctly done in the resize event but not in the startup (restore) of the application. Check you are setting the axes scales at the application startup, considering the restored window size.
Also note forcing a chart repaint before getting the axis size may help here. In the example above I had to do it:
Code: Select all
TChart1.Environment.InternalRepaint
If the charts are correct after restoring, but they get wrong after resizing, I'd revise the calculations and debug the application to see where the error exactly is.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: the scale of x-axis change after increase the size of window
the scale is wrong after restoring then window and after a resize.
take a look on the attachment there is a small difference.
5 PIXELS ENV.
THE SIZE OF X-AXIS IS 625 PIXELS
on load of the window
TChart1>>Environment>>InternalRepaint
TChart1>>axis>>Bottom>>ExactDateTime=Vrai
TChart1>>Axis>>Bottom>>AutomaticMaximum = Faux
TChart1>>Axis>>Bottom>>AutomaticMinimum = Faux
on load of the window and on resize
lnStartPos est un entier = TChart1>>Axis>>Bottom>>IStartPos // BEGIN OF Y-AXIS
lnEndPos est un entier = TChart1>>Axis>>Bottom>>IEndPos // END OF Y-AXIS
lr30Sec est un réel = TChart1>>GetDateTimeStep(dtThirtySeconds) // INCREMENT Y-AXIS
lnPixel est un entier = 10 // I WANT 10 PIXELS FOR INCREMENT OF 30 SECONDS
gfrMaxDateHeure = gfrMinDateHeure + (((lnEndPos - lnStartPos) / lnPixel) * lr30Sec) // DATE MAXIMUM OF Y-AXIS
TChart1>>Axis>>Bottom>>Maximum = gfrMaxDateHeure
take a look on the attachment there is a small difference.
5 PIXELS ENV.
THE SIZE OF X-AXIS IS 625 PIXELS
on load of the window
TChart1>>Environment>>InternalRepaint
TChart1>>axis>>Bottom>>ExactDateTime=Vrai
TChart1>>Axis>>Bottom>>AutomaticMaximum = Faux
TChart1>>Axis>>Bottom>>AutomaticMinimum = Faux
on load of the window and on resize
lnStartPos est un entier = TChart1>>Axis>>Bottom>>IStartPos // BEGIN OF Y-AXIS
lnEndPos est un entier = TChart1>>Axis>>Bottom>>IEndPos // END OF Y-AXIS
lr30Sec est un réel = TChart1>>GetDateTimeStep(dtThirtySeconds) // INCREMENT Y-AXIS
lnPixel est un entier = 10 // I WANT 10 PIXELS FOR INCREMENT OF 30 SECONDS
gfrMaxDateHeure = gfrMinDateHeure + (((lnEndPos - lnStartPos) / lnPixel) * lr30Sec) // DATE MAXIMUM OF Y-AXIS
TChart1>>Axis>>Bottom>>Maximum = gfrMaxDateHeure
Re: the scale of x-axis change after increase the size of window
Hi,
We should find where the calculation is getting wrong. It could be some rounding problem or some mistake in the calculations we are doing.
And only resizing, before restoring anything?jika wrote:the scale is wrong after restoring then window and after a resize.
We should find where the calculation is getting wrong. It could be some rounding problem or some mistake in the calculations we are doing.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: the scale of x-axis change after increase the size of window
Don't know if this might help or not, but I have used the component for years with no problems.
ReSize component.
http://www.lyoung.com/
ReSize component.
http://www.lyoung.com/
Re: the scale of x-axis change after increase the size of window
I think I have solved the problem
I use Windev. And I'm writing
lnStartPos is int = TChart1 >> Axis >> Bottom >> IStartPos
lnEndPos is int = TChart1 >> Axis >> Bottom >> IEndPos
lr30sec is a real = GetDateTimeStep (dtThirtySeconds))
gfrMinDateHeure is a real
gfrMinDateHeure gfrMinDateHeure + = ((lnEndPos - lnStartPos) / 10 * lr30sec)
TChart1 >> Axis >> Bottom >> Maximum = gfrMinDateHeure
TChart1 >> Axis >> Bottom >> Minimum = gfrMinDateHeure
TChart1 >> Axis >> Bottom >> Increment = lr30sec
this method is bad because of the declaration of real (double in vb6)
it's better to write in this way
TChart1 >> Axis >> Bottom >> Maximum = Round (gfrMinDateHeure, 7) + (((lnEndPos - lnStartPos) / 10) >> TChart1 GetDateTimeStep (dtThirtySeconds))
TChart1 >> Axis >> Bottom >> Minimum = gfrMinDateHeure
TChart1 >> Axis >> Bottom >> Increment = TChart1 >> GetDateTimeStep (dtThirtySeconds)
thank you for your time to work on the subject
I use Windev. And I'm writing
lnStartPos is int = TChart1 >> Axis >> Bottom >> IStartPos
lnEndPos is int = TChart1 >> Axis >> Bottom >> IEndPos
lr30sec is a real = GetDateTimeStep (dtThirtySeconds))
gfrMinDateHeure is a real
gfrMinDateHeure gfrMinDateHeure + = ((lnEndPos - lnStartPos) / 10 * lr30sec)
TChart1 >> Axis >> Bottom >> Maximum = gfrMinDateHeure
TChart1 >> Axis >> Bottom >> Minimum = gfrMinDateHeure
TChart1 >> Axis >> Bottom >> Increment = lr30sec
this method is bad because of the declaration of real (double in vb6)
it's better to write in this way
TChart1 >> Axis >> Bottom >> Maximum = Round (gfrMinDateHeure, 7) + (((lnEndPos - lnStartPos) / 10) >> TChart1 GetDateTimeStep (dtThirtySeconds))
TChart1 >> Axis >> Bottom >> Minimum = gfrMinDateHeure
TChart1 >> Axis >> Bottom >> Increment = TChart1 >> GetDateTimeStep (dtThirtySeconds)
thank you for your time to work on the subject
Re: the scale of x-axis change after increase the size of window
Hi,
Thanks for sharing the solution. I'm glad to hear you found it!
Thanks for sharing the solution. I'm glad to hear you found it!
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |