Skip to content

Wrap Prototype

hanzo2001 edited this page May 9, 2016 · 2 revisions

No matter what type of Wrap you are working with, they all have the same prototype interface

Method signature Function
getSelectedRow() if you are listening on a select event then you should call this method to find out what row was selected
getSelectedCol() just like getSelectedRow but returns the selected column
toggleResponsiveness(force) when called without a parameter it will only toggle the availability of the responsiveness feature. If the force parameter is passed then you can either shutdown the feature or activate it if it was not already
refreshData(params) get data from the server and repaint the whole chart with the new data leaving current options unchanged
on(event, handler) shorthand method to attach permanent event listeners to a chart (or until the chart is cleared)
once(event, handler) shorthand method to attach a single one-time event listener that will detach itself once fired (or until the chart is cleared). Very handy for attaching listeners to the ready event
removeRow() select event dependent method that removes a row from the DataView when a row is selected. When the last row is removed, the DataView is reset and all rows repopulate the chart. If the removed row has a label (ie: in Pie and Donut charts, rows are identified by their first column), then this function will return the label of the row and the underlying DataTable index to which it belongs: {label:'string', idx:'number'}
recoverRow(index) re-add a row on index index that was removed with removeRow()

Extending the prototype

To extend the Wrap prototype there is a handy extender on the CreateChart that is bound to Wrap.prototype.

$.fn.CreateChart.extend({
    methodName : function () {
        var wrap = this;
        /* methodBody */
    }
});

Clone this wiki locally