rubycritic icon indicating copy to clipboard operation
rubycritic copied to clipboard

Complexity vs Churn graph: Log scaling option wise?

Open MyklClason opened this issue 9 years ago • 4 comments

I'm trying to determine how useful it would be to add a log scaling option, though not as a default. Seems like it would be helpful in ensuring that the graph isn't quite as clustered or distorted by outliers. The data would need to be adjusted slightly to avoid log(0) issues. I've done this by manually adjusting the highchart and it seems to work fairly well.

MyklClason avatar May 30 '16 18:05 MyklClason

I'm trying to determine how useful it would be to add a log scaling option, though not as a default.

I believe this might be very useful indeed, would be great if you could give it a shot ;)

troessner avatar May 30 '16 18:05 troessner

I'll give it a shot. I've started working out the design but after a couple hours I ran into a couple issues.

  1. Spent a fair bit of time trying to get around simply incrementing each by one to avoid log(0) issues. The best overall solution seems to be to use a linear scale and simulate log scaling by manipuating the data set and output formatting. So plot them as Math.log10(x+1) but display the values as x via Math.pow(x, 10) (and a bit of rounding). This seems to require converting line 95 in application.js to use pointFormatter instead of pointFormat so you can. However, I've been unable to get it to work at all even after trying code from several places and reading a number of StackOverflow answers. Perhaps my JavaScript skills are lacking. For now I'll just go with the simple +1 method.
  2. I'm still filling in some gaps in my Ruby knowledge and I'm not sure how best to go about adjusting the code to allow toggling between log and linear scaling. I'm currently looking at the initialize function of overview.rb as a place to put a @use_log_scale variable to handle whether they should be used or not. The main reason being that @turbulence_data is also defined here which will need to be adjusted to handle the log(0) issue. The issue is that I'm also trying to working out how that will be set in the first place. Seems I'll have to take a look into the commands section of this repo before I can continue on this front as I've been focusing on the first point so far.

Any tips in were relevant code is would be helpful. This repo isn't exactly small.

MyklClason avatar May 30 '16 22:05 MyklClason

Just leaving this here: http://www.highcharts.com/docs/chart-concepts/axes

Adding type: 'logarithmic' to an axis should have some effect.

guilhermesimoes avatar Oct 19 '16 14:10 guilhermesimoes

@guilhermesimoes: Thanks. I'll have to revisit this a bit, as it's been a few months and I've learned a fair bit more since then. Still probably needs a bit of work to deal with values of zero.

MyklClason avatar Oct 23 '16 01:10 MyklClason