This is a migrated thread and some comments may be shown as answers.

Get the name of a graph that has been clicked

5 Answers 208 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Shane P
Top achievements
Rank 1
Shane P asked on 01 Sep 2012, 12:41 PM
I am trying to get the chart to work in a way I need.

Lets say I have the following chat

@(Html.Kendo().Chart()
                  .Name("chart")
                  .Title("Number 1")
                  .Legend(legend => legend
                                        .Position(ChartLegendPosition.Bottom)
                  )
                  .Series(series => {
                                        //  series.Column(new double[] { 15.7, 16.7, 20, 23.5, 26.6 }).Name("World");
                                        series.Column(new double[] { 67.96, 68.93, 75, 74, 78,77,12,19,99,79 }).Name("Rating");
                  })
                  .CategoryAxis(axis => axis
                                            .Categories("1", "2", "3", "4", "5","6","7","8","9","10")
                  )
                  .ValueAxis(axis => axis
                                         .Numeric().Labels(labels => labels.Format("{0}"))
                  )
                  .Tooltip(tooltip => tooltip
                                          .Visible(true)
                                          .Format("{0}")
                  ).Events(events => events
        .SeriesClick("onSeriesClick")
    )
                  )


As you can see I have the series click event hooked up. If I click on the series I can see
Object
category: "6"
dataItem: 77
element: jQuery.fn.jQuery.init[1]
isDefaultPrevented: function (){return g}
preventDefault: function (){g=!0}
sender: n.extend.init
series: Object
value: 77
__proto__: Object
I have clicked on the 6th column within the graph to get the above result.

Can I get access to the graph's name that has been clicked on? I am building a page that could have many graphs on it so I am wanting to build a reusable function.
Ideally somehow I would like to get the name of the graph that's been clicked on.


Thank you

5 Answers, 1 is accepted

Sort by
0
Hristo Germanov
Telerik team
answered on 03 Sep 2012, 08:00 AM
Hello Shane Price, 

In this event we give you information about the point that you click. You can get the chart options from this.options. For example:

this.options.title.text
Note: "this" is the chart widget in all chart's events.

All the best,
Hristo Germanov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Shane P
Top achievements
Rank 1
answered on 03 Sep 2012, 09:26 AM
Thanks Hristo,

That works if I want to get the title however how do I get the name of graph. I have looked into all the properties and I can see name but its not rendering the correct name I provide.

0
Hristo Germanov
Telerik team
answered on 03 Sep 2012, 10:10 AM
Hello Shane Price,

I can't understand what is a graph. Could you tell me what is a graph and what is this name?

Regards,
Hristo Germanov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Shane P
Top achievements
Rank 1
answered on 03 Sep 2012, 10:25 AM
Sorry I meant Chart not graph :( I have a kendo chart created like

         @(Html.Kendo().Chart()
    .Name("question1")
    .Title("Do you hate work on a Monday?")
    
    .Legend(legend => legend
        .Position(ChartLegendPosition.Bottom)
    )
    .Series(series => {
        series.Pie(new dynamic[] {
            new { category = "Yes", value = 80 },
            new { category = "No", value = 20 }               
        });
    })
    .Tooltip(tooltip => tooltip
        .Visible(true)
        .Format("{0}%")
    ).Events(events => events
        .SeriesClick("onSeriesClick")
    )
)
Your earlier example showed how to get the title of the chart but how do I get the name of the chart.

I looked into firebug and could see the title but I have hunted through and can't see any properties for the name.

Sorry for the confusion.

0
Accepted
Hristo Germanov
Telerik team
answered on 03 Sep 2012, 11:13 AM
Hello Shane Price,

You can get the Id of the chart with this.wrapper.attr("id").

Regards,
Hristo Germanov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Charts
Asked by
Shane P
Top achievements
Rank 1
Answers by
Hristo Germanov
Telerik team
Shane P
Top achievements
Rank 1
Share this question
or