jQWidgets Forums

jQuery UI Widgets Forums Chart Data adapter, changing URL?

This topic contains 1 reply, has 1 voice, and was last updated by  jondecker76 11 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Data adapter, changing URL? #23180

    jondecker76
    Member

    I have made a script which expects a parameter describing what dataset should be returned, and returns the data in JSON format:

    I.e. trenddata.php?units= day, trenddata.php?units=week, trenddata.php?units=month
    Note that each “units” type returns a different number of data results.

    The script works fine when run from directly from the browser.

    Now what I’m trying to do, is when a certain button from a buttongroup is pressed, is change the source.url appropriately, and refresh the data for the chart to display accordingly. i display an alert that shows that the source.url changed as it should, but the chart does not change… See code:

    $('#buttonsTrend').on('buttonclick', function (event) {
    var clickedButton = event.args.button;
    //$("#eventsLog").text("Clicked: " + clickedButton[0].id);
    source.url="trenddata.php?units="+clickedButton[0].id;
    alert(source.url);
    source.localdata = generateData(),
    dataAdapter.dataBind();
    });

    any idea on how to get this to work as expected?

    thanks

    Data adapter, changing URL? #23185

    jondecker76
    Member

    Disregard, I was able to get this to work finally. Here is what I did:

    			// Change trend depending on which button was clicked                
    $('#buttonsTrend').on('buttonclick', function (event) {
    var clickedButton = event.args.button;
    source.url="trenddata.php?units="+clickedButton[0].id;
    var dataAdapter= new $.jqx.dataAdapter(source);
    $('#trendDash').jqxChart({source: dataAdapter});
    $('#trendDash').jqxChart({description: "Last "+clickedButton[0].id});
    });
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.