0

Good morning all

I'm using ResearchKit default charts to display some steps recorded within HealthKit. This all works awesomely where I'm now at the stage of styling the charts.

One thing I'm unable to do is getting rid of the lighter background thats being applied to each range point. I've attached screenshot of the demo ORKCatalog charts - see Line Graph cell (ignore the grey line - I know how to get rid of that :) )

Code wise (which is probably not that useful) I have the following where stepsChart is my ORKLineGraphChartView...

stepsChart.dataSource = stepChartDataSource
stepsChart.tintColor = UIColor(red: 134/255, green: 74/255, blue: 244/255, alpha: 1)
stepsChart.showsHorizontalReferenceLines = false
stepsChart.showsVerticalReferenceLines = false
stepsChart.axisColor = UIColor.whiteColor()
stepsChart.verticalAxisTitleColor = UIColor.whiteColor()

Any additional info please shout and I'll do my best to improve question / info :)

enter image description here

sukh
  • 328
  • 2
  • 16
  • Do you mean the semi transparent fill under the line? If so, that's not currently supported, but there's an ongoing pull request [here](https://github.com/ResearchKit/ResearchKit/pull/662) which would allow you to specify any color, including `clearColor`. You can either, get that pull request, or if you want a quick hackish workaround, you can modify [this line](https://github.com/ResearchKit/ResearchKit/blob/9f5caad71d474af0014ff4885ee3292fe7434e24/ResearchKit/Charts/ORKLineGraphChartView.m#L105) and specify a transparent color there. – Ricardo Sanchez-Saez May 04 '16 at 12:00
  • @RicardoSánchez-Sáez Yup I believe that is it! I've got ResearchKit through CocoaPods though - not sure how'd I go around getting this in but will figure that out...Feel free to put you comment in as an answer and I'll give you the green tick :) – sukh May 04 '16 at 13:42

1 Answers1

0

UPDATE: The PR has been merged and the feature will be included with the next release.

This is the relevant method: - (UIColor *)graphChartView:(ORKGraphChartView *)graphChartView fillColorForPlotIndex:(NSInteger)plotIndex;


Removing ORKLineGraphChartView's fill is ~~not~~ currently supported, but there's an ongoing pull request which will allow you to specify any color, including [UIColor clearColor].

You can either:

  1. Checkout the branch from that pull request
  2. Modify this line and specify a transparent color there

Given that you are importing ResearchKit through Cocoapods, then perhaps your best option is 2. (look for the file in your Pods/ResearchKit folder). If your project has several developers, make sure the Pods folder is committed to your repo so others get your change.

And be aware that when you update the ResearchKit pod, this modification will be lost. But with luck, the new PR will be in by then.

Ricardo Sanchez-Saez
  • 9,466
  • 8
  • 53
  • 92