You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/10/25 09:02:14 UTC
[echarts] 01/01: fix(line): fix visual gradient when coords are
between two stops.
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch fix-line-visual
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 2b63cd78c15952e0ad3693cde38c29002098d769
Author: pissang <bm...@gmail.com>
AuthorDate: Mon Oct 25 16:47:56 2021 +0800
fix(line): fix visual gradient when coords are between two stops.
---
src/chart/line/LineView.ts | 6 ++++++
test/line-visual2.html | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/src/chart/line/LineView.ts b/src/chart/line/LineView.ts
index 6da8628..e062bb2 100644
--- a/src/chart/line/LineView.ts
+++ b/src/chart/line/LineView.ts
@@ -224,6 +224,12 @@ function clipColorStops(colorStops: ColorStop[], maxSize: number): ColorStop[] {
if (prevInRangeColorStop) {
newColorStops.push(lerpStop(prevInRangeColorStop, stop, maxSize));
}
+ else if (prevOutOfRangeColorStop) { // If there are two stops and coord range is between these two stops
+ newColorStops.push(
+ lerpStop(prevOutOfRangeColorStop, stop, 0),
+ lerpStop(prevOutOfRangeColorStop, stop, maxSize)
+ );
+ }
// All following stop will be out of range. So just ignore them.
break;
}
diff --git a/test/line-visual2.html b/test/line-visual2.html
index 44f2b9b..f45dad5 100644
--- a/test/line-visual2.html
+++ b/test/line-visual2.html
@@ -41,6 +41,7 @@ under the License.
<div id="main1"></div>
<div id="main2"></div>
<div id="main3"></div>
+ <div id="main4"></div>
@@ -495,5 +496,45 @@ under the License.
})
</script>
+
+ <script>
+ require([
+ 'echarts'
+ ], function (echarts) {
+
+ const option = {
+ xAxis: {
+ type: 'category',
+ data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
+ },
+ yAxis: {
+ type: 'value'
+ },
+
+ visualMap: {
+ type: "piecewise",
+ pieces: [{
+ gte: -1,
+ lte: 1,
+ color: '#000'
+ }],
+ outOfRange: { color: '#F43915' }
+ },
+ series: [
+ {
+ data: [0.2, 0.24, 0.18, 0.15, 0.18, 0.27, 0.25],
+ type: 'line'
+ }
+ ]
+ };
+ const myChart = testHelper.create(echarts, 'main4', {
+ title: [
+ 'Gradient should be black.',
+ 'https://github.com/apache/echarts/issues/15885'
+ ],
+ option: option
+ });
+ })
+ </script>
</body>
</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org