Page 1 of 1
how can we sorting chart
Posted: Mon Jun 05, 2006 1:15 pm
by 6925851
i need to sort chart by series but labelvalues on the x-axis has to be changed according to sort..
i used this code
TChart1.series(i).YValues.Order = loDescending
TChart1.series(i).YValues.Sort
TChart1.series(i).XValues.FillSequence
series was sorted but on the bottom is showing for wrong label
ie,
on x-axis i have plotted 2008,2009,2010
on y-axis volume
and have 5 series and i need to sort on the last series descending
Posted: Tue Jun 06, 2006 8:36 am
by narcis
Hi Aravind,
This is because the axes labels drawn correspond to the first series. You should try chaning your last series to first series:
Code: Select all
ExchangeSeries(Series1, Series2: Integer);
This method changes the Series order, swapping one Series Z position with another. The Chart repaints to reflect the new Series order. It accesses TChart.SeriesList property.
while sorting some data marks visible outside the graph
Posted: Wed Jun 07, 2006 10:13 am
by 6925851
while sorting , some data marks are appearing outside the graph
i used following code
For i = 0 To TChart1.SeriesCount - 1
TChart1.series(i).XValues.Order = loNone
TChart1.series(i).YValues.Order = loDescending
TChart1.series(i).YValues.Sort
TChart1.series(i).XValues.FillSequence
Next i
TChart1.Repaint
tchart1.Page.MaxPointsPerPage=5
i have enclosed tee file in your newsgroup
pls advise me on this
aravind
Posted: Wed Jun 07, 2006 10:58 am
by narcis
Hi Aravind,
You can clip them using this code:
Code: Select all
Private Sub TChart1_OnBeforeDrawSeries()
TChart1.Canvas.ClipRectangle TChart1.Axis.Left.Position, _
TChart1.Axis.Top.Position - TChart1.Aspect.Height3D, _
TChart1.Axis.Right.Position + TChart1.Aspect.Width3D, _
TChart1.Axis.Bottom.Position
End Sub
still some part of the bar inside is shown on the corners
Posted: Wed Jun 07, 2006 11:25 am
by 6925851
still some part of the bar is shown inside the chart
for example :
i have kept the max no of points is 5 , do sorting then ur masked code works fine trim outter area but the 6th point is shown half on the corner of the chart ( half bar is visible )
aravind
Posted: Fri Jun 09, 2006 8:24 am
by Pep
Hi aravind,
it works fine here using the following code, could you please check if it works fine for you ? :
Code: Select all
Private Sub Form_Load()
With TChart1
.Series(0).FillSampleValues (10)
For i = 0 To TChart1.SeriesCount - 1
.Series(i).YValues.Order = loDescending
.Series(i).YValues.Sort
.Series(i).XValues.FillSequence
Next i
.Page.MaxPointsPerPage = 5
End With
End Sub
there is another issue
Posted: Fri Jun 09, 2006 12:11 pm
by 6925851
when i used the code which you have given , the page number ,data table are masked too ... apart from the outer region ...
how can we avoid this issue pls advise me
thanks
aravind
Posted: Mon Jun 12, 2006 11:09 am
by narcis
Hi Aravind,
There's a simpler solution then, which is using TChart1.Series(i).Marks.Clip=True:
Code: Select all
Private Sub Form_Load()
ChartPageNavigator1.Chart = TChart1
With TChart1
For i = 0 To 4
.AddSeries scLine
.Series(i).FillSampleValues (10)
.Series(i).Marks.Visible = True
Next
For i = 0 To TChart1.SeriesCount - 1
.Series(i).YValues.Order = loDescending
.Series(i).YValues.Sort
.Series(i).XValues.FillSequence
.Series(i).Marks.Clip = True
Next i
.Page.MaxPointsPerPage = 5
End With
End Sub