question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Baseline series should use min/max price range in visible range to calculate gradient stops

See original GitHub issue

Lightweight Charts Version: 3.7.0

Steps/code to reproduce:

  • Add BaselineSeries
  • Set a custom price scale
  • Assign scaleMargins
var series = chart.addBaselineSeries({
  priceScaleId: 'my-custom-scale',
  scaleMargins: {
    top: 0.8,
    bottom: 0,
  },
  bottomFillColor2: 'rgba(0,0,0,1)',
  bottomFillColor1: 'rgba(0,0,0,0)',
  topFillColor2: 'rgba(0,0,0,0)',
  topFillColor1: 'rgba(0,0,0,1)',
  baseValue: { type: 'price', price: 180 },
});

Actual behavior: The baseline gradient does not fully render the assigned color stop from the configuration.

Expected behavior: The baseline gradient should use the scaleMargins to compute the color stops.

// src/renderers/baseline-renderer.ts:21
const gradient = ctx.createLinearGradient(0, 0, 0, data.bottom);

data.bottom should not be the height of the current chart, but the height of the series with the current scaleMargins.

Screenshots: Expected here would be a full-black (#000000) top and bottom gradient.

Without scale margins: image

Scale margins moved to top: image

Scale margins moved to bottom: image

CodeSandbox/JSFiddle/etc link: https://jsfiddle.net/0r3cLmjd/51/

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
EastingAndNorthingcommented, Feb 14, 2022

Have you tried to move a series after that vertically? How the color is changing on this?

Yes, this will give the same result, a color change while moving the chart up/down. See https://jsfiddle.net/ean9vj3r/1/

What do you think about that @EastingAndNorthing?

I agree, compared to the baseline series on Tradingview, it does seem more logical to use the entire scale as a gradient if we’re talking about percentage values.

@EastingAndNorthing Do you still want to create a pull request for that?

Yes. I’ll also add a few lines to check whether the base value is price, leaving the upcoming percentage scale at 0..height.

1reaction
EastingAndNorthingcommented, Feb 11, 2022

Regarding your second comment, I think the most logical situation would be that the gradient is simply based on the min/max values of the series (or well, the top/bottom of the pane).

Having extra options for the start/end point in the API would seem cluttered, in my opinion 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

ScottPlot 4.1 Cookbook
If data values extend beyond the min/max range displayed by a colorbar you can indicate the colormap is clipping the data values and...
Read more >
mne.Epochs — MNE 1.2.2 documentation - MNE-Python
The baseline (a, b) includes both endpoints, i.e. all timepoints t such that a <= t <= b . Correction is applied to...
Read more >
Gradient QML Type | Qt Quick 6.4.1
A gradient is defined by two or more colors, which will be blended seamlessly. The colors are specified as a set of GradientStop...
Read more >
Conditional Formatting of Excel Charts - Peltier Tech
Except for some simple built-in formats, conditional formatting of worksheet ranges requires formulas to determine which cells should take on the formatting ...
Read more >
Kernel Profiling Guide :: Nsight Compute Documentation
When defining the range markers using cu(da)ProfilerStart/Stop , prefer the CUDA driver API calls cuProfilerStart/Stop . Internally, NVIDIA ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found