Hi Gobing,
Gobing wrote:I added a “Numeric Gauge” series to the TeeChart(ActiveX) control. Then I wrote the following codes in my program:
m_TChart.Series(0).SetValueFormat("10:00");
When I ran my program, I found that the result displayed on the dialog is “10:04”. The last number ‘0’ became ‘4’. I also found that this phenomenon is very common in any number sequence.
The TextFormat is used to print the Value in the series with an specific visual aspect. The numbers in the string represents the number of digits that will be used to print the value, while the character '.' is used to separate the integer part from the decimal part. Other characters such as ':' will be printed as-is.
For example, note the difference between the following codes:
Code: Select all
TChart1.AddSeries scNumericGauge
TChart1.Series(0).asNumericGauge.Value = 25.76
TChart1.Series(0).ValueFormat = "0.000"
Here we are printing the value forcing three decimals after the "coma". Result: 25.760.
Code: Select all
TChart1.AddSeries scNumericGauge
TChart1.Series(0).asNumericGauge.Value = 25.76
TChart1.Series(0).ValueFormat = "0:000"
Here we are forcing to print the value only with integer part (there is no coma) so it will be rounded. And we are printing the value forcing four digits and with a "strange" character between some of the characters. Result: 0:026
Gobing wrote:In “Polar” or “Point” series, I want to know whether the return value is the index of new generated point for the function:
int nIndex = m_TeeChart.Series(0).GetAsPolar().AddPolar()
But I found that, the collection of “nIndex” had several repeated values, when using a loop to generate several points. So I doubted the return value of the function mentioned before is not the index.
Point series: It seems to work fine here with the following code:
Code: Select all
Private Sub Command1_Click()
TChart1.Header.Text.Text = Str(TChart1.Series(0).Add(Rnd * 1000, "", clTeeColor))
End Sub
Private Sub Form_Load()
TChart1.AddSeries scPoint
End Sub
Polar series: The problem here is the order. Each time you add a point to this series, the value list is reordered by angle reassigning the indexes. That's why this code returns non sequential numbers, but the correct index assigned in the value list for the entered new point:
Code: Select all
Private Sub Command1_Click()
TChart1.Header.Text.Text = Str(TChart1.Series(0).asPolar.AddPolar(Rnd * 360, Rnd * 1000, "", clTeeColor))
End Sub
Private Sub Form_Load()
TChart1.AddSeries scPolar
End Sub
If you want you could force not to do this reorder process with this:
Code: Select all
TChart1.Series(0).XValues.Order = loNone
Gobing wrote:I also want to know how to get the index of the specified point in a series?
Maybe I answered this with the answers above. If you want to retrieve the point index (ValueIndex) in an other situation, please, try to specify more in what context are you trying to do that.