Click the controls below the timeline to change the view.
Entities with no events in the view are hidden.
The view can be controlled with the fit, pan and zoom functions.
See Also
Click the controls below the timeline to change the view.
Entities with no events in the view are hidden.
The view can be controlled with the fit, pan and zoom instance methods.
See Also
import { createTimeline } from "kronograph";
import data from "./data";
const timeline = createTimeline("my-timeline");
timeline.set(data);
timeline.fit();
document.getElementById("pan-left").onclick = () => timeline.pan("left");
document.getElementById("pan-right").onclick = () => timeline.pan("right");
document.getElementById("zoom-in").onclick = () => timeline.zoom("in");
document.getElementById("zoom-out").onclick = () => timeline.zoom("out");
document.getElementById("fit").onclick = () => timeline.fit(); export default {
entityTypes: {
Claim: {
order: 2,
},
Investigated: {
baseType: "Claim",
color: "#EA3C53",
labelColor: "#fc4c63",
},
Accepted: {
baseType: "Claim",
color: "#1BBC9B",
labelColor: "#21deb8",
},
Claimant: {
color: "#b2bfd8",
lineWidth: 10,
order: 1,
},
},
eventTypes: {
default: {
showArrows: true,
},
"Not Flagged": {
baseType: "default",
color: "#1BBC9B",
lineWidth: 2,
},
Flagged: {
baseType: "default",
color: "#EA3C53",
lineWidth: 6,
},
},
entities: {
"smith-johnathan-151": {
label: "John Smith",
type: "Claimant",
},
"west-josephine-126": {
label: "Josephine West",
type: "Claimant",
},
"roberts-nathaniel-023": {
label: "Nathan Roberts",
type: "Claimant",
},
"baxter-eleanor-004": {
label: "Ella Baxter",
type: "Claimant",
},
"Claim MF-1883": {
type: "Accepted",
},
"Claim DO-1748": {
type: "Accepted",
},
"Claim EF-8738": {
type: "Accepted",
},
"Claim PD-9393": {
type: "Investigated",
},
"Claim SL-8745": {
type: "Investigated",
},
"Claim IE-9393": {
type: "Accepted",
},
"Claim GZ-2012": {
type: "Investigated",
},
"Claim SQ-5563": {
type: "Accepted",
},
"Claim FW-1888": {
type: "Investigated",
},
},
events: {
"claim 1": {
entityIds: ["smith-johnathan-151", "Claim MF-1883"],
type: "Not Flagged",
time: new Date(2027, 3, 4),
},
"claim 2": {
entityIds: ["baxter-eleanor-004", "Claim SL-8745"],
type: "Flagged",
time: new Date(2025, 2, 25),
},
"claim 3": {
entityIds: ["west-josephine-126", "Claim DO-1748"],
type: "Not Flagged",
time: new Date(2028, 12, 8),
},
"claim 4": {
entityIds: ["roberts-nathaniel-023", "Claim EF-8738"],
type: "Not Flagged",
time: new Date(2025, 6, 13),
},
"claim 5": {
entityIds: ["smith-johnathan-151", "Claim PD-9393"],
type: "Flagged",
time: new Date(2027, 10, 16),
},
"claim 6": {
entityIds: ["baxter-eleanor-004", "Claim IE-9393"],
type: "Not Flagged",
time: new Date(2028, 2, 25),
},
"claim 7": {
entityIds: ["roberts-nathaniel-023", "Claim GZ-2012"],
type: "Flagged",
time: new Date(2027, 4, 11),
},
"claim 8": {
entityIds: ["baxter-eleanor-004", "Claim SQ-5563"],
type: "Not Flagged",
time: new Date(2025, 11, 2),
},
"claim 9": {
entityIds: ["west-josephine-126", "Claim FW-1888"],
type: "Flagged",
time: new Date(2026, 8, 5),
},
},
}; <!doctype html>
<html>
<head>
<link rel="stylesheet" href="@ci/theme/kg/css/examples.css" />
</head>
<body>
<div class="story">
<div class="story__timeline" id="my-timeline"></div>
<div class="story__controls story__controls--row">
<div class="story__controls__button-container">
<button class="button button--neutral" title="Pan Left" id="pan-left">
<i class="fas fa-chevron-left"></i>
</button>
<button class="button button--neutral" title="Pan Right" id="pan-right">
<i class="fas fa-chevron-right"></i>
</button>
<button class="button button--neutral" title="Zoom In" id="zoom-in">
<i class="fas fa-search-plus"></i>
</button>
<button class="button button--neutral" title="Zoom Out" id="zoom-out">
<i class="fas fa-search-minus"></i>
</button>
<button class="button button--neutral" title="Fit to View" id="fit">
<i class="fas fa-expand"></i>
</button>
</div>
</div>
</div>
<script type="module" src="./code.js"></script>
</body>
</html> import React, { useRef } from "react";
import { createRoot } from "react-dom/client";
import Timeline from "kronograph/react/Timeline";
import data from "./data";
function Button({ clickHandler, title, iconClass }) {
return (
<button className="button button--neutral" title={title} onClick={clickHandler}>
<i className={`fas ${iconClass}`}></i>
</button>
);
}
export const Demo = () => {
const timelineRef = useRef(null);
return (
<div className="story">
<Timeline
className="story__timeline"
ref={timelineRef}
events={data.events}
entities={data.entities}
eventTypes={data.eventTypes}
entityTypes={data.entityTypes}
/>
<div className="story__controls story__controls--row">
<div className="story__controls__button-container">
<Button
title="Pan Left"
clickHandler={() => timelineRef.current.pan("left")}
iconClass="fa-chevron-left"
/>
<Button
title="Pan Right"
clickHandler={() => timelineRef.current.pan("right")}
iconClass="fa-chevron-right"
/>
<Button
title="Zoom In"
clickHandler={() => timelineRef.current.zoom("in")}
iconClass="fa-search-plus"
/>
<Button
title="Zoom Out"
clickHandler={() => timelineRef.current.zoom("out")}
iconClass="fa-search-minus"
/>
<Button
title="Fit to View"
clickHandler={() => timelineRef.current.fit()}
iconClass="fa-expand"
/>
</div>
</div>
</div>
);
};
const root = createRoot(document.getElementById("my-timeline"));
root.render(<Demo />); export default {
entityTypes: {
Claim: {
order: 2,
},
Investigated: {
baseType: "Claim",
color: "#EA3C53",
labelColor: "#fc4c63",
},
Accepted: {
baseType: "Claim",
color: "#1BBC9B",
labelColor: "#21deb8",
},
Claimant: {
color: "#b2bfd8",
lineWidth: 10,
order: 1,
},
},
eventTypes: {
default: {
showArrows: true,
},
"Not Flagged": {
baseType: "default",
color: "#1BBC9B",
lineWidth: 2,
},
Flagged: {
baseType: "default",
color: "#EA3C53",
lineWidth: 6,
},
},
entities: {
"smith-johnathan-151": {
label: "John Smith",
type: "Claimant",
},
"west-josephine-126": {
label: "Josephine West",
type: "Claimant",
},
"roberts-nathaniel-023": {
label: "Nathan Roberts",
type: "Claimant",
},
"baxter-eleanor-004": {
label: "Ella Baxter",
type: "Claimant",
},
"Claim MF-1883": {
type: "Accepted",
},
"Claim DO-1748": {
type: "Accepted",
},
"Claim EF-8738": {
type: "Accepted",
},
"Claim PD-9393": {
type: "Investigated",
},
"Claim SL-8745": {
type: "Investigated",
},
"Claim IE-9393": {
type: "Accepted",
},
"Claim GZ-2012": {
type: "Investigated",
},
"Claim SQ-5563": {
type: "Accepted",
},
"Claim FW-1888": {
type: "Investigated",
},
},
events: {
"claim 1": {
entityIds: ["smith-johnathan-151", "Claim MF-1883"],
type: "Not Flagged",
time: new Date(2027, 3, 4),
},
"claim 2": {
entityIds: ["baxter-eleanor-004", "Claim SL-8745"],
type: "Flagged",
time: new Date(2025, 2, 25),
},
"claim 3": {
entityIds: ["west-josephine-126", "Claim DO-1748"],
type: "Not Flagged",
time: new Date(2028, 12, 8),
},
"claim 4": {
entityIds: ["roberts-nathaniel-023", "Claim EF-8738"],
type: "Not Flagged",
time: new Date(2025, 6, 13),
},
"claim 5": {
entityIds: ["smith-johnathan-151", "Claim PD-9393"],
type: "Flagged",
time: new Date(2027, 10, 16),
},
"claim 6": {
entityIds: ["baxter-eleanor-004", "Claim IE-9393"],
type: "Not Flagged",
time: new Date(2028, 2, 25),
},
"claim 7": {
entityIds: ["roberts-nathaniel-023", "Claim GZ-2012"],
type: "Flagged",
time: new Date(2027, 4, 11),
},
"claim 8": {
entityIds: ["baxter-eleanor-004", "Claim SQ-5563"],
type: "Not Flagged",
time: new Date(2025, 11, 2),
},
"claim 9": {
entityIds: ["west-josephine-126", "Claim FW-1888"],
type: "Flagged",
time: new Date(2026, 8, 5),
},
},
}; <!doctype html>
<html>
<head>
<link rel="stylesheet" href="@ci/theme/kg/css/examples.css" />
</head>
<body>
<div id="my-timeline" style="height: 100vh"></div>
<script type="module" src="./code.jsx"></script>
</body>
</html>