Skip to content
Gordon Smith edited this page Feb 15, 2018 · 4 revisions

Publishing Properties

Internally each visualization has a "publish" section which defines which properties are available to the user of that visualization. For example here are the published properties for the HPCC Pie Chart:

    Pie.prototype.publish("paletteID", "default", "set", "Palette ID", Pie.prototype._palette.switch(),{tags:["Basic","Shared"]});
    Pie.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette",null,{tags:["Intermediate","Shared"]});
    Pie.prototype.publish("outerText", false, "boolean", "Sets label position inside or outside chart",null,{tags:["Basic"]});
    Pie.prototype.publish("innerRadius", 0, "number", "Sets inner pie hole radius as a percentage of the radius of the pie chart",null,{tags:["Basic"]});

Once published each property is available as a setter and a getter for that widget:

    //  Setting properties (can be chained)
    myViz.paletteID("Dark2");
    myViz.outerText(true);
    myViz.innerRadius(33);
    //  Setting properties can also be "chained" for cleaner code
    myViz
        .paletteID("Dark2")
        .outerText(true)
        .innerRadius(33)
    ;
    //  Getting properties
    var paletteID = myViz.paletteID();
    var outerText = myViz.outerText();
    var innerRadius = myViz.innerRadius();

Also these published properties are then "discoverable", which allows the framework to create generic test pages like the [dermatology](todo - url) page. The final benefit of the publish paradigm is that visualizations can be serialized / deserialized this allows the visualizations to user configured and then saved / restored by the end user.

To discover Publish Parameters run the following:

var params = Persist.discover(widget);

or within requireJS

require(["src/chart/Column","src/other/Persist"], function (Column, Persist) {
    var params = Persist.discover(Column);
});