Baseline series should use min/max price range in visible range to calculate gradient stops
See original GitHub issueLightweight 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:
Scale margins moved to top:
Scale margins moved to bottom:
CodeSandbox/JSFiddle/etc link: https://jsfiddle.net/0r3cLmjd/51/
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, this will give the same result, a color change while moving the chart up/down. See https://jsfiddle.net/ean9vj3r/1/
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.
Yes. I’ll also add a few lines to check whether the base value is price, leaving the upcoming percentage scale at
0..height
.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 👍