Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @domoinc/notifier with all npm packages installed. Try it out:

var notifier = require("@domoinc/notifier")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@domoinc/notifier v2.2.4

Notifier - Domo Widget

Notifier

This component notifies the user if bad data is passed into a widget.

Config

this._config = {
    height: {                                       // Name of config Item
        name: 'Chart Height',                       // [Optional] - This is the human readable name for this config item in Title Case. It should only be set if this is something that an end user would want to configure.
        description: 'Height of the chart.',        // Human readable description.
        type: 'number',                             // [Optional] - Value type. Will be used for UI elements in future.
        value: 100                                  // Default value for item
    },
    width: {
        name: 'Chart Width'
        description: 'Width of the chart.',
        type: 'number',
        value: 100
    },
    chartName: {
        description: 'Name of chart for Reporting.',
        type: 'string',
        value: 'Notifier'
    }
};

Interface

//----------------------------------------------------------------------------------
// Notifier Interface
//
// In trumping order:
//
// WARNs are always consoled, NO_DATE trumps DISCARDED_VALID_DATA,
// SAMPLE_DATA trumps NO_DATA, and FAIL trumps all.
//----------------------------------------------------------------------------------

//ChartName, MessageType, 'Custom Message', 'Column Names, ...', [[Data], ...]

chart.appendMessage('Notifier', 'WARN', 'Warning: Invalid Data', "Schema", [[Bad Data],...]);
chart.appendMessage("Notifier", "DISCARDED_VALID_DATA", "Why", "Schema", [[Discarded Data], ...]);
chart.appendMessage("Notifier", "NO_DATA", "No Data", "", []);
chart.appendMessage("Notifier", "SAMPLE_DATA", "Sample Data", "", []);
chart.appendMessage('Notifier', 'FAIL', 'O, Something Went Wrong!', "", []);

Create Widget

//Initialze the widget
var chart = d3.select("#vis")
    .append("svg")
    .attr({
        "width":800,
        "height":800
    })
    .append("g")
    .attr("transform", "translate(50,50)")
    .chart("Notifier")
    .config({
        'width':250,
        'height':function(){return 250;}
    });

//Render the chart with data

//ChartName, MessageType, 'Custom Message', 'Column Names, ...', [[Bad Data], ...]
chart.appendMessage("Notifier", "NO_DATA", "No Data", "", []);
chart.appendMessage("Notifier", "SAMPLE_DATA", "No Data", "", []);
chart.appendMessage('Notifier', 'WARN', 'Warning', "", []);
chart.appendMessage('Notifier', 'FAIL', 'O, Something Went Wrong!', "", []);

//var allMessages = {};
//    allMessages.warningMessages = [{chartName:"Notifier", type:"WARN", message:"Warning", expectedDataFormat:"", data:[]}];
//    allMessages.failMessages = [{chartName:"Notifier", type:"FAIL", message:"Fail", expectedDataFormat:"", data:[]}];
//    allMessages.noDataMessages = [{chartName:"Notifier", type:"NO_DATA", message:"No Data", expectedDataFormat:"", data:[]}];
//    allMessages.sampleDataMessages = [{chartName:"Notifier", type:"SAMPLE_DATA", message:"Sample Data", expectedDataFormat:"", data:[]}];
//chart.appendMessages(allMessages);

chart.showMessage(true);
chart.draw();


//chart.clearMessages();
//chart.draw();

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free