Skip to content

Commit

Permalink
commit omitted .syncRect() demo & add unlisted demos to index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
leeoniya committed Apr 12, 2020
1 parent 68bbde8 commit d5b37e8
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
4 changes: 4 additions & 0 deletions demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ <h1>μPlot Demos</h1>
<a href="resize.html">Resize with window</a>
<a href="time-periods.html">Compare several overlaid time periods &amp; stacked legend</a>

<a href="months-ru.html">Russian month names on date/time axis</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>

<a href="trendlines.html">Trendlines from zoomed range &amp; zoom snapping</a>
<a href="candlestick-ohlc.html">OHLC plugin &amp; legend-as-tooltip plugin</a>
<a href="draw-hooks.html">Draw hooks &amp; (custom points)</a>
Expand Down
71 changes: 71 additions & 0 deletions demos/scroll-sync.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Scroll syncRect()</title>
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="../src/uPlot.css">

<style>
#foo {
width: 400px;
height: 400px;
overflow-y: auto;
overflow-x: hidden;
}
</style>
</head>
<body>
<div id="foo">
<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
<p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</p>
</div>

<script src="../dist/uPlot.iife.js"></script>
<script>
let xs = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];
let vals = [-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10];

let data = [
xs,
xs.map((t, i) => vals[Math.floor(Math.random() * vals.length)]),
xs.map((t, i) => vals[Math.floor(Math.random() * vals.length)]),
xs.map((t, i) => vals[Math.floor(Math.random() * vals.length)]),
];

const opts = {
width: 400,
height: 200,
title: ".syncRect()",
scales: {
x: {
time: false,
},
},
series: [
{},
{
stroke: "red",
fill: "rgba(255,0,0,0.1)",
},
{
stroke: "green",
fill: "rgba(0,255,0,0.1)",
},
{
stroke: "blue",
fill: "rgba(0,0,255,0.1)",
},
],
};

let fooEl = document.querySelector("#foo");
let u = new uPlot(opts, data, fooEl);

fooEl.onscroll = e => {
u.syncRect();
};
</script>
</body>
</html>

0 comments on commit d5b37e8

Please sign in to comment.