Problem with right and left axis
Problem with right and left axis
Hi!!
Actually I use Teechart 7 version and Visual Basic 6. I need draw two series, one of them a bar style in left axis, and the other line style in right axis. I need a graph similar to image (attach), is this possible? And I can set the number of points in the scale? (In this example 6 points), because when set min and max values por left and right scale, the rght scale don't start in the bottom axis, and the graph have difent lines in left and riight axis. Thanks in advance
Actually I use Teechart 7 version and Visual Basic 6. I need draw two series, one of them a bar style in left axis, and the other line style in right axis. I need a graph similar to image (attach), is this possible? And I can set the number of points in the scale? (In this example 6 points), because when set min and max values por left and right scale, the rght scale don't start in the bottom axis, and the graph have difent lines in left and riight axis. Thanks in advance
- Attachments
-
- Example
- DemoGraph.jpg (46.25 KiB) Viewed 13228 times
Re: Problem with right and left axis
Hi Daniel,
You could use custom labels to do this. For example, this seems to end similar than what you described:
You could use custom labels to do this. For example, this seems to end similar than what you described:
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.AddSeries scBar
TChart1.AddSeries scLine
Dim i As Integer
For i = 0 To 25
TChart1.Series(0).Add Rnd * 5, "", clTeeColor
TChart1.Series(1).Add (Rnd * 0.25) + 2.6, "", clTeeColor
Next i
TChart1.Series(0).Marks.Visible = False
TChart1.Series(0).asBar.BarWidthPercent = 25
TChart1.Series(1).Pen.Width = 2
TChart1.Series(0).VerticalAxis = aLeftAxis
TChart1.Series(1).VerticalAxis = aRightAxis
TChart1.Axis.Left.SetMinMax 0, 6
TChart1.Axis.Right.SetMinMax 2.5, 2.9
TChart1.Environment.InternalRepaint
End Sub
Private Sub DrawRighAxisCustomLabels()
Dim i As Integer
Dim YValue As Double
With TChart1.Axis
.Right.Labels.Clear
For i = 0 To .Left.Labels.Count - 1
YValue = .Right.CalcPosPoint(.Left.CalcYPosValue(.Left.Labels.Item(i).Value))
.Right.Labels.Add YValue, Format$(YValue, "#.###")
Next i
End With
End Sub
Private Sub TChart1_OnAfterDraw()
DrawRighAxisCustomLabels
End Sub
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Problem with right and left axis
Hi Yeray,
Thanks for your reply. I try your solution, but not fix my problem. I need, equal lines in right and left axis, i will attach an image with the example. And other question, I can set the number of intervals in the graph? I changed the increment value in the left and right axis calculating this value (in other example), but the right axis not start in the bottom axis, and the lines in left and right axis is not equal. Thanks for your time and patience.
Thanks for your reply. I try your solution, but not fix my problem. I need, equal lines in right and left axis, i will attach an image with the example. And other question, I can set the number of intervals in the graph? I changed the increment value in the left and right axis calculating this value (in other example), but the right axis not start in the bottom axis, and the lines in left and right axis is not equal. Thanks for your time and patience.
- Attachments
-
- Graph Demo
- DemoGraph.jpg (48.66 KiB) Viewed 13147 times
Re: Problem with right and left axis
Hi Daniel,
Excuse me. I missed a line at the end of Form_Load method:
Now I corrected the code above too.
Excuse me. I missed a line at the end of Form_Load method:
Code: Select all
TChart1.Environment.InternalRepaint
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Problem with right and left axis
Hi Yeray, thanks for your time
I try again, and the problem is the same
Is possible draw a graph like I want?
Thanks
I try again, and the problem is the same
Is possible draw a graph like I want?
Thanks
Re: Problem with right and left axis
Hi Yeray,
I want to draw a graph like that.
Thanks in advance
I want to draw a graph like that.
Thanks in advance
- Attachments
-
- Mple.jpg (22.62 KiB) Viewed 13097 times
Re: Problem with right and left axis
Hi Daniel,
Here is what I'm getting with the code suggested above in TeeChart v8.
I'm afraid I can't think on a way to do this in v7.
Here is what I'm getting with the code suggested above in TeeChart v8.
I'm afraid I can't think on a way to do this in v7.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Problem with right and left axis
Hi Yeray
Is true, I tried in v8 and work fine. Thanks. I'll update my version
I have another two questions
- Is possible create a graph, with comments in a few points? (like picture1)
- If I have a graph with logarithmic scale, how can I controll the number of points in a scale, for example if I want only 3 points (like pincture 2)
Thanks for your time, if this two graphs work fine, I'll update my version asap
Thanks in advance
Is true, I tried in v8 and work fine. Thanks. I'll update my version
I have another two questions
- Is possible create a graph, with comments in a few points? (like picture1)
- If I have a graph with logarithmic scale, how can I controll the number of points in a scale, for example if I want only 3 points (like pincture 2)
Thanks for your time, if this two graphs work fine, I'll update my version asap
Thanks in advance
- Attachments
-
- Picture 1
- DemoGraph.jpg (91.67 KiB) Viewed 13086 times
-
- Picture 2
- DemoGraph2.jpg (32.15 KiB) Viewed 13080 times
Re: Problem with right and left axis
Hi Daniel,
Yes, you can use annotation tools and you can update their positions at OnAfterDraw event if you want them to be repositioned each time the chart is redrawn.Daniel wrote:- Is possible create a graph, with comments in a few points? (like picture1)
Do you mean the left axis labels? You can use custom labels, for example:Daniel wrote:- If I have a graph with logarithmic scale, how can I controll the number of points in a scale, for example if I want only 3 points (like pincture 2)
Code: Select all
uses series, teetools;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=false;
Chart1.MarginLeft:=10;
Chart1.AddSeries(TFastLineSeries.Create(self));
Chart1.Axes.Left.Logarithmic:=true;
Chart1[0].FillSampleValues(100);
with Chart1.Axes.Left.Items do
begin
Clear;
Add(Chart1[0].YValues.MinValue);
Add(Chart1[0].YValues.MinValue + Chart1[0].YValues.MaxValue / 2);
Add(Chart1[0].YValues.MaxValue);
end;
Chart1.Tools.Add(TAnnotationTool.Create(self));
Chart1.Tools.Add(TAnnotationTool.Create(self));
(Chart1.Tools[0] as TAnnotationTool).Text:='point 25 info';
(Chart1.Tools[1] as TAnnotationTool).Text:='point 75 info';
Chart1.Draw;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
(Chart1.Tools[0] as TAnnotationTool).Left:=Chart1[0].CalcXPos(25);
(Chart1.Tools[0] as TAnnotationTool).Top:=Chart1[0].CalcYPos(25);
(Chart1.Tools[1] as TAnnotationTool).Left:=Chart1[0].CalcXPos(75);
(Chart1.Tools[1] as TAnnotationTool).Top:=Chart1[0].CalcYPos(75);
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Problem with right and left axis
Thanks Yeray, I'll update my versión ASAP
Could you write to me, an example for anotation tool?
TIA
Daniel
Could you write to me, an example for anotation tool?
TIA
Daniel
Re: Problem with right and left axis
Hi Yeray
Acutally I use Visual Basic 6.
thanks
Acutally I use Visual Basic 6.
thanks
Re: Problem with right and left axis
Hi Daniel,
Here it is the above example translated to VB6:
Here it is the above example translated to VB6:
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.Panel.MarginLeft = 10
TChart1.AddSeries scFastLine
TChart1.Axis.Left.Logarithmic = True
TChart1.Series(0).FillSampleValues 100
With TChart1.Axis.Left.Labels
.Clear
.Add TChart1.Series(0).YValues.Minimum, Str$(TChart1.Series(0).YValues.Minimum)
.Add TChart1.Series(0).YValues.Minimum + TChart1.Series(0).YValues.Maximum / 2, Str$(TChart1.Series(0).YValues.Minimum + TChart1.Series(0).YValues.Maximum / 2)
.Add TChart1.Series(0).YValues.Maximum, Str$(TChart1.Series(0).YValues.Maximum)
End With
TChart1.Tools.Add tcAnnotate
TChart1.Tools.Add tcAnnotate
With TChart1.Tools.Items(0).asAnnotation
.Text = "point 25 info"
.Callout.Visible = True
.Callout.Arrow.Visible = True
.Callout.Style = psNothing
.Callout.Arrow.Color = vbBlack
End With
With TChart1.Tools.Items(1).asAnnotation
.Text = "point 75 info"
.Callout.Visible = True
.Callout.Arrow.Visible = True
.Callout.Style = psNothing
.Callout.Arrow.Color = vbBlack
End With
TChart1.Environment.InternalRepaint
End Sub
Private Sub TChart1_OnAfterDraw()
With TChart1.Tools.Items(0).asAnnotation
.Left = TChart1.Series(0).CalcXPos(25) + 10
.Top = TChart1.Series(0).CalcYPos(25) + 10
.Callout.XPosition = TChart1.Series(0).CalcXPos(25)
.Callout.YPosition = TChart1.Series(0).CalcYPos(25)
End With
With TChart1.Tools.Items(1).asAnnotation
.Left = TChart1.Series(0).CalcXPos(75) + 10
.Top = TChart1.Series(0).CalcYPos(75) + 10
.Callout.XPosition = TChart1.Series(0).CalcXPos(75)
.Callout.YPosition = TChart1.Series(0).CalcYPos(75)
End With
End Sub
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Problem with right and left axis
Hi Yeray,
That's exact why I need
Thanks
That's exact why I need
Thanks