jQuery UI Widgets Forums Chart Get XAxisText with Click Event

This topic contains 1 reply, has 2 voices, and was last updated by  Vladimir 9 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Get XAxisText with Click Event #75747

    minsu0806
    Participant

    with this demo :http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxchart/javascript_chart_events.htm?arctic

    I want to get “Monday”. When Click the Bar on Monday>Erica.

    goal: print String=> Last Event: click,XaxisText: Monday, Serie DataField: Keith, Value: 30

    Can I get it?

    Get XAxisText with Click Event #75752

    Vladimir
    Participant

    Hello minsu0806,

    The event argument event.args.elementIndex holds the information of the records index. So in this case it would return 0, for the first day (e.g. Monday).
    So depending on your implementation you can map this value to your desired result. In this particular example you can have something like this:

       function myEventHandler(event) {
                    var daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
                    var day = '';
                    if (event.args.elementIndex !== undefined) {
                        day = daysOfWeek[event.args.elementIndex];
                    }
                    var eventData = '<div><b>Last Event: </b>' + event.type + '<b>, XaxisText: </b>' + day + '<b>, Serie DataField: </b>' + event.args.serie.dataField + '<b>, Value: </b>' + event.args.elementValue + "</div>";
                    if (event.type == 'toggle')
                        eventData = '<div><b>Last Event: </b>' + event.type + '<b>, Serie DataField: </b>' + event.args.serie.dataField + '<b>, visible: </b>' + event.args.state + "</div>";
                    $('#eventText').html(eventData);
                };

    Best Regards,
    Vladimir

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.