系列活動(dòng)
TeeChart for .NET制圖控件提供了一套出色的通用組件套件,可滿足無(wú)數(shù)的制圖要求,也針對(duì)重要的垂直領(lǐng)域,例如金融,科學(xué)和統(tǒng)計(jì)領(lǐng)域。制圖控件提供了一套出色的通用組件套件,可滿足無(wú)數(shù)的制圖要求,也針對(duì)重要的垂直領(lǐng)域,例如金融,科學(xué)和統(tǒng)計(jì)領(lǐng)域。
前一節(jié)介紹了系列事件的一些用法。本節(jié)將展示一些其他用途。
加入官方社群740060302,歡迎相互交流
OnClickSeries
你可以使用OnClickSeries事件來(lái)獲取關(guān)于一個(gè)序列的幾乎任何信息(參見(jiàn)章節(jié),訪問(wèn)序列值)。
這些示例適用于具有日期時(shí)間數(shù)據(jù)的系列,例如這些測(cè)試值可用于以下事件示例:
[C#]
private void button1_Click(object sender, System.EventArgs e) { Random rnd = new Random(); line1.XValues.DateTime = true; line1.Pointer.Visible = true; line1.Add(DateTime.Parse("25/12/2002 10:30:00"),rnd.Next(100),"", Color.Red); line1.Add(DateTime.Parse("25/12/2002 22:30:00"),rnd.Next(100),"", Color.Red); line1.Add(DateTime.Parse("26/12/2002 09:20:00"),rnd.Next(100),"", Color.Red); line1.Add(DateTime.Parse("26/12/2002 23:30:00"),rnd.Next(100),"", Color.Red); line1.Add(DateTime.Parse("27/12/2002 11:10:00"),rnd.Next(100),"", Color.Red); line1.Add(DateTime.Parse("27/12/2002 20:15:00"),rnd.Next(100),"", Color.Red); line1.Add(DateTime.Parse("28/12/2002 08:15:00"),rnd.Next(100),"", Color.Red); line1.Add(DateTime.Parse("28/12/2002 21:45:00"),rnd.Next(100),"", Color.Red); line1.Add(DateTime.Parse("29/12/2002 12:45:00"),rnd.Next(100),"", Color.Red); line1.Add(DateTime.Parse("29/12/2002 22:05:00"),rnd.Next(100),"", Color.Red); line1.HorizAxis = Steema.TeeChart.Styles.HorizontalAxis.Top; } private void tChart1_ClickSeries(object sender, Steema.TeeChart.Styles.Series s, int valueIndex, System.Windows.Forms.MouseEventArgs e) { //The below will show the Value of the nearest Point, not the exact Axis value at the clicked X and Y. MessageBox.Show("Date is: " + DateTime.FromOADate(line1.XValues[valueIndex]) + " Value is: " + line1.YValues[valueIndex]); }
點(diǎn)擊復(fù)制
[VB.Net]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim rnd As New Random() Line1.XValues.DateTime = True Line1.Pointer.Visible = True Line1.Add(DateTime.Parse("25/12/2002 10:30:00"), rnd.Next(100), "", Color.Red) Line1.Add(DateTime.Parse("25/12/2002 22:30:00"), rnd.Next(100), "", Color.Red) Line1.Add(DateTime.Parse("26/12/2002 09:20:00"), rnd.Next(100), "", Color.Red) Line1.Add(DateTime.Parse("26/12/2002 23:30:00"), rnd.Next(100), "", Color.Red) Line1.Add(DateTime.Parse("27/12/2002 11:10:00"), rnd.Next(100), "", Color.Red) Line1.Add(DateTime.Parse("27/12/2002 20:15:00"), rnd.Next(100), "", Color.Red) Line1.Add(DateTime.Parse("28/12/2002 08:15:00"), rnd.Next(100), "", Color.Red) Line1.Add(DateTime.Parse("28/12/2002 21:45:00"), rnd.Next(100), "", Color.Red) Line1.Add(DateTime.Parse("29/12/2002 12:45:00"), rnd.Next(100), "", Color.Red) Line1.Add(DateTime.Parse("29/12/2002 22:05:00"), rnd.Next(100), "", Color.Red) Line1.HorizAxis = Steema.TeeChart.Styles.HorizontalAxis.Top End Sub Private Sub TChart1_ClickSeries(ByVal sender As Object, ByVal s As Steema.TeeChart.Styles.Series, ByVal valueIndex As Integer, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TChart1.ClickSeries 'The below will show the Value of the nearest Point, not the exact Axis value at the clicked X and Y. MsgBox("Date is: " & DateTime.FromOADate(Line1.XValues(valueIndex)) _ & " Value is: " & Line1.YValues(valueIndex)) End Sub
點(diǎn)擊復(fù)制
OnGetSeriesPointerStyle
對(duì)于那些使用TChart指針的系列,你可以使用OnGetSeriesPointer事件訪問(wèn)和修改指針:
如果該點(diǎn)高于上一個(gè)三角形,則繪制上一個(gè)三角形;如果該點(diǎn)低于上一個(gè)三角形,則繪制下一個(gè)三角形,以此類(lèi)推。
[C#]
private void line1_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e) { if(e.ValueIndex > 0) { if(line1.YValues[e.ValueIndex] > line1.YValues[e.ValueIndex - 1]) { e.Style = Steema.TeeChart.Styles.PointerStyles.Triangle; } else if(line1.YValues[e.ValueIndex] < line1.YValues[e.ValueIndex - 1]) { e.Style = Steema.TeeChart.Styles.PointerStyles.DownTriangle; } else { e.Style = Steema.TeeChart.Styles.PointerStyles.Diamond; } } else { e.Style = Steema.TeeChart.Styles.PointerStyles.Diamond; } }
點(diǎn)擊復(fù)制
[VB.Net]
Private Sub Line1_GetPointerStyle(ByVal series As Steema.TeeChart.Styles.CustomPoint, ByVal e As Steema.TeeChart.Styles.GetPointerStyleEventArgs) Handles Line1.GetPointerStyle If e.ValueIndex > 0 Then If (Line1.YValues(e.ValueIndex) > Line1.YValues(e.ValueIndex - 1)) Then e.Style = Steema.TeeChart.PointerStyles.Triangle ElseIf (Line1.YValues(e.ValueIndex) < Line1.YValues(e.ValueIndex - 1)) Then e.Style = Steema.TeeChart.Styles.PointerStyles.DownTriangle Else e.Style = Steema.TeeChart.Styles.PointerStyles.Diamond End If Else e.Style = Steema.TeeChart.Styles.PointerStyles.Diamond End If End Sub
點(diǎn)擊復(fù)制
OnGetSeriesMark
使用OnGetSeriesMark事件在運(yùn)行時(shí)修改標(biāo)記內(nèi)容。以下代碼根據(jù)相對(duì)于最后一個(gè)的值改變MarkText;
TeeChart支持通過(guò)DragMarks工具拖動(dòng)重疊的標(biāo)記:
[C#]
private void line1_GetSeriesMark(Steema.TeeChart.Styles.Series series, Steema.TeeChart.Styles.GetSeriesMarkEventArgs e) { if(e.ValueIndex > 0) { if(line1.YValues[e.ValueIndex] > line1.YValues[e.ValueIndex - 1]) { e.MarkText = e.MarkText + " (Up)"; } else if(line1.YValues[e.ValueIndex] < line1.YValues[e.ValueIndex - 1]) { e.MarkText = e.MarkText + " (Down)"; } else { e.MarkText = e.MarkText + " (No Change)"; } } }
點(diǎn)擊復(fù)制
[VB.Net]
Private Sub Line1_GetSeriesMark(ByVal series As Steema.TeeChart.Styles.Series, ByVal e As Steema.TeeChart.Styles.GetSeriesMarkEventArgs) Handles Line1.GetSeriesMark If (e.ValueIndex > 0) Then If (Line1.YValues(e.ValueIndex) > Line1.YValues(e.ValueIndex - 1)) Then e.MarkText = e.MarkText + " (Up)" ElseIf (Line1.YValues(e.ValueIndex) < Line1.YValues(e.ValueIndex - 1)) Then e.MarkText = e.MarkText + " (Down)" End If Else e.MarkText = e.MarkText + " (No Change)" End If End Sub
點(diǎn)擊復(fù)制
最后兩個(gè)事件所產(chǎn)生的圖表外觀如下:
如需下載產(chǎn)品TeeChart for NET ,請(qǐng)點(diǎn)擊產(chǎn)品名進(jìn)入下載頁(yè)面