Rules

Rules

Methods to add, update and delete rules within your chart.

Note: Requires the zingchart-api-rules.min.js module.

addrule

Adds a rule to a chart.

zingchart.exec('myid', 'addrule', {
    id: 'rule1',
    plotindex: 0,
    rule : '%node-value < 50',
    style: {
        'background-color' : '#f00'
    }
});
AttributeTypeInfo
graphid (optional)Mixed

The id/index of the graph. The default is 0.

"mygraph" | 0 | 1 | ...

idString

The id of the rule to be added.

"rule1" | "rule2"

plotindexNumeric

The index of the plot.

0 | 1 | ...

ruleString

The rule parameters to be added.

"%node-value < 50" | "%v > 50" | ...

styleObject

The style to be applied when the rule parameters are met.

{ ... }

removerule

https://app.zingsoft.com/demos/embed/3IGY00LO
https://app.zingsoft.com/demos/embed/3IGY00LO

Removes a rule from a chart.

zingchart.exec('myid', 'removerule', {
  id: [ 'rule1', 'rule2' ]
});
AttributeTypeInfo
graphid (optional)Mixed

The id/index of the graph. The default is 0.

"mygraph" | 0 | 1 | ...

idMixed

The id or ids of the rule or rules to be removed.

"rule1" | ["rule1,"rule2"]

plotindexNumeric

The index of the plot containing the rules to be removed.

0 | 1 | ...

updaterule

https://app.zingsoft.com/demos/embed/3IGY00LO
https://app.zingsoft.com/demos/embed/3IGY00LO

Updates an existing rule.

zingchart.exec('zc', 'updaterule', {
  id: 'rule1',
  plotindex: 0,
  style: { 'background-color': '\#aaa \#333' }
});
AttributeTypeInfo
graphid (optional)Mixed

The id/index of the graph. The default is 0.

"mygraph" | 0 | 1 | ...

idMixed

The id of the rule to be updated.

"rule1" | "rule2"

plotindexNumeric

The index of the plot.

0 | 1 | ...

ruleString

The rule parameters to be updated.

"%node-value < 50" | "%v > 50" | ...

typeString

The style to be applied when the rule parameters are met.

"background-color" : "#f00" | "border-color" : "#ff0" | ...