Skip to main content
Version: 8.3.2

Line

Polar line chartPolar line chart

// Creation of a polar line series
const lineSeries = chart.addLineSeries()

Adding data

lineSeries.setData([
{ angle: 0, amplitude: 50 },
{ angle: 45, amplitude: 60 },
{ angle: 90, amplitude: 35 },
// ...
])

Changing stroke color

const fillRed = new SolidFill({ color: ColorRGBA(255, 0, 0, 255) })
lineSeries.setStrokeStyle((stroke) => stroke.setFillStyle(fillRed))

For more details about style API, please see Styles, colors and fonts.

Changing stroke thickness

lineSeries.setStrokeStyle((stroke) => stroke.setThickness(1))

For more details about style API, please see Styles, colors and fonts.

Dashed line series

lineSeries.setStrokeStyle((stroke) => new DashedLine({
fillStyle: stroke.getFillStyle(),
thickness: stroke.getThickness(),
pattern: StipplePatterns.Dashed,
}))

For more details about style API, please see Styles, colors and fonts.

Auto connect ends

To close loop between first and last data point, use setConnectDataAutomaticallyEnabled method:

lineSeries.setConnectDataAutomaticallyEnabled(true)

User interactions

Custom user interactions can be implemented using the Events API:

lineSeries.addEventListener('click', event => {
console.log('user clicked series', event)
})

To find nearest data point to user interaction, use "solve nearest" functionality (see below).

Solve nearest from location

// Example 1, when user clicks on chart, log closest data point to console
chart.seriesBackground.addEventListener('click', event => {
const nearest = lineSeries.solveNearest(event)
console.log(nearest)
})
// Example 2, solve nearest data point from an axis coordinate
const locationAxis = { angle: 45, amplitude: 10 }
const locationClient = chart.translateCoordinate(locationAxis, chart.coordsClient)
const nearest = series.solveNearest(locationClient)
console.log(nearest)

Interactions with data points

All series support tracking user interactions:

lineSeries.addEventListener('click', (event, hit) => {
// hit.amplitude
// hit.angle
console.log(hit)
})

For all available events to track, please see API