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

new candlestick chart demo #606

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
54 changes: 54 additions & 0 deletions demos/candlestick-ohlc-pan-zoom-scroller.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<title>Candlestick Chart</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../dist/uPlot.min.css">

</head>

<body>
Expand Down Expand Up @@ -163,6 +164,55 @@

}, false);



/* left axis scale */

let leftAxisScale = u.root.querySelectorAll(".u-axis")[1];
Copy link
Owner

@leeoniya leeoniya Nov 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great to see use of cutting-edge features :)

this was exactly the use-case i had in mind for these rects, too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm implementing a trading system, and the graphic visualization in metatrader doesn't support the graphic types I want to create. I will actually use context2d to create cluster footprint charts. vertical scale will be required to implement these features.

as I saw that others wanted this, I decided to implement it in the example to help those who also want these features, I thought your project was really cool and very fast.

let valYscaleBefore = 0;

let clientYMove = 0;


function move() {
rafPending = false;

let diff = 0;

lftx = u.valToPos(u.scales.x.min, 'x');
widx = u.valToPos(u.scales.x.max, 'x');

lfty = u.valToPos(u.scales.y.min, 'y');
widy = u.valToPos(u.scales.y.max, 'y') + (valYscaleBefore - clientYMove) ;

zoomed(lftx, widx, lfty, widy);
};

let animateMove = function(e){
clientYMove = e.clientY;

if (!rafPending) {
rafPending = true;

requestAnimationFrame(move);
}
}




leftAxisScale.addEventListener("mousedown", (e) => {
valYscaleBefore = e.clientY;
leftAxisScale.addEventListener("mousemove", animateMove, { passive: true });
}, false);

leftAxisScale.addEventListener("mouseup", (e) => {
leftAxisScale.removeEventListener("mousemove", animateMove, { passive: true });
}, false);

/* end: left axis scale */


}

return {
Expand Down Expand Up @@ -504,6 +554,10 @@







</script>


Expand Down
2 changes: 1 addition & 1 deletion demos/candlestick-ohlc.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
});

opts.series.forEach(series => {
series.paths = () => null;
//series.paths = () => null;
series.points = {show: false};
});
},
Expand Down