Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b7a2b7e

Browse files
Merge pull request #34 from ajyong/bugs/support-timeline-without-groups
Support Timeline without groups
2 parents 5d0828e + ba056b7 commit b7a2b7e

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

‎examples/src/App.vue‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,39 @@
5555

5656
<hr>
5757

58-
<h2>Timeline</h2>
58+
<h2>Timeline (without groups)</h2>
59+
<timeline
60+
ref="timeline-withoutGroups"
61+
:items="timeline.items"
62+
:options="timeline.options"
63+
@click="timelineWithoutGroupsEvent('click')"
64+
@contextmenu="timelineWithoutGroupsEvent('contextmenu')"
65+
@current-time-tick="timelineWithoutGroupsEvent('currentTimeTick')"
66+
@double-click="timelineWithoutGroupsEvent('doubleClick')"
67+
@drop="timelineWithoutGroupsEvent('drop')"
68+
@mouse-over="timelineWithoutGroupsEvent('mouseOver')"
69+
@mouse-down="timelineWithoutGroupsEvent('mouseDown')"
70+
@mouse-up="timelineWithoutGroupsEvent('mouseUp')"
71+
@mouse-move="timelineWithoutGroupsEvent('mouseMove')"
72+
@group-dragged="timelineWithoutGroupsEvent('groupDragged')"
73+
@changed="timelineWithoutGroupsEvent('changed')"
74+
@rangechange="timelineWithoutGroupsEvent('rangechange')"
75+
@rangechanged="timelineWithoutGroupsEvent('rangechanged')"
76+
@select="timelineWithoutGroupsEvent('select')"
77+
@itemover="timelineWithoutGroupsEvent('itemover')"
78+
@itemout="timelineWithoutGroupsEvent('itemout')"
79+
@timechange="timelineWithoutGroupsEvent('timechange')"
80+
@timechanged="timelineWithoutGroupsEvent('timechanged')"
81+
@items-mounted="timelineWithoutGroupsEvent('items-mounted')"
82+
@items-add="timelineWithoutGroupsEvent('items-add')"
83+
@items-update="timelineWithoutGroupsEvent('items-update')"
84+
@items-remove="timelineWithoutGroupsEvent('items-remove')">
85+
</timeline>
86+
<div class="events"><p>Timeline events: <br /> {{timelineWithoutGroupsEvents}}</p></div>
87+
88+
<hr>
89+
90+
<h2>Timeline (with groups)</h2>
5991
<timeline
6092
ref="timeline"
6193
:items="timeline.items"
@@ -126,6 +158,7 @@ import { Timeline, Graph2d, Network } from 'vue2vis';
126158
export default {
127159
data: () => ({
128160
timelineEvents: '',
161+
timelineWithoutGroupsEvents: '',
129162
timeline: {
130163
groups: [
131164
{
@@ -266,6 +299,10 @@ export default {
266299
if (this.timelineEvents.length > 500) this.timelineEvents = '';
267300
this.timelineEvents += `${eventName}, `;
268301
},
302+
timelineWithoutGroupsEvent(eventName) {
303+
if (this.timelineWithoutGroupsEvents.length > 500) this.timelineWithoutGroupsEvents = '';
304+
this.timelineWithoutGroupsEvents += `${eventName}, `;
305+
},
269306
graph2dEvent(eventName) {
270307
if (this.graph2dEvents.length > 500) this.graph2dEvents = '';
271308
this.graph2dEvents += `${eventName}, `;

‎src/components/Timeline.vue‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,15 @@ export default {
156156
},
157157
mounted() {
158158
const container = this.$refs.visualization;
159+
159160
this.visData.items = mountVisData(this, 'items');
160-
this.visData.groups = mountVisData(this, 'groups');
161-
this.timeline = new Timeline(container, this.visData.items, this.visData.groups, this.options);
161+
162+
if (this.groups && this.groups.length > 0) {
163+
this.visData.groups = mountVisData(this, 'groups');
164+
this.timeline = new Timeline(container, this.visData.items, this.visData.groups, this.options);
165+
} else {
166+
this.timeline = new Timeline(container, this.visData.items, this.options);
167+
}
162168
163169
this.events.forEach(eventName =>
164170
this.timeline.on(eventName, props => this.$emit(translateEvent(eventName), props))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /