graph » series » rules


[ root » graph » series » rules ]

Rules allow you to apply different sets of attributes to only the parts of your chart that meet the prerequisites listed in your rules. For example, if you wanted to apply differently styled guide lines to everything below zero on your scale-y, rules can help you do that. In the demo, notice that the guide lines below zero are red; this is because there is a rule that states that for all scale-y values less than 0, guidelines will appear as solid red lines (with an alpha value of 0.4 for a bit of transparency).

Refer to the Rules Tutorial for more information.

'scale-y': {
  guide: {
    rules: [
        rule: "%v<0",
        'line-color': "red",
        'line-style': "solid"
        rule: "%v=0",
        'line-style': "solid",
        'line-color': "#c7c7c7"

A rule allows you to include logic in order to apply a set of attributes only to certain aspects of your chart that meet the criteria specified within each "rule": group. You can include any number of "rule": groups nested within a "rules": set. Place the desired attribute or attributes within each "rule": group to apply those attributes to the areas that fulfill the requirement. The effect of rules depends largely on the placement of the "rules": set within your JSON code. In the above example, the styling attributes within each rule will be applied to the scale-y guide.

"%c == 2" | "%v <= 0" | "%v > 0" | ...