Skip to content

Polyline

LucyMu edited this page Dec 17, 2018 · 4 revisions

Polyline is one of the plot types that can be added to the chart.

Polyline creation

To create a polyline you need two series: Xcoords: float seq and Ycoords: float seq which define the points that form the polyline.

let polyline = createPolyline Xcoords Ycoords

Note

Actually the polyline is a record of type FSharpIDD.Plots.Polyline.Plot

You can also create it by explicitly filling up all record fields:

{
		/// Specifies how to annotate the polyline in the legend. Null means that name is not set
		Name: string
		/// Series of X coords of the points that form the polyline
		X: DataSeries
		/// Series of Y coords of the points that form the polyline
		Y: DataSeries
		/// The fill colour of the polyline
		Colour: Colour.Colour
		/// The line thickness of the polyline in pixels
		Thickness: float
		/// The cap (shape of ending) of the line
		LineCap: LineCap
		/// The shape of joins of polyline's strait segments
		LineJoin: LineJoin
}

Configuring polyline style

The polyline has five appearance options that can be configured:

  • Name (as it's seen in a legend)
  • Stroke colour
  • Line thickness (in pixels)
  • Line cap
  • Line join

You can use the following functions of module FSharpIDD.Plots.Polyline to define the options respectively:

  • setName: name:string -> polyline:Plot -> Plot
  • setStrokeColour: colour:Colour.Colour -> polyline:Plot -> Plot
  • setThickness: thickness:Float -> polyline:Plot -> Plot
  • setLineCap: lineCap:CapType -> polyline:Plot -> Plot
  • setLineJoin: lineJoin:LineJoin -> polyline:Plot -> Plot

Example

let curve2 = 
    createPolyline Xseries Yseries2        
    |> setName "Curve 2"
    |> setStrokeColour Colour.Green
    |> setThickness 10.0  

There is also an option to set several of the appearance options with a single setOptions: options:Options -> polyline:Plot -> Plot call.

The convenience of the method is that you can define several but not necessary all options during Options value creation.

Example

let options = Options(Name = "Curve 1", Thickness = 30.0, LineCap=LineCap.Round)
let curve1 =
    createPolyline Xseries Yseries1
    |> setOptions options 

Clone this wiki locally