gwatts / jquery.sparkline

A plugin for the jQuery javascript library to generate small sparkline charts directly in the browser
http://omnipotent.net/jquery.sparkline/
1.24k stars 278 forks source link

Feature Request: Add greater than threshold to discrete sparkline #35

Open LukeDukem opened 12 years ago

LukeDukem commented 12 years ago

First I would like to say awesome work on the plug-in, it is brilliant! I would love to see the ability to apply a high and low threshold color to the discrete threshold sparkline. This could be done with the addition of a greater than threshold and greater than threshold color. Currently you can only supply a less than threshold which allows you to only color code one set of outlier datapoints high or low depending on how you setup the colors. The datasets I want to display will have high and low outlier data points with an acceptable mid-range which would use the "Line Color" setting.

Cheers, Luke

LukeDukem commented 12 years ago

I have edited the code to support this. I can not commit the code because I only have read only access but here is what I did.

In the defaults for the discrete chart I added the following two options: upperThresholdValue: undefined, upperThresholdColor: undefined,

In the $.fn.sparkline.discrete function I replaced this color = (options.get('thresholdColor') && val < options.get('thresholdValue')) ? options.get('thresholdColor') : options.get('lineColor');

with this if (options.get('thresholdColor') && val < options.get('thresholdValue')) { color = options.get('thresholdColor'); } else if (options.get('upperThresholdColor') && val > options.get('upperThresholdValue')) { color = options.get('upperThresholdColor'); } else { color = options.get('lineColor'); }

gwatts commented 12 years ago

Thanks for the request; I'll take a look soon - In the meantime, the wonderful thing about Github is that you can "fork" your own copy of the project, make and commit your own changes there and then create a pull request to send back to me to consider merging your changes into the main project.

It's really a much better way of working than sending around patches - Checkout: https://help.github.com/articles/fork-a-repo and https://help.github.com/articles/using-pull-requests

LukeDukem commented 12 years ago

Thanks for the response qwatts! I forked the code and would like to add some more features and submit changes but I am a bit confused. Sorry in advance for the really basic and stupid question but how do you actually combine all these .js files to make the final jquery.sparkline.js file? I see the makefile but since JavaScript does not have a standard compiler I do not know what to run the makefile through.

Thanks!

gwatts commented 12 years ago

Just run "make jqs" in the directory the Makefile is located and it will concatenate the files into dist/