Get the name of a graph that has been clicked

6 posts, 1 answers
  1. Shane P
    Shane P avatar
    86 posts
    Member since:
    Sep 2012

    Posted 01 Sep 2012 Link to this post

    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
  2. Hristo Germanov
    Admin
    Hristo Germanov avatar
    703 posts

    Posted 03 Sep 2012 Link to this post

    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!
  3. Shane P
    Shane P avatar
    86 posts
    Member since:
    Sep 2012

    Posted 03 Sep 2012 Link to this post

    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.

  4. Hristo Germanov
    Admin
    Hristo Germanov avatar
    703 posts

    Posted 03 Sep 2012 Link to this post

    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!
  5. Shane P
    Shane P avatar
    86 posts
    Member since:
    Sep 2012

    Posted 03 Sep 2012 Link to this post

    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.

  6. Answer
    Hristo Germanov
    Admin
    Hristo Germanov avatar
    703 posts

    Posted 03 Sep 2012 Link to this post

    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!
Back to Top