Skip to content

Instantly share code, notes, and snippets.

@ahandsel
Last active June 10, 2022 10:33
Show Gist options
  • Select an option

  • Save ahandsel/28d8bf88ba55e026226178b8180bb495 to your computer and use it in GitHub Desktop.

Select an option

Save ahandsel/28d8bf88ba55e026226178b8180bb495 to your computer and use it in GitHub Desktop.

No Server Data Visualization: Build a Timeline Generator!

Thank you for attending our Kintone x Timeline workshop!

Use the following CSV file, CDN URLs, JavaScript file, and PDF files for the hands-on section!

Download Links

Click here or the Download Zip button on the upper right corner for all the code, data, & slide you need for our workshop!

Getting your FREE Kintone Database

Step 1 - Sign Up for Kintone Developer Account (Website)

  • bit.ly/KDP_signup
    • ⚠ Do NOT use Safari
    • ⚡Accept Cookies First
    • ✅ Use Chrome & Firefox

Step 2 - Create a Kintone Subdomain (Environment)

  • bit.ly/K_DevLic
    • ⚡ Only use lowercase, numbers, & hyphens in your subdomain
    • ⚠ Do not use uppercase nor special characters

Quick video on the sign-up process

https://youtu.be/Gzz8SbTuoFg https://youtu.be/Gzz8SbTuoFg

Start_Date End_Date First_Name Last_Name Party Wiki_URL
04/30/1789 03/04/1797 George Washington Unaffiliated https://en.wikipedia.org/wiki/Presidency_of_George_Washington
03/04/1797 03/04/1801 John Adams Federalist https://en.wikipedia.org/wiki/Presidency_of_John_Adams
03/04/1801 03/04/1809 Thomas Jefferson Democratic-Republican https://en.wikipedia.org/wiki/Presidency_of_Thomas_Jefferson
03/04/1809 03/04/1817 James Madison Democratic-Republican https://en.wikipedia.org/wiki/Presidency_of_James_Madison
03/04/1817 03/04/1825 James Monroe Democratic-Republican https://en.wikipedia.org/wiki/Presidency_of_James_Monroe
03/04/1825 03/04/1829 John Adams Democratic-Republican https://en.wikipedia.org/wiki/Presidency_of_John_Quincy_Adams
03/04/1829 03/04/1837 Andrew Jackson Democratic https://en.wikipedia.org/wiki/Presidency_of_Andrew_Jackson
03/04/1837 03/04/1841 Martin Van Buren Democratic https://en.wikipedia.org/wiki/Presidency_of_Martin_Van_Buren
03/04/1841 04/04/1841 William Henry Harrison Whig https://en.wikipedia.org/wiki/William_Henry_Harrison#Presidency_(1841)
04/04/1841 03/04/1845 John Tyler Whig https://en.wikipedia.org/wiki/Presidency_of_John_Tyler
03/04/1845 03/04/1849 James Polk Democratic https://en.wikipedia.org/wiki/Presidency_of_James_K._Polk
03/04/1849 07/09/1850 Zachary Taylor Whig https://en.wikipedia.org/wiki/Presidency_of_Zachary_Taylor
07/09/1850 03/04/1853 Millard Fillmore Whig https://en.wikipedia.org/wiki/Presidency_of_Millard_Fillmore
03/04/1853 03/04/1857 Franklin Pierce Democratic https://en.wikipedia.org/wiki/Presidency_of_Franklin_Pierce
03/04/1857 03/04/1861 James Buchanan Democratic https://en.wikipedia.org/wiki/Presidency_of_James_Buchanan
03/04/1861 04/15/1865 Abraham Lincoln Republican https://en.wikipedia.org/wiki/Presidency_of_Abraham_Lincoln
04/15/1865 03/04/1869 Andrew Johnson Democratic https://en.wikipedia.org/wiki/Presidency_of_Andrew_Johnson
03/04/1869 03/04/1877 Ulysses Grant Republican https://en.wikipedia.org/wiki/Presidency_of_Ulysses_S._Grant
03/04/1877 03/04/1881 Rutherford Hayes Republican https://en.wikipedia.org/wiki/Presidency_of_Rutherford_B._Hayes
03/04/1881 09/19/1881 James Garfield Republican https://en.wikipedia.org/wiki/James_A._Garfield#Presidency,_1881
09/19/1881 03/04/1885 Chester Arthur Republican https://en.wikipedia.org/wiki/Presidency_of_Chester_A._Arthur
03/04/1885 03/04/1889 Grover Cleveland Democratic https://en.wikipedia.org/wiki/Presidencies_of_Grover_Cleveland
03/04/1889 03/04/1893 Benjamin Harrison Republican https://en.wikipedia.org/wiki/Presidency_of_Benjamin_Harrison
03/04/1893 03/04/1897 Grover Cleveland Democratic https://en.wikipedia.org/wiki/Presidencies_of_Grover_Cleveland
03/04/1897 09/14/1901 William McKinley Republican https://en.wikipedia.org/wiki/Presidency_of_William_McKinley
09/14/1901 03/04/1909 Theodore Roosevelt Republican https://en.wikipedia.org/wiki/Presidency_of_Theodore_Roosevelt
03/04/1909 03/04/1913 William Taft Republican https://en.wikipedia.org/wiki/Presidency_of_William_Howard_Taft
03/04/1913 03/04/1921 Woodrow Wilson Democratic https://en.wikipedia.org/wiki/Presidency_of_Woodrow_Wilson
03/04/1921 08/02/1923 Warren Harding Republican https://en.wikipedia.org/wiki/Presidency_of_Warren_G._Harding
08/02/1923 03/04/1929 Calvin Coolidge Republican https://en.wikipedia.org/wiki/Presidency_of_Calvin_Coolidge
03/04/1929 03/04/1933 Herbert Hoover Republican https://en.wikipedia.org/wiki/Presidency_of_Herbert_Hoover
03/04/1933 04/12/1945 Franklin Roosevelt Democratic https://en.wikipedia.org/wiki/Franklin_D._Roosevelt
04/12/1945 01/20/1953 Harry Truman Democratic https://en.wikipedia.org/wiki/Presidency_of_Harry_S._Truman
01/20/1953 01/20/1961 Dwight Eisenhower Republican https://en.wikipedia.org/wiki/Presidency_of_Dwight_D._Eisenhower
01/20/1961 11/22/1963 John Kennedy Democratic https://en.wikipedia.org/wiki/Presidency_of_John_F._Kennedy
11/22/1963 01/20/1969 Lyndon Johnson Democratic https://en.wikipedia.org/wiki/Presidency_of_Lyndon_B._Johnson
01/20/1969 08/09/1974 Richard Nixon Republican https://en.wikipedia.org/wiki/Presidency_of_Richard_Nixon
08/09/1974 01/20/1977 Gerald Ford Republican https://en.wikipedia.org/wiki/Presidency_of_Gerald_Ford
01/20/1977 01/20/1981 Jimmy Carter Democratic https://en.wikipedia.org/wiki/Presidency_of_Jimmy_Carter
01/20/1981 01/20/1989 Ronald Reagan Republican https://en.wikipedia.org/wiki/Presidency_of_Ronald_Reagan
01/20/1989 01/20/1993 George Bush Republican https://en.wikipedia.org/wiki/Presidency_of_George_H._W._Bush
01/20/1993 01/20/2001 Bill Clinton Democratic https://en.wikipedia.org/wiki/Presidency_of_Bill_Clinton
01/20/2001 01/20/2009 George Bush Republican https://en.wikipedia.org/wiki/Presidency_of_George_W._Bush
01/20/2009 01/20/2017 Barack Obama Democratic https://en.wikipedia.org/wiki/Presidency_of_Barack_Obama
01/20/2017 01/20/2021 Donald Trump Republican https://en.wikipedia.org/wiki/Presidency_of_Donald_Trump
01/20/2021 01/20/2025 Joe Biden Democratic https://en.wikipedia.org/wiki/Presidency_of_Joe_Biden
// ⚠️ Order matters when inserting CDN URLs into Kintone App settings
https://cdn.amcharts.com/lib/4/core.js
https://cdn.amcharts.com/lib/4/charts.js
https://cdn.amcharts.com/lib/4/plugins/timeline.js
https://cdn.amcharts.com/lib/4/plugins/bullets.js
https://cdn.amcharts.com/lib/4/themes/animated.js
// amChart TimeLine x Kintone
(function () {
'use strict';
// Color HEX code for the political parties
const partyColor = {
'Democratic': '#2502fe',
'Democratic-Republican': '#0e7003',
'Federalist': '#e28665',
'Republican': '#e0001b',
'Unaffiliated': '#d5d5d5',
'Whig': '#ebbd50'
};
// Imgur's Image Hash
const imgCode = ['', 'gk1cP2u', '9FR7eva', 'aumfl2F', 'kx8BdCT', 'z6Yd9Lm', '4HLWKcB', 'mmTyKJ1', 'PCb7ly6', 'UgN4EA7', 'rVoiW4X', 'i3euA9w', 'kt92UVi', 'oo5aw5x', 'BZI7FTa', 'XLkIWAs', 'qB4GVSv', '5kAZ3NJ', 'drQysn9', 'UqvMVTH', 'Wte60Q6', '3DAK1C1', 'h6b7Vw5', 'ctHNmhA', '18zBca0', 'hb94eO2', '12hJdg0', 'Bl8oRVY', 'HQ1xV6H', 'pj4oAjR', 'QuzzGmm', 'zpE50Pa', '4zSuesA', 'mevGXAh', '5zq1fDg', 'EcUoEs2', 'S5BJfEO', 'bMW0Ltr', 'hutxiiz', 'hRBgyF1', 'gHP21eA', '3QtuHuW', 'XSwwVLh', 'wnbeSN1', 'Uw18RFA', '4APgxYd', 'S5wCZcd'];
// Kintone event triggered after the record list page is displayed.
kintone.events.on('app.record.index.show', function (event) {
// Peak inside Kintone's data
console.log('event.records');
console.log(event.records);
// Retrieve & configure the space element below the record list's header
const spaceDiv = kintone.app.getHeaderSpaceElement();
spaceDiv.style.height = '650px';
spaceDiv.style.marginLeft = '25px';
spaceDiv.style.marginRight = '25px';
spaceDiv.style.border = 'solid';
spaceDiv.style.borderColor = '#ED7B84';
// Automatically enable all amCharts animations
am4core.useTheme(am4themes_animated);
// Create chart instance
const chart = am4core.create(spaceDiv, am4plugins_timeline.SerpentineChart);
// Space between the chart & border
chart.paddingTop = 100;
// Number of straight lines of serpentine shape
chart.levelCount = 5;
// Allow bullets to 'bleed' over the edge
chart.maskBullets = false;
// Input & Output Date format
chart.dateFormatter.inputDateFormat = 'yyyy-MM-dd';
chart.dateFormatter.dateFormat = 'yyyy-MM-dd';
// Font size
chart.fontSize = 12;
chart.tooltipContainer.fontSize = 12;
// Input Kintone data into the chart
chart.data = event.records.map((rec, index) => {
return {
// Text above the PinBullet; President's name
'text': `${rec.Text.value}\n${rec.Text_0.value}`,
// PinBullet's & time period's color; Party color
'color': partyColor[rec.Drop_down.value],
// Time period's start; Term's start
'start': rec.Date.value,
// Time period's end; Term's end
'end': rec.Date_0.value,
// Icon inside the PinBullet; President's icon
'icon': `https://i.imgur.com/${imgCode[rec.Record_number.value]}.png`,
// Timeline category; only 1 is needed
'category': ''
}
});
console.log('chart.data');
console.log(chart.data);
// Create 1 timeline with all the US Presidents
const categoryAxis = chart.yAxes.push(new am4charts.CategoryAxis());
categoryAxis.dataFields.category = 'category';
// Axis using date & time scale
const dateAxis = chart.xAxes.push(new am4charts.DateAxis());
// Gray, dashed lines for date axis
dateAxis.renderer.line.strokeDasharray = '1,4';
dateAxis.renderer.line.strokeOpacity = 1;
// Place the label in the middle of the axis
dateAxis.renderer.labels.template.verticalCenter = 'middle';
// Series containing the US Presidents and their terms
const series = chart.series.push(new am4plugins_timeline.CurveColumnSeries());
series.dataFields.openDateX = 'start';
series.dataFields.dateX = 'end';
series.dataFields.categoryY = 'category';
series.baseAxis = categoryAxis;
// Coloring of the Presidential terms
series.columns.template.height = am4core.percent(15);
series.columns.template.propertyFields.fill = 'color';
series.columns.template.propertyFields.stroke = 'color';
series.columns.template.strokeOpacity = 0;
series.columns.template.fillOpacity = 0.6;
// Create the PinBullet (Circles)
const pinBullet = series.bullets.push(new am4plugins_bullets.PinBullet());
pinBullet.locationX = 1; //Place the PinBullet at their term's start
pinBullet.propertyFields.stroke = 'color';
pinBullet.background.propertyFields.fill = 'color';
pinBullet.image = new am4core.Image();
pinBullet.image.propertyFields.href = 'icon';
// President's name over the icon
const labelBullet = series.bullets.push(new am4charts.LabelBullet());
labelBullet.label.propertyFields.text = 'text';
labelBullet.label.textAlign = 'middle';
labelBullet.locationX = 1; // Place the labelBullet at their term's start
labelBullet.dy = -80; // Raising text above the icon
// Scrollbar used to focus the timeline
chart.scrollbarX = new am4core.Scrollbar();
chart.scrollbarX.align = 'center'
chart.scrollbarX.width = am4core.percent(75);
chart.scrollbarX.parent = chart.bottomAxesContainer;
// Year appearing when hovering over the chart axis
const cursor = new am4plugins_timeline.CurveCursor();
chart.cursor = cursor;
dateAxis.tooltipDateFormat = 'yyyy-MMM';
cursor.xAxis = dateAxis;
cursor.lineY.disabled = true; // Disable Y line highlight
// Optional - Enable export
chart.exporting.menu = new am4core.ExportMenu();
// Remove unneeded Scrollbar & tooltip
chart.scrollbarX.exportable = false;
dateAxis.tooltip.exportable = false;
});
})();

Thank you for attending our workshop!

Your Feedback Please 🙇

Please fill out this quick survey for a chance to win 💰️ $25 Amazon Gift Card:

Next Step

For those wanting more visualization projects:

  • Try linking to different amChart libraries, and reuse the code we used in the workshop!

For those wanting to create projects on Kintone and want to retrieve & store data from public APIs:

For those wanting to use Kintone as a back-end database:

Where to Get Help?

(function () {
'use strict';
var url = "https://xkcd.com/327/info.0.json";
kintone.events.on('app.record.index.show', function (event) {
kintone.proxy(url, 'GET', {}, {}, function (success) {
var jsonResponse = JSON.parse(success);
console.log(jsonResponse);
window.open(jsonResponse.img, "", "width=800, height=200, top=200");
}, function (error) {
console.log(error);
});
return event;
});
})();

amCharts & Kintone References

Following are documentations refereed when creating the Timeline Chart x Kintone customizations.

Kintone Events

amCharts Getting Started Tutorials

amCharts Animation

Timeline

Plugin: Bullets

To have the PinBullets linkable to their Wiki_URL, take a look at the following docs

Other Parts

// amChart TimeLine x Kintone
// Use this version if you imported the CSV file without changing the Party field to a Drop_down field
(function () {
'use strict';
// Color HEX code for the political parties
const partyColor = {
'Democratic': '#2502fe',
'Democratic-Republican': '#0e7003',
'Federalist': '#e28665',
'Republican': '#e0001b',
'Unaffiliated': '#d5d5d5',
'Whig': '#ebbd50'
};
// Imgur's Image Hash
const imgCode = ['', 'gk1cP2u', '9FR7eva', 'aumfl2F', 'kx8BdCT', 'z6Yd9Lm', '4HLWKcB', 'mmTyKJ1', 'PCb7ly6', 'UgN4EA7', 'rVoiW4X', 'i3euA9w', 'kt92UVi', 'oo5aw5x', 'BZI7FTa', 'XLkIWAs', 'qB4GVSv', '5kAZ3NJ', 'drQysn9', 'UqvMVTH', 'Wte60Q6', '3DAK1C1', 'h6b7Vw5', 'ctHNmhA', '18zBca0', 'hb94eO2', '12hJdg0', 'Bl8oRVY', 'HQ1xV6H', 'pj4oAjR', 'QuzzGmm', 'zpE50Pa', '4zSuesA', 'mevGXAh', '5zq1fDg', 'EcUoEs2', 'S5BJfEO', 'bMW0Ltr', 'hutxiiz', 'hRBgyF1', 'gHP21eA', '3QtuHuW', 'XSwwVLh', 'wnbeSN1', 'Uw18RFA', '4APgxYd', 'S5wCZcd'];
// Kintone event triggered after the record list page is displayed.
kintone.events.on('app.record.index.show', function (event) {
// Peak inside Kintone's data
console.log('event.records');
console.log(event.records);
// Retrieve & configure the space element below the record list's header
const spaceDiv = kintone.app.getHeaderSpaceElement();
spaceDiv.style.height = '650px';
spaceDiv.style.marginLeft = '25px';
spaceDiv.style.marginRight = '25px';
spaceDiv.style.border = 'solid';
spaceDiv.style.borderColor = '#ED7B84';
// Automatically enable all amCharts animations
am4core.useTheme(am4themes_animated);
// Create chart instance
const chart = am4core.create(spaceDiv, am4plugins_timeline.SerpentineChart);
// Space between the chart & border
chart.paddingTop = 100;
// Number of straight lines of serpentine shape
chart.levelCount = 5;
// Allow bullets to 'bleed' over the edge
chart.maskBullets = false;
// Input & Output Date format
chart.dateFormatter.inputDateFormat = 'yyyy-MM-dd';
chart.dateFormatter.dateFormat = 'yyyy-MM-dd';
// Font size
chart.fontSize = 12;
chart.tooltipContainer.fontSize = 12;
// Input Kintone data into the chart
chart.data = event.records.map((rec, index) => {
return {
// Text above the PinBullet; President's name
'text': `${rec.Text.value}\n${rec.Text_0.value}`,
// PinBullet's & time period's color; Party color
'color': partyColor[rec.Text_1.value],
// Time period's start; Term's start
'start': rec.Date.value,
// Time period's end; Term's end
'end': rec.Date_0.value,
// Icon inside the PinBullet; President's icon
'icon': `https://i.imgur.com/${imgCode[rec.Record_number.value]}.png`,
// Timeline category; only 1 is needed
'category': ''
}
});
console.log('chart.data');
console.log(chart.data);
// Create 1 timeline with all the US Presidents
const categoryAxis = chart.yAxes.push(new am4charts.CategoryAxis());
categoryAxis.dataFields.category = 'category';
// Axis using date & time scale
const dateAxis = chart.xAxes.push(new am4charts.DateAxis());
// Gray, dashed lines for date axis
dateAxis.renderer.line.strokeDasharray = '1,4';
dateAxis.renderer.line.strokeOpacity = 1;
// Place the label in the middle of the axis
dateAxis.renderer.labels.template.verticalCenter = 'middle';
// Series containing the US Presidents and their terms
const series = chart.series.push(new am4plugins_timeline.CurveColumnSeries());
series.dataFields.openDateX = 'start';
series.dataFields.dateX = 'end';
series.dataFields.categoryY = 'category';
series.baseAxis = categoryAxis;
// Coloring of the Presidential terms
series.columns.template.height = am4core.percent(15);
series.columns.template.propertyFields.fill = 'color';
series.columns.template.propertyFields.stroke = 'color';
series.columns.template.strokeOpacity = 0;
series.columns.template.fillOpacity = 0.6;
// Create the PinBullet (Circles)
const pinBullet = series.bullets.push(new am4plugins_bullets.PinBullet());
pinBullet.locationX = 1; //Place the PinBullet at their term's start
pinBullet.propertyFields.stroke = 'color';
pinBullet.background.propertyFields.fill = 'color';
pinBullet.image = new am4core.Image();
pinBullet.image.propertyFields.href = 'icon';
// President's name over the icon
const labelBullet = series.bullets.push(new am4charts.LabelBullet());
labelBullet.label.propertyFields.text = 'text';
labelBullet.label.textAlign = 'middle';
labelBullet.locationX = 1; // Place the labelBullet at their term's start
labelBullet.dy = -80; // Raising text above the icon
// Scrollbar used to focus the timeline
chart.scrollbarX = new am4core.Scrollbar();
chart.scrollbarX.align = 'center'
chart.scrollbarX.width = am4core.percent(75);
chart.scrollbarX.parent = chart.bottomAxesContainer;
// Year appearing when hovering over the chart axis
const cursor = new am4plugins_timeline.CurveCursor();
chart.cursor = cursor;
dateAxis.tooltipDateFormat = 'yyyy-MMM';
cursor.xAxis = dateAxis;
cursor.lineY.disabled = true; // Disable Y line highlight
// Optional - Enable export
chart.exporting.menu = new am4core.ExportMenu();
// Remove unneeded Scrollbar & tooltip
chart.scrollbarX.exportable = false;
dateAxis.tooltip.exportable = false;
});
})();
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ahandsel
Copy link
Author

Hello @pizzou , thank you for your comment. Please try again. I was able to just confirm that the zip file properly downloaded.

You can also try downloading this gist by directly using “Download Zip” button at the top of this page.

Confirmed it in MacOS, Chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment