Skip to content

KnockoutJS: Polyline plot

lucymukh edited this page Dec 19, 2019 · 2 revisions

Polyline

polylineplot

You may want to read about general approach to the KnockoutJS support in IDD here. This page is about specific plot type.

To create polyline you must create a plot with data-idd-plot="polyline" attribute and two mandatory bindings.

Mandatory bindings:

  • iddX (number array) - horizontal coordinates data series
  • iddY (number array) - vertical coordinates data series

Remark: Length of iddX and iddY must be the same. The plot will not be drawn until the length is the same.

Optional bindings:

  • iddStroke (string) - a color of the polyline (e.g. "red","#FF0000",...)

  • iddThickness (nymber) - a thickness of the polyline

  • iddLineCap (string) - the shape of polyline ends

    Allowed values:

    • "butt"
    • "round"
    • "square"
  • iddLineJoin (string) - the visual form of joints between different polyline segments

    Allowed values:

    • "bevel"
    • "round"
    • "miter"

You may try to open and explore the interactive sample at the bottom of the page to see the visual difference between the options presented above.

Source code: View

    <div id="chart" data-idd-plot="chart">
        <div data-idd-plot="polyline" data-bind="iddX: X, iddY: Y, iddiddStroke: ActiveColour, iddLineJoin: 'round'" />
    </div>

Source code:View Model

    ko.applyBindings({
        X: ko.observable([1,2,3]),
        Y: ko.observable([2,3,1]),
        ActiveColour: "Red"
    });

Interactive sample

Clone this wiki locally