πŸ“ˆString Label Line Plot

Introduction

A normal line plot, also called a dot plot, is a graph that shows the frequency, or the number of times, a value occurs in a data set. Line plots are constructed with each value recorded along the horizontal axis, also called the x-axis.

A string label line plot is created when we use custom string labels for the Y Axis instead of the ones calculated internally by the library.

Also, multiple data sets can be passed through the function to create double/multiple line charts.

One Linear Data Set Object
Two Linear Data Set Object
Three Linear Data Set Object
Four Linear Data Set Object

Code Example

According to the number of Linear Data Sets in the list, the plot shows the plotted lines for all the data sets respectively.

If you provide a single linear data set, only one line plot is created. Similarly, if you provide two coordinate sets then two line plots will be created and so on.

Example of a line plot with a list of linear data set objects :-

// X Axis Labels Example
val xAxisLabels = listOf("Jan" , "Feb" , "Mar").toCoordinateSet()

// y Axis Labels Example
val yAxisLabels = mutableListOf(
    Coordinate("Worst"),
    Coordinate("Bad"),
    Coordinate("Average"),
    Coordinate("Good"),
    Coordinate("Excellent")
)

// This function draws the String Line Plot
BasicLinearStrategy.LinePlot(
    linearData = BasicDataStrategy(
        linearDataSets = linearDataSet1, // List<LinearDataSet>
        xAxisLabels = xAxisLabels,
        yAxisLabels = yAxisLabels.toMutableList()
    )
)

Note :- In custom label system the data values are mapped to the index values of the custom label.

For example, in above code, if the value in the data set is 0, its point will be plotted along the Worst label in the Y - axis.

Last updated

Was this helpful?