I’d like to develop my own Chart Theme to use in an app, which would be a great way to make sure all charts in the app follow a consistent theme. I know overriding SChartTheme is supported and is *somewhat* documented. However I just can’t get it to work for me when it comes to setting up styles for the series lines in a line chart.
I started by using the demo iPad app to get a theme pretty close to what I wanted, then e-mailed it to me. I received four files, which seemed to be sort of generating the output in two different ways…one way using [theme setValue … forKey] (CustomChartTheme.h, CustomChartTheme.m); the second way Subclassing SChartTheme (ShinobiPlaySChartTheme.h and .m).
After trying I find neither of these sets of files will compile in my iOS7 project. They contain various deprecated methods and syntax. But, I went ahead and imported ShinobiPlayShartTheme.* anyway and did my best to fix all the errors so I could get it to compile. Once compiled, it just crashes my app, though. It *seems* to me that these output files are referencing overrides that have been deprecated in the library?
So with some re-rigging such as removing the setStyles and setColors methods, and only calling the initialiseThemeWithDefaults method from my init, I can get the theme to “do something”, such as setting the background color of the chart and some font sizes. But I can’t get SChartLineSeriesStyle logic to take effect. The documentation mentions in passing to override lineSeriesStyleForSeriesAtIndex. If I do this, my app goes back to crashing again.
What is missing from the picture is an example from your team where an SChartTheme override is done and works (with the latest version of the library and a recent version of iOS). I feel like the architecture of what is designed is perfect, but I’m finding it impossible to implement successfully.
The only thing I’ve done that works is to force the line style in the DataSource, but this is not ideal since the SChartTheme has all the wiring to encapsulate defaults without having to do it “manually” with every chart creation.
Is there an example/blog post/tutorial I’m missing? And BTW, even if there is, IMO the documentation on this feature needs a serious revisit to make it simpler to implement.