ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  XY Chart - User Clicks on Bar - How to Identify Bar - WinChartViewer and VB.net
Posted by Jeff on Jul-12-2015 21:40
Hello All

I'm sure this is a basic question, but have been playing with the product and I can get it
to
do all I need except one thing

I want to be able to let the user click on a bar and then drill down, but in order to do it,
I
need to know the bar that was clicked

So in example1,


Dim data0() As Double = {100, 125, 245, 147, 67}
Dim labels() As String = {"Mon", "Tue", "Wed", "Thur", "Fri"}

I would want to be able to get "Mon" if the user clicks on the Monday bar

In example 2,

Dim data0() As Double = {100, 125, 245, 147, 67}
Dim data1() As Double = {85, 156, 179, 211, 123}
Dim data2() As Double = {97, 87, 56, 267, 157}
Dim labels() As String = {"Mon", "Tue", "Wed", "Thur", "Fri"}

If the user clicks on the one of the Monday bars,
I would want to be able to get "Mon" and data0, data1, or data2 depending on what the
user clicks on

Please help... this is the missing piece of my puzzle!

This is for WinChartDirector using VB.net

  Re: XY Chart - User Clicks on Bar - How to Identify Bar - WinChartViewer and VB.net
Posted by Peter Kwan on Jul-14-2015 05:54
Hi Jeff,

In the original NetWinCharts sample project included in the ChartDirector distribution, when
you clicked on the stacked bar chart, a box will pop-up displaying the xLabel of the bar
(which can be "Mon", "Tue", ....), and also the data set name (which identifies the bar
segment). May be you can use the sample code as a reference.

In brief, when you create the chart, you can also create an image map. In the sample code,
it is like:

viewer.ImageMap = c.getHTMLImageMap("clickable", "", _
            "title='{dataSetName} on {xLabel}: {value} MBytes/hour'")

The image map creates the hot spots for the data representation, which are the bar
segments for a stacked bar chart. When the hot spot is clicked, in the ClickHotSpot event
handler, you can obtain the x-axis label of the bar as e("xLabel") and the data set name as
e("dataSetName").

Hope this can help.

Regards
Peter Kwan

  Re: XY Chart - User Clicks on Bar - How to Identify Bar - WinChartViewer and VB.net
Posted by Jeff on Jul-14-2015 08:19
I saw that, but the code that does that seems to be written in C, not VB

From what I can see, I can get the values doing something like this (just used msgbox to
make them pop up)

Private Sub WinChartViewer1_ClickHotSpot(sender As Object, e As WinHotSpotEventArgs)
Handles WinChartViewer1.ClickHotSpot

        MsgBox(e.AttrValues("xLabel"))
        MsgBox(e.AttrValues("value"))

    End Sub

Does this make sense?

Thanks

  Re: XY Chart - User Clicks on Bar - How to Identify Bar - WinChartViewer and VB.net
Posted by Peter Kwan on Jul-15-2015 00:10
Hi Jeff,

The NetWinCharts sample Visual Studio solution should contain two sample projects, one in
C# called CSharpWinCharts, and the other in VB called VBNetWinCharts.

Your code should work. In my own testing, both e("xLabel") and e.AttrValues("xLabel") will
work. The xLabel identifies the x-axis label of the bar, while the "dataSetName" identifies
which segment the user has clicked for a stacked bar chart. The "value" is the data value of
the clicked segment represented as a text string.

Hope this can help.

Regards
Peter Kwan