Browse Source

Merge remote-tracking branch 'origin/develop' into develop

Conflicts:
	dist/vis.js
v3_develop
Alex de Mulder 9 years ago
parent
commit
0c34e3bb02
8 changed files with 74 additions and 25 deletions
  1. +5
    -0
      HISTORY.md
  2. +1
    -1
      dist/vis.map
  3. +9
    -9
      dist/vis.min.js
  4. +16
    -0
      docs/graph2d.html
  5. +20
    -0
      docs/timeline.html
  6. +12
    -13
      lib/timeline/TimeStep.js
  7. +7
    -2
      lib/timeline/component/TimeAxis.js
  8. +4
    -0
      test/timeline.html

+ 5
- 0
HISTORY.md View File

@ -14,6 +14,11 @@ http://visjs.org
- Added property `length` holding the total number of items to the `DataSet` - Added property `length` holding the total number of items to the `DataSet`
and `DataView`. and `DataView`.
### Timeline
- Implemented option `timeAxis: {scale: string, step: number}` to set a
fixed scale.
## 2015-01-16, version 3.9.1 ## 2015-01-16, version 3.9.1

+ 1
- 1
dist/vis.map
File diff suppressed because it is too large
View File


+ 9
- 9
dist/vis.min.js
File diff suppressed because it is too large
View File


+ 16
- 0
docs/graph2d.html View File

@ -737,6 +737,22 @@ The options colored in green can also be used as options for the groups. All opt
If not provided, the earliest date present in the events is taken as start date.</td> If not provided, the earliest date present in the events is taken as start date.</td>
</tr> </tr>
<tr>
<td>timeAxis.scale</td>
<td>string</td>
<td>none</td>
<td>Set a fixed scale for the time axis of the Timeline. Choose from <code>'millisecond'</code>, <code>'second'</code>, <code>'minute'</code>, <code>'hour'</code>, <code>'weekday'</code>, <code>'day'</code>, <code>'month'</code>, <code>'year'</code>.</td>
</tr>
<tr>
<td>timeAxis.step</td>
<td>number</td>
<td>1</td>
<td>
Set a fixed step size for the time axis. Only applicable when used together with <code>timeAxis.scale</code>.
Choose for example 1, 2, 5, or 10.</td>
</tr>
<tr> <tr>
<td>width</td> <td>width</td>
<td>String</td> <td>String</td>

+ 20
- 0
docs/timeline.html View File

@ -764,6 +764,26 @@ var options = {
<td>A template function used to generate the contents of the items. The function is called by the Timeline with an items data as argument, and must return HTML code as result. When the option template is specified, the items do not need to have a field <code>content</code>. See section <a href="#Templates">Templates</a> for a detailed explanation.</td> <td>A template function used to generate the contents of the items. The function is called by the Timeline with an items data as argument, and must return HTML code as result. When the option template is specified, the items do not need to have a field <code>content</code>. See section <a href="#Templates">Templates</a> for a detailed explanation.</td>
</tr> </tr>
<tr>
<td>timeAxis.scale</td>
<td>string</td>
<td>none</td>
<td>Set a fixed scale for the time axis of the Timeline. Choose from <code>'millisecond'</code>, <code>'second'</code>, <code>'minute'</code>, <code>'hour'</code>, <code>'weekday'</code>, <code>'day'</code>, <code>'month'</code>, <code>'year'</code>. Example usage:
<pre class="prettyprint lang-js">var options = {
timeAxis: {scale: 'minute', step: 5}
}</pre>
</td>
</tr>
<tr>
<td>timeAxis.step</td>
<td>number</td>
<td>1</td>
<td>
Set a fixed step size for the time axis. Only applicable when used together with <code>timeAxis.scale</code>.
Choose for example 1, 2, 5, or 10.</td>
</tr>
<tr> <tr>
<td>type</td> <td>type</td>
<td>String</td> <td>String</td>

+ 12
- 13
lib/timeline/TimeStep.js View File

@ -240,23 +240,22 @@ TimeStep.prototype.getCurrent = function() {
/** /**
* Set a custom scale. Autoscaling will be disabled. * Set a custom scale. Autoscaling will be disabled.
* For example setScale(SCALE.MINUTES, 5) will result
* For example setScale('minute', 5) will result
* in minor steps of 5 minutes, and major steps of an hour. * in minor steps of 5 minutes, and major steps of an hour.
* *
* @param {string} newScale
* A scale. Choose from 'millisecond, 'second,
* 'minute', 'hour', 'weekday, 'day, 'month, 'year'.
* @param {Number} newStep A step size, by default 1. Choose for
* example 1, 2, 5, or 10.
* @param {{scale: string, step: number}} params
* An object containing two properties:
* - A string 'scale'. Choose from 'millisecond', 'second',
* 'minute', 'hour', 'weekday, 'day, 'month, 'year'.
* - A number 'step'. A step size, by default 1.
* Choose for example 1, 2, 5, or 10.
*/ */
TimeStep.prototype.setScale = function(newScale, newStep) {
this.scale = newScale;
if (newStep > 0) {
this.step = newStep;
TimeStep.prototype.setScale = function(params) {
if (params && typeof params.scale == 'string') {
this.scale = params.scale;
this.step = params.step > 0 ? params.step : 1;
this.autoScale = false;
} }
this.autoScale = false;
}; };
/** /**

+ 7
- 2
lib/timeline/component/TimeAxis.js View File

@ -38,7 +38,8 @@ function TimeAxis (body, options) {
// TODO: implement timeaxis orientations 'left' and 'right' // TODO: implement timeaxis orientations 'left' and 'right'
showMinorLabels: true, showMinorLabels: true,
showMajorLabels: true, showMajorLabels: true,
format: null
format: null,
timeAxis: null
}; };
this.options = util.extend({}, this.defaultOptions); this.options = util.extend({}, this.defaultOptions);
@ -68,7 +69,8 @@ TimeAxis.prototype.setOptions = function(options) {
'showMinorLabels', 'showMinorLabels',
'showMajorLabels', 'showMajorLabels',
'hiddenDates', 'hiddenDates',
'format'
'format',
'timeAxis'
], this.options, options); ], this.options, options);
// apply locale to moment.js // apply locale to moment.js
@ -190,6 +192,9 @@ TimeAxis.prototype._repaintLabels = function () {
if (this.options.format) { if (this.options.format) {
step.setFormat(this.options.format); step.setFormat(this.options.format);
} }
if (this.options.timeAxis) {
step.setScale(this.options.timeAxis);
}
this.step = step; this.step = step;
// Move all DOM elements to a "redundant" list, where they // Move all DOM elements to a "redundant" list, where they

+ 4
- 0
test/timeline.html View File

@ -118,6 +118,10 @@
'hour': 'dddd D MMMM' 'hour': 'dddd D MMMM'
} }
} }
// timeAxis: {
// scale: 'hour',
// step: 2
// }
//clickToUse: true, //clickToUse: true,
//min: moment('2013-01-01'), //min: moment('2013-01-01'),
//max: moment('2013-12-31'), //max: moment('2013-12-31'),

Loading…
Cancel
Save