Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am generating Gantt chart using MS chart stacked bar chart.
I am using 3 series in the chart.
After generating the chart when I click on any of the series, it should give the information of the series.
For that I need to get the series name after clicking.

Is there any way to get the series name and chartarea name which I clicked.
Posted

1 solution

I tried myself and got the answer as below

We need to use Mouseclick evnet not the just clickevnet.

Example: In below example we will get series name which is clicked in clkdGraphSeries

Protected Friend Sub ProdChart_Click(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles ProdChart.MouseClick

Dim clkdGraphPoint As Integer = Nothing
Dim clkdGraphSeries As String = Nothing
Dim clkdGraphChartArea As String = Nothing

Try

Dim result As DataVisualization.Charting.HitTestResult = ProdChart.HitTest(e.X, e.Y)


clkdGraphPoint = result.PointIndex

If (clkdGraphPoint < 0) Then
App.MsgBox("Click on the drawn graph", MsgBoxStyle.Information)
Exit Sub
End If

clkdGraphSeries = result.Series.Name

clkdGraphChartArea = result.ChartArea.Name

Catch ex As Exception
App.ErrorAdd(Me,ex.Message)
End Try

End Sub

In the same passion you can get all the properties of the graph.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900