summaryrefslogtreecommitdiff
path: root/jarmon.js
diff options
context:
space:
mode:
authorRichard Wall <richard@aziz>2010-07-13 21:02:03 +0100
committerRichard Wall <richard@aziz>2010-07-13 21:02:03 +0100
commit0f367b91a2d0a30256a7957daacf3a79486d3781 (patch)
treef44dd73b00fd20d64ba2bf7d42ec656f5207f008 /jarmon.js
parent313cefbe020aa1bc48a3f66a1cb8e3f2ff9a21d6 (diff)
Allow overriding of yaxis tickDecimals
Diffstat (limited to 'jarmon.js')
-rw-r--r--jarmon.js39
1 files changed, 27 insertions, 12 deletions
diff --git a/jarmon.js b/jarmon.js
index c6da509..6b29692 100644
--- a/jarmon.js
+++ b/jarmon.js
@@ -362,12 +362,19 @@ jarmon.Chart = function(template, options) {
}
}
+ if(self.options.yaxis.tickDecimals != null) {
+ decimalPlaces = self.options.yaxis.tickDecimals;
+ }
+
var tickMin = minVal - minVal % stepSize;
var tickMax = maxVal - maxVal % stepSize + stepSize
var ticks = [];
for(var j=tickMin; j<=tickMax; j+=stepSize) {
- ticks.push([j*Math.pow(1000, si), j.toFixed(decimalPlaces)]);
+ ticks.push([
+ j*Math.pow(1000, si),
+ j.toFixed(decimalPlaces)
+ ]);
}
self.siPrefix = siPrefixes[si];
@@ -652,6 +659,11 @@ jarmon.ChartCoordinator = function(ui) {
options.append($('<option />').text(jarmon.timeRangeShortcuts[i][0]));
}
+ // Append a custom option for when the user selects an area of the graph
+ options.append($('<option />').text('custom'));
+ // Select the first shortcut by default
+ options.val(jarmon.timeRangeShortcuts[0][0]);
+
options.bind('change', function(e) {
// No point in updating if the user chose custom.
if($(this).val() != 'custom') {
@@ -669,6 +681,7 @@ jarmon.ChartCoordinator = function(ui) {
self.update();
}
);
+
this.ui.find('[name="to_custom"]').bind('change',
function(e) {
self.ui.find('[name="from_standard"]').val('custom');
@@ -677,11 +690,11 @@ jarmon.ChartCoordinator = function(ui) {
self.update();
}
);
+
// Populate a list of tzoffset options if the element is present in the
// template as a select list
-
- options = this.ui.find('select[name="tzoffset"]');
- if(options.length == 1) {
+ tzoffsetEl = this.ui.find('[name="tzoffset"]');
+ if(tzoffsetEl.is('select')) {
var label, val;
for(var i=-12; i<=12; i++) {
label = 'UTC';
@@ -696,13 +709,21 @@ jarmon.ChartCoordinator = function(ui) {
label += '0';
}
label += val + '00';
- options.append($('<option />').attr('value', i*60*60*1000).text(label));
+ tzoffsetEl.append($('<option />').attr('value', i*60*60*1000).text(label));
}
- options.bind('change', function(e) {
+ tzoffsetEl.bind('change', function(e) {
self.update();
});
}
+
+ // Don't set a default tzoffset if one has already been added to the form
+ if(tzoffsetEl.val() === '') {
+ // Default timezone offset based on localtime
+ var tzoffset = -1 * new Date().getTimezoneOffset() * 60 * 1000;
+ tzoffsetEl.val(tzoffset);
+ }
+
// Update the time ranges and redraw charts when the form is submitted
this.ui.find('[name="action"]').bind('click', function(e) {
self.update();
@@ -829,12 +850,6 @@ jarmon.ChartCoordinator.prototype.init = function() {
/**
* Reset all charts and the input form to the default time range - last hour
**/
- // Default timezone offset based on localtime
- var tzoffset = -1 * new Date().getTimezoneOffset() * 60 * 1000;
- this.ui.find('[name="tzoffset"]').val(tzoffset);
-
- // Default to 1 hour
- this.ui.find('[name="from_standard"]').val('last 3 hours');
this.update();
};