Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in localization for datetime with override option for datetime and numbers #985

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h1>μPlot Demos</h1>
<a href="timeseries-discrete.html">Discrete &amp; shifted series w/sync</a>
<a href="update-cursor-select-resize.html">Maintains location of cursor/select/hoverPts during resize (test)</a>

<a href="months-ru.html">Russian month names on date/time axis</a>
<a href="localize-fr-ca.html">Override default localization (French Canada)</a>
<a href="add-del-series.html">Dynamically add or delete series</a>
<a href="scroll-sync.html">Sync chart position when inside a scrollable container</a>

Expand Down
17 changes: 5 additions & 12 deletions demos/months-ru.html → demos/localize-fr-ca.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Months (Russian)</title>
<title>Localize Time & Measure (French Canadian)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="../dist/uPlot.min.css">
Expand All @@ -23,26 +23,19 @@
})
});

let vals = [0,1,2,3,4,5,6,7,8,9,10];
let vals = [1000.1,1100.1,1200.2,1300.3,1400.4,1500.5,1600.6,1700.7,1800.8,1900.9,2000.10];

let data = [
ts,
ts.map((t, i) => i == 0 ? 5 : vals[Math.floor(Math.random() * vals.length)]),
ts.map((t, i) => i == 0 ? 1500 : vals[Math.floor(Math.random() * vals.length)]),
];

const ruNames = {
MMMM: ["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"],
MMM: ["Янв","Февр","Март","Апр","Май","Июнь","Июль","Авг","Сент","Окт","Нояб","Дек"],
WWWW: ["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"],
WWW: ["Вск","Пнд","Втр","Срд","Чтв","Птн","Сбт"],
};

const opts = {
width: 1920,
height: 600,
title: "Months",
locale: 'fr-CA',
tzDate: ts => uPlot.tzDate(new Date(ts * 1e3), 'Etc/UTC'),
fmtDate: tpl => uPlot.fmtDate(tpl, ruNames),
series: [
{},
{
Expand All @@ -54,4 +47,4 @@
let u = new uPlot(opts, data, document.body);
</script>
</body>
</html>
</html>
Loading