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

demo/stock-orderbook #20885

Merged
merged 18 commits into from
May 10, 2024
Merged

demo/stock-orderbook #20885

merged 18 commits into from
May 10, 2024

Conversation

kamil-musialowski
Copy link
Contributor

@kamil-musialowski kamil-musialowski commented Mar 19, 2024

Created a live demo simulating stock orderbook charts.

@highsoft-bot
Copy link
Collaborator

Webpack monitoring

LGTM 👍

@highsoft-bot
Copy link
Collaborator

File size comparison

No differences found

@highsoft-bot
Copy link
Collaborator

highsoft-bot commented Mar 19, 2024

Visual test results - No difference found


Samples changed

Change type Sample
Modified samples/stock/demo/orderbook-chart/demo.js
Modified samples/highcharts/studies/map-activate/demo.js
Modified samples/highcharts/studies/map-activate/demo.js
Modified samples/stock/demo/orderbook-chart/demo.js
Modified samples/stock/demo/orderbook-chart/demo.js
Modified samples/stock/demo/orderbook-chart/demo.js
Modified samples/stock/demo/orderbook-chart/demo.js
Modified samples/stock/demo/orderbook-chart/demo.js
Modified samples/stock/demo/orderbook-chart/demo.js
Modified samples/stock/demo/orderbook-chart/demo.js
Modified samples/stock/demo/orderbook-chart/demo.js
Added samples/stock/demo/orderbook-chart/demo.js

Copy link
Contributor

@pawelfus pawelfus left a comment

Choose a reason for hiding this comment

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

Nice!

In addition to inline comments:

  • tooltip should be updated, to reflect what is being displayed, not random X-values and negative numbers
    Zrzut ekranu 2024-03-19 o 13 39 24
  • fix the black line in the middle of the chart
  • did you consider using category Axis instead of translated dataLabels?

samples/stock/demo/orderbook-chart/demo.js Outdated Show resolved Hide resolved
samples/stock/demo/orderbook-chart/demo.js Show resolved Hide resolved
samples/stock/demo/orderbook-chart/demo.js Outdated Show resolved Hide resolved
samples/stock/demo/orderbook-chart/demo.js Outdated Show resolved Hide resolved
@kamil-musialowski
Copy link
Contributor Author

kamil-musialowski commented Mar 20, 2024

@pawelfus Thank you!

  • tooltip done
  • black line looks like a bug, it disappears when we decrease the chart.marginTop (fixed with crisp)
  • I did consider using category axis, but felt more comfortable with dataLabels, since both price and Bids/Asks are values strictly correlated with the point, and axes don't matter on this chart that much

Copy link
Contributor

@pawelfus pawelfus left a comment

Choose a reason for hiding this comment

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

Neat! Just a few minor things:

  • Is it Orderbook or Order Book? I mean the title.
  • Exporting throws errors
  • Missing a11y chart's descriptions (in chart config and in demo itselft)
  • Let's improve the labels further:

image

  • enable the thousands-separator
  • if the righthand labels have decimal point, then the left hand should too. I would say XXX XXX.00 and XXX XXX.50 should be fine. Perhaps one decimal place could be better, hard to say

samples/stock/demo/orderbook-chart/demo.html Outdated Show resolved Hide resolved
@kamil-musialowski
Copy link
Contributor Author

In terms of "Orderbook" vs "Order book", I've seen both but the second one seems to be more popular and correct, therefore I went with this one. Thanks :)

Copy link
Member

@DJTechnoo DJTechnoo left a comment

Choose a reason for hiding this comment

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

Nice orderbook demo and great work! 👍
Just a visual thing: When the asks exceed 1 million increases order of magnitude, the data label jumps and creates visual noise. On the bids side it looks fine and steady.
Other than that, see small comment.

To discuss: Does it update overwhelmingly fast, or is it intended to work this way?

samples/stock/demo/orderbook-chart/demo.js Outdated Show resolved Hide resolved
Copy link
Member

@pawellysy pawellysy left a comment

Choose a reason for hiding this comment

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

Looks great! Good job 🎉

@kamil-musialowski
Copy link
Contributor Author

@DJTechnoo Yes, it should update that fast :D
For the dataLabels, yeah that's the case of the right alignment, and I'm not sure if that can be changed to be honest, but doesn't look bad imo - what do you think @pawelfus ?

@pawelfus
Copy link
Contributor

I saw that too. It's probably a matter of preference, but I would also rather see it without jumping. However, I'm not sure how to fix it. Maybe @TorsteinHonsi has an idea

Copy link
Contributor

@pawelfus pawelfus left a comment

Choose a reason for hiding this comment

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

Nitpicking 🧵

samples/stock/demo/orderbook-chart/demo.details Outdated Show resolved Hide resolved
samples/stock/demo/orderbook-chart/demo.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@TorsteinHonsi TorsteinHonsi left a comment

Choose a reason for hiding this comment

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

Thanks, it looks great! Some change requests inline.

samples/stock/demo/orderbook-chart/demo.css Show resolved Hide resolved
samples/stock/demo/orderbook-chart/demo.js Outdated Show resolved Hide resolved
@TorsteinHonsi
Copy link
Collaborator

I saw that too. It's probably a matter of preference, but I would also rather see it without jumping. However, I'm not sure how to fix it. Maybe TorsteinHonsi has an idea

@pawelfus Not a good one. Clearly it comes from re-aligning to the right. But instead of keeping the right edge fixed, it animates the x. If someone wants to dig int, feel free. The issue may lie either in the data labels logic, or deeper in the SVGLabel/SVGElement itself.

@pawelfus
Copy link
Contributor

pawelfus commented Apr 5, 2024

Good point. It seems to be exactly as you said: aligning items animates x. Simple demo: https://jsfiddle.net/BlackLabel/tbcroaeg/

We could disable animations for dataLabels, but accidentally we missed that (we can disable the Chart's animation, but that's not the point of this demo). Setting label.placed = false works around the issue: https://jsfiddle.net/BlackLabel/tbcroaeg/1/

However, I don't think it's a good & clean workaround to include in the official demo. Until we support nice labels/numbers animations should we just set a hard max for the value? To be 999 999? And hard min (100 000)?

@kamil-musialowski
Copy link
Contributor Author

Merge #20993 first, before merging the demo.

kamil-musialowski

This comment was marked as duplicate.

@TorsteinHonsi
Copy link
Collaborator

@pawelfus @kamil-musialowski I merged in the fix for the jumping right label, but it turns out it is still jumping. Any ideas? It probably still has to do with the alignment, but the animateX flag returns true for these cases.

@kamil-musialowski
Copy link
Contributor Author

I had a look into that, but I couldn't come up with anything reasonable 🤔

@pawelfus
Copy link
Contributor

@pawelfus @kamil-musialowski I merged in the fix for the jumping right label, but it turns out it is still jumping. Any ideas? It probably still has to do with the alignment, but the animateX flag returns true for these cases.

Found the reason: https://jsfiddle.net/BlackLabel/zf1q7cdb/2/

In short, we have two align() calls for each label in the demo. The first one aligns according to x+y options. The second one comes from justifyDataLabel() - where we align to the plotting area. That means x option always changes, so we can observe the animation.

@TorsteinHonsi
Copy link
Collaborator

Another problem is that the right-justified data label actually has align: 'left', so it effectively ducks our animation fix. Trying out some alternative approach here: #21093

@TorsteinHonsi
Copy link
Collaborator

@pawelfus I give up :( Any more ideas? Or should we modify the data so we don't get this situation?

@TorsteinHonsi
Copy link
Collaborator

TorsteinHonsi commented May 3, 2024

Wait a minute, just want to try one more thing, to implement alignTo for other series than pie. In addition to fixing this issue, the config will also look much cleaner, and avoid the hacky nature of setting x to -999 or 999.

Draft PR: #21117
Stock orderbook with the new option applied: https://jsfiddle.net/highcharts/zaou38t4/

@kamil-musialowski
Copy link
Contributor Author

@TorsteinHonsi Thank you, the alignTo looks perfect. I will merge the master and add the property to the demo, once #21117 is merged.

@TorsteinHonsi
Copy link
Collaborator

@kamil-musialowski The alignTo option is now in the master.

@kamil-musialowski
Copy link
Contributor Author

Perfect, thank you!

@TorsteinHonsi TorsteinHonsi merged commit 17ab1bc into master May 10, 2024
13 checks passed
@TorsteinHonsi TorsteinHonsi deleted the demo/stock-orderbook branch May 10, 2024 08:51
@pawelfus pawelfus requested a review from marvin19 May 17, 2024 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants