﻿/**
* Copyright (c) 2009 Chris Leonello
* jqPlot is currently available for use in all personal or commercial projects 
* under both the MIT and GPL version 2.0 licenses. This means that you can 
* choose the license that best suits your project and use it accordingly. 
*
* Although not required, the author would appreciate an email letting him 
* know of any substantial use of jqPlot.  You can reach the author at: 
* chris dot leonello at gmail dot com or see http://www.jqplot.com/info.php .
*
* If you are feeling kind and generous, consider supporting the project by
* making a donation at: http://www.jqplot.com/donate.php .
*/
(function(a) { a.jqplot.CategoryAxisRenderer = function() { a.jqplot.LinearAxisRenderer.call(this) }; a.jqplot.CategoryAxisRenderer.prototype = new a.jqplot.LinearAxisRenderer(); a.jqplot.CategoryAxisRenderer.prototype.constructor = a.jqplot.CategoryAxisRenderer; a.jqplot.CategoryAxisRenderer.prototype.init = function(e) { a.extend(true, this, { tickOptions: { formatString: "%d"} }, e); var b = this._dataBounds; for (var f = 0; f < this._series.length; f++) { var g = this._series[f]; var h = g.data; for (var c = 0; c < h.length; c++) { if (this.name == "xaxis" || this.name == "x2axis") { if (h[c][0] < b.min || b.min == null) { b.min = h[c][0] } if (h[c][0] > b.max || b.max == null) { b.max = h[c][0] } } else { if (h[c][1] < b.min || b.min == null) { b.min = h[c][1] } if (h[c][1] > b.max || b.max == null) { b.max = h[c][1] } } } } }; a.jqplot.CategoryAxisRenderer.prototype.createTicks = function() { var y = this._ticks; var v = this.ticks; var B = this.name; var x = this._dataBounds; var p, w; var n, q; var d, c; var b, r; if (v.length) { this.min = 0.5; this.max = v.length + 0.5; var h = this.max - this.min; this.numberTicks = 2 * v.length + 1; for (r = 0; r < v.length; r++) { b = this.min + 2 * r * h / (this.numberTicks - 1); var f = new this.tickRenderer(this.tickOptions); f.showLabel = false; f.showMark = true; f.setTick(b, this.name); this._ticks.push(f); var f = new this.tickRenderer(this.tickOptions); f.label = v[r]; f.showLabel = true; f.showMark = false; f.showGridline = false; f.setTick(b + 0.5, this.name); this._ticks.push(f) } var f = new this.tickRenderer(this.tickOptions); f.showLabel = false; f.showMark = true; f.setTick(b + 1, this.name); this._ticks.push(f) } else { if (B == "xaxis" || B == "x2axis") { p = this._plotDimensions.width } else { p = this._plotDimensions.height } if (this.min != null && this.max != null && this.numberTicks != null) { this.tickInterval = null } if (this.min != null && this.max != null && this.tickInterval != null) { if (parseInt((this.max - this.min) / this.tickInterval, 10) != (this.max - this.min) / this.tickInterval) { this.tickInterval = null } } var u = []; var z = 0; var n = 0.5; var q, A; for (var r = 0; r < this._series.length; r++) { var g = this._series[r]; for (var o = 0; o < g.data.length; o++) { if (this.name == "xaxis" || this.name == "x2axis") { A = g.data[o][0] } else { A = g.data[o][1] } if (a.inArray(A, u) == -1) { z += 1; u.push(A) } } } this.ticks = u; for (var r = 0; r < this._series.length; r++) { var g = this._series[r]; for (var o = 0; o < g.data.length; o++) { if (this.name == "xaxis" || this.name == "x2axis") { A = g.data[o][0] } else { A = g.data[o][1] } var k = a.inArray(A, u) + 1; if (this.name == "xaxis" || this.name == "x2axis") { g.data[o][0] = k } else { g.data[o][1] = k } } } q = z + 0.5; if (this.numberTicks == null) { this.numberTicks = 2 * z + 1 } var h = q - n; this.min = n; this.max = q; var l = 0; var e = parseInt(3 + p / 20, 10); var m = parseInt(z / e, 10); if (this.tickInterval == null) { this.tickInterval = h / (this.numberTicks - 1) } for (var r = 0; r < this.numberTicks; r++) { b = this.min + r * this.tickInterval; var f = new this.tickRenderer(this.tickOptions); if (r / 2 == parseInt(r / 2, 10)) { f.showLabel = false; f.showMark = true } else { if (m > 0 && l < m) { f.showLabel = false; l += 1 } else { f.showLabel = true; l = 0 } f.label = f.formatter(f.formatString, u[(r - 1) / 2]); f.showMark = false; f.showGridline = false } if (!this.showTicks) { f.showLabel = false; f.showMark = false } else { if (!this.showTickMarks) { f.showMark = false } } f.setTick(b, this.name); this._ticks.push(f) } } } })(jQuery);
