- // take all values from all datasets and find max and min
- var map = PlotKit.Base.map;
- var items = PlotKit.Base.items;
- var itemgetter = MochiKit.Base.itemgetter;
- var collapse = PlotKit.Base.collapse;
- var listMin = MochiKit.Base.listMin;
- var listMax = MochiKit.Base.listMax;
- var isNil = MochiKit.Base.isUndefinedOrNull;
-
-
- var all = collapse(map(itemgetter(1), items(this.datasets)));
- if (isNil(this.options.xAxis)) {
- if (this.options.xOriginIsZero)
- this.minxval = 0;
- else
- this.minxval = listMin(map(parseFloat, map(itemgetter(0), all)));
-
- this.maxxval = listMax(map(parseFloat, map(itemgetter(0), all)));
- }
- else {
- this.minxval = this.options.xAxis[0];
- this.maxxval = this.options.xAxis[1];
- this.xscale = this.maxval - this.minxval;
- }
-
- if (isNil(this.options.yAxis)) {
- if (this.options.yOriginIsZero)
- this.minyval = 0;
- else
- this.minyval = listMin(map(parseFloat, map(itemgetter(1), all)));
-
- this.maxyval = listMax(map(parseFloat, map(itemgetter(1), all)));
+ this.minxval = this.maxxval = null;
+ for (var name in this.datasets) {
+ var series = this.datasets[name];
+ var x1 = series[0][0];
+ if (!this.minxval || x1 < this.minxval) this.minxval = x1;
+
+ var x2 = series[series.length - 1][0];
+ if (!this.maxxval || x2 > this.maxxval) this.maxxval = x2;