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

Reversing order of y-axis values #102

Open das-shrike opened 10 years ago

das-shrike commented 10 years ago

The standard behaviour of sparkline is that values grow from lowest to highest along the vertical axis, i.e. (0,0) at bottom left.

Feature request: It would be great to have it the other way round, i.e., that the lowest value starts at the top and the highest value is at the bottom. (0,0) would, thus, be in the upper left corner.

(I tried a workaround by multiplying with -1 but the result is not satisfying.)

512banque commented 10 years ago

+1

ankurraiyani commented 9 years ago

Any update on this feature? I too need reverse Y-axis feature.

khaosdoctor commented 8 years ago

+1

khaosdoctor commented 8 years ago

@das-shrike I managed to work around this by reversing the chart and unreversing the tooltip using the formatter.

  1. Multiplied everything by -1 and added to the sparkline chart
  2. Added this:
tooltipFormatter: function(sparkline, options, point) {
            return Math.abs(point.y)+'º '+Math.abs(options.userOptions.tooltipValueLookups.points.map[point.y]) + ' pts.';
        },

To the options, which returns Xº Z pts. (in my case that just did it).