Page 1 of 1

Erroneous data in the ChartGrid while edit the value...

Posted: Fri Mar 03, 2006 6:36 am
by 9083326
Hi,

I am using the Teechart latest version 7.0.0.6. I am using the ChartGrid also. I created series0 of type line and created one more series as series1. For series1 the datasource is series0 and setting the smoothing function. I am showing the chartgrid. I am seeing 120 rows in the grid. Because I am setting the FunctionType.asSmoothing.Factor = 10 for series2. But hiding the series2 columns in the grid. When I entering the 110 in the 12th row, in the 3rd row 11 is added in the x axis column and 0 in the Y axis column. This is cuasing the problem. I do not the know what could be the problem. My intension is display the data only for series0. Then I can modify the values in the grid. Which intern reflect the graph.

Now I am not able add a new row in the grid. How can we add a new row.

Please find the code below to reproduce the problem. You just copy this code to a form. Please let me know if you need more information. I need to solve this problem as early as possible. Because my dead line is next weekend.

Private Sub Form_Load()
Dim XCoords(1 To 11) As Double
Dim YCoords(1 To 11) As Double
Dim i As Integer

XCoords(1) = 2.33
YCoords(1) = 27.778
XCoords(2) = 6.46
YCoords(2) = 62.778
XCoords(3) = 9.71
YCoords(3) = 93.333
XCoords(4) = 19.86
YCoords(4) = 165.566
XCoords(5) = 25.74
YCoords(5) = 204.444
XCoords(6) = 38.21
YCoords(6) = 287.778
XCoords(7) = 46.89
YCoords(7) = 343.33
XCoords(8) = 51.17
YCoords(8) = 371.111
XCoords(9) = 67.7
YCoords(9) = 498.889
XCoords(10) = 74.91
YCoords(10) = 565.556
XCoords(11) = 100
YCoords(11) = 817.32

With TChart1

.Legend.LegendStyle = lsSeries
.Legend.CheckBoxes = True
.Legend.Visible = True
.Axis.Bottom.Labels.MultiLine = True
.Axis.Bottom.Automatic = False
.Axis.Bottom.SetMinMax 0#, 101#
.Axis.Bottom.Title.Caption = "X - Axis"
.Axis.Bottom.Title.Font.Bold = True
.Axis.Left.Title.Caption = "Y - Axis"
.Axis.Left.Title.Font.Bold = True
.Header.Text.Clear
.Header.Text.Add "Test"
.AddSeries scLine
End With
With TChart1.Series(0)
.asLine.Pointer.Visible = True
.asLine.Pointer.Style = psDownTriangle
.asLine.Pointer.VerticalSize = 2
For i = 1 To 11
.AddXY XCoords(i), YCoords(i), CStr(XCoords(i)), vbRed
Next i
.Title = "Test"
End With

TChart1.AddSeries scLine
With TChart1.Series(1)
.SetFunction tfSmoothing
.DataSource = TChart1.Series(0).Name
.Color = vbRed
.FunctionType.asSmoothing.Factor = 10
.Title = "Test"
End With

With TChart1.Series(0)
.ShowInLegend = False
.asLine.LinePen.Visible = False
End With

TChart1.Tools.Add tcMarksTip
TChart1.Tools.Items(0).asMarksTip.Delay = 10
TChart1.Tools.Items(0).asMarksTip.Style = smsValue

ChartGrid1.Chart = TChart1

ChartGrid1.Cols.Widths(0) = 0
ChartGrid1.Cols.Widths(1) = 0
ChartGrid1.Cols.Widths(4) = 0
ChartGrid1.Cols.Widths(5) = 0

End Sub

Thanks & Regards,
Rama

Posted: Wed Mar 08, 2006 10:09 am
by Pep
Hi Rama,

yes, to be able to add new rows in the ChartGrid, add the following line at the end of your code :
TChart1.Series(0).XValues.Order = loNone

Posted: Thu Mar 09, 2006 12:25 pm
by 9083326
Hi Pep,

Thank you for your solution. But in my request I have the following questions.

1) How can we add a new row in the grid?
2) Series0 having the 12 points. But the grid is displaying 120 rows. How can we display only 12 rows in the grid?

Thanks & Regards,
Rama

Posted: Fri Mar 17, 2006 11:12 am
by Pep
Hi Rama,

1) Adding the line I post in my other reply simply double clicking over the cells and add a new value should work fine.
2) The only way I can think of is by setting the height of each row to 0, like we do for the cols. One trick could be to do this and leave one row which allow to add a new data row (by clicking over the empty cells, and once the cell is clicked you can change the height of the next row, or can be changed in another moment if you want, for example checking the .Series(0).Count,..).
Once the ChartGrid arrives to the end of rows, to add a new row the user must use the keyDown.

Code: Select all

Private Sub ChartGrid1_OnClick()
ChartGrid1.Rows.Heights(TChart1.Series(0).Count + 2) = ChartGrid1.Rows.Heights(2)
End Sub

Private Sub Form_Load()
Dim XCoords(1 To 11) As Double
Dim YCoords(1 To 11) As Double
Dim i As Integer
TeeCommander1.Chart = TChart1
XCoords(1) = 2.33
YCoords(1) = 27.778
XCoords(2) = 6.46
YCoords(2) = 62.778
XCoords(3) = 9.71
YCoords(3) = 93.333
XCoords(4) = 19.86
YCoords(4) = 165.566
XCoords(5) = 25.74
YCoords(5) = 204.444
XCoords(6) = 38.21
YCoords(6) = 287.778
XCoords(7) = 46.89
YCoords(7) = 343.33
XCoords(8) = 51.17
YCoords(8) = 371.111
XCoords(9) = 67.7
YCoords(9) = 498.889
XCoords(10) = 74.91
YCoords(10) = 565.556
XCoords(11) = 100
YCoords(11) = 817.32

With TChart1

.Legend.LegendStyle = lsSeries
.Legend.CheckBoxes = True
.Legend.Visible = True
.Axis.Bottom.Labels.MultiLine = True
.Axis.Bottom.Automatic = False
.Axis.Bottom.SetMinMax 0#, 101#
.Axis.Bottom.Title.Caption = "X - Axis"
.Axis.Bottom.Title.Font.Bold = True
.Axis.Left.Title.Caption = "Y - Axis"
.Axis.Left.Title.Font.Bold = True
.Header.Text.Clear
.Header.Text.Add "Test"
.AddSeries scLine
End With
TChart1.Series(0).XValues.Order = loNone
With TChart1.Series(0)
.asLine.Pointer.Visible = True
.asLine.Pointer.Style = psDownTriangle
.asLine.Pointer.VerticalSize = 2
For i = 1 To 11
.AddXY XCoords(i), YCoords(i), CStr(XCoords(i)), vbRed
Next i
.Title = "Test"
End With

TChart1.AddSeries scLine
With TChart1.Series(1)
.SetFunction tfSmoothing
.DataSource = TChart1.Series(0).Name
.Color = vbRed
.FunctionType.asSmoothing.Factor = 10
.Title = "Test"
End With

With TChart1.Series(0)
.ShowInLegend = False
.asLine.LinePen.Visible = False
End With

TChart1.Tools.Add tcMarksTip
TChart1.Tools.Items(0).asMarksTip.Delay = 10
TChart1.Tools.Items(0).asMarksTip.Style = smsValue

ChartGrid1.Chart = TChart1

ChartGrid1.Cols.Widths(0) = 0
ChartGrid1.Cols.Widths(1) = 0
ChartGrid1.Cols.Widths(4) = 0
ChartGrid1.Cols.Widths(5) = 0

For i = 14 To TChart1.Series(1).Count
ChartGrid1.Rows.Heights(i) = 0
Next i

End Sub