Created
January 21, 2015 16:57
-
-
Save edmundoa/a5bad160026c0f2c230e to your computer and use it in GitHub Desktop.
Rickshaw #461 workaround
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rickshaw issue: https://github.com/shutterstock/rickshaw/issues/461 | |
// Original code: https://github.com/Graylog2/graylog2-web-interface/blob/master/app/assets/javascripts/rickshaw-helper.js | |
SmartResolutionBarRenderer = Rickshaw.Class.create(Rickshaw.Graph.Renderer.Bar, { | |
defaults: function($super) { | |
var defaults = Rickshaw.extend( $super(), { | |
gapSize: 0.05, | |
unstack: false, | |
resolution: 'minute' | |
} ); | |
delete defaults.tension; | |
return defaults; | |
}, | |
initialize: function($super, args) { | |
args = args || {}; | |
this.resolution = args.resolution || this.resolution; | |
$super(args); | |
}, | |
_frequentInterval: function(data) { | |
var resolutionDuration = moment.duration(1, this.resolution); | |
return { count: 100, magnitude: resolutionDuration.asSeconds() }; | |
} | |
}); | |
var graph = new Rickshaw.Graph( { | |
element: foo, | |
renderer: SmartResolutionBarRenderer, | |
resolution: 'minute', | |
series: [ {...} ] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment