]>
git.proxmox.com Git - extjs.git/blob - extjs/packages/charts/src/chart/axis/segmenter/Time.js
2 * @class Ext.chart.axis.segmenter.Time
3 * @extends Ext.chart.axis.segmenter.Segmenter
7 Ext
.define('Ext.chart.axis.segmenter.Time', {
8 extend
: 'Ext.chart.axis.segmenter.Segmenter',
9 alias
: 'segmenter.time',
14 * @cfg {String} step.unit The unit of the step (Ext.Date.DAY, Ext.Date.MONTH, etc).
15 * @cfg {Number} step.step The number of units for the step (1, 2, etc).
16 * If specified, will override the result of {@link #preferredStep}.
20 * unit: Ext.Date.HOUR,
27 renderer: function(value
, context
) {
28 var ExtDate
= Ext
.Date
;
30 switch (context
.majorTicks
.unit
) {
32 return ExtDate
.format(value
, 'Y');
35 return ExtDate
.format(value
, 'Y-m');
38 return ExtDate
.format(value
, 'Y-m-d');
41 return ExtDate
.format(value
, 'Y-m-d\nH:i:s');
44 from: function(value
) {
45 return new Date(value
);
48 diff: function(min
, max
, unit
) {
57 return Ext
.Date
.diff(min
, max
, unit
);
60 updateStep: function() {
61 var axis
= this.getAxis();
63 if (axis
&& !this.isConfiguring
) {
68 align: function(date
, step
, unit
) {
69 if (unit
=== 'd' && step
>= 7) {
70 date
= Ext
.Date
.align(date
, 'd', step
);
71 date
.setDate(date
.getDate() - date
.getDay() + 1);
76 return Ext
.Date
.align(date
, unit
, step
);
80 add: function(value
, step
, unit
) {
81 return Ext
.Date
.add(new Date(value
), unit
, step
);
87 steps
: [1, 2, 5, 10, 20, 50, 100, 200, 500]
102 unit
: Ext
.Date
.MINUTE
,
103 steps
: [1, 5, 15, 30]
106 unit
: Ext
.Date
.SECOND
,
107 steps
: [1, 5, 15, 30]
110 unit
: Ext
.Date
.MILLI
,
111 steps
: [1, 2, 5, 10, 20, 50, 100, 200, 500]
117 * Takes a time interval and figures out what is the smallest nice number of which
118 * units (years, months, days, etc.) that can fully encompass that interval.
122 * @return {String} return.unit The unit.
123 * @return {Number} return.step The number of units.
125 getTimeBucket: function(min
, max
) {
126 var buckets
= this.timeBuckets
,
132 for (i
= 0; i
< buckets
.length
; i
++) {
133 unit
= buckets
[i
].unit
;
134 unitCount
= this.diff(min
, max
, unit
);
137 steps
= buckets
[i
].steps
;
139 for (j
= 0; j
< steps
.length
; j
++) {
142 if (unitCount
<= step
) {
155 // If the interval is smaller then one millisecond ...
157 // ... we can't go smaller than one millisecond.
159 unit
: Ext
.Date
.MILLI
,
167 preferredStep: function(min
, estStepSize
) {
168 var step
= this.getStep();
172 : this.getTimeBucket(
174 new Date(+min
+ Math
.ceil(estStepSize
))