How to change the stroke width in a CareKit graph?

269 views Asked by At

I'm trying to display a graph in my app using CareKit-UI. But the default stroke width is huge and I'd like to change it. I tried to use OCKDimensionStyler and overriding the lineWidth1 property, but it failed at updating the graph's main line.

enter image description here

Chart view declaration:

let chartView = OCKCartesianChartView(type: .line)

chartView.headerView.titleLabel.text = "Doxylamine"

chartView.graphView.dataSeries = [
    OCKDataSeries(values: [0, 1, 1, 2, 3, 3, 2], title: "Doxylamine")
]
1

There are 1 answers

0
Clément Cardonnel On

This property isn't editable using an OCKStyler, but by setting the size property of OCKDataSeries.

Here's an updated version of the code:

let chartView = OCKCartesianChartView(type: .line)

chartView.headerView.titleLabel.text = "Doxylamine"

var series = OCKDataSeries(values: [0, 1, 1, 2, 3, 3, 2], title: "Doxylamine")
series.size = 2
chartView.graphView.dataSeries = [series]

This allows you to have multiple series on the same graph, with different stroke width for each series.

enter image description here