cvasseng edited this page Dec 19, 2017 · 10 revisions

Sample plugins can be found here.

Data Import Plugins (for importing data)

Data import plugins can be attached using highed.plugins.import.install(...).

These plugins add functionality to the Web Import system.

Example: Register a basic CSV plugin

highed.plugins.import.install('CSV', {
    description: "Standard CSV Import",
    treatAs: 'csv',
    fetchAs: 'text',
    filter: function (data, options, fn) {
        //Validate CSV here... 
        fn(wasInvalid, data);

Example: Register a Socrata plugin

highed.plugins.import.install('Socrata', {
        description: 'Socrata is an open data format commonly used for various government sources. <a href="" target="_blank"></a>',
        treatAs: 'csv',
        fetchAs: 'json',
        defaultURL: '',
        options: {
            includeFields: {
                type: 'string',
                label: 'Fields to include, separate by whitespace',
                default: 'fiscal_year amount_us_millions_'                        
        filter: function (data, options, fn) {
            var csv = [], header = [];

            options.includeFields = highed.arrToObj(options.includeFields.split(' '));

            if (highed.isArr(data)) {

                //Only include things we're interested in
                data = (d) {
                    var r = {};
                    Object.keys(options.includeFields).forEach(function (c) {
                        r[c] = d[c];
                    return r;

                data.forEach(function (row, i) {
                    var rdata = [];                            
                    Object.keys(row).forEach(function (key) {
                        var col = row[key];

                        if (!options.includeFields[key]) {

                        if (i == 0) {


            fn(false, [header.join(',')].concat(csv).join('\n'));

To enable import plugins, add its name to the plugins array supplied when creating either the importer or the editor:

highed.DataImporter(.., {plugins: ['NAME']})
highed.Editor(...,{importer: {plugins: ['NAME']}});

Export plugins

To add export plugins, call highed.plugins.export.install(<name>, <definition>).


highed.plugins.export.install('My Plugin', {
    description: 'Description Test',
    //Custom options - will produce a UI
    options: {
        myOption: {
            type: 'string',
            label: 'Custom Option'
    //Function to call when performing an export
    //Chart is an instance of ChartPreview containing the current chart
    export: function (options, chart, fn) {
       //Do stuff, then call fn(). First argument is an error message or false

Similarly to import plugins, plugins must be explicitly enabled when creating the editor:

highed.Exporter(.., {plugins: ['NAME']})
highed.Editor(...,{exporter: {plugins: ['NAME']}});
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.