Skip to content

Commit 67efa47

Browse files
authored
Merge pull request apexcharts#3122 from lf94/gradient-line-area
Add ability to use gradient fill on line and area at the same time
2 parents 2cbc818 + f4f8204 commit 67efa47

File tree

5 files changed

+6107
-4977
lines changed

5 files changed

+6107
-4977
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/charts/Line.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,18 @@ class Line {
334334
if (w.config.stroke.show && !this.pointsChart) {
335335
let lineFill = null
336336
if (type === 'line') {
337-
// fillable lines only for lineChart
338337
lineFill = fill.fillPath({
339338
seriesNumber: realIndex,
340339
i
341340
})
341+
} else if (w.config.stroke.fill) {
342+
const prevFill = w.config.fill
343+
w.config.fill = w.config.stroke.fill
344+
lineFill = fill.fillPath({
345+
seriesNumber: realIndex,
346+
i
347+
})
348+
w.config.fill = prevFill
342349
} else {
343350
lineFill = w.globals.stroke.colors[realIndex]
344351
}

src/modules/settings/Defaults.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,18 @@ export default class Defaults {
330330
area() {
331331
return {
332332
stroke: {
333-
width: 4
333+
width: 4,
334+
fill: {
335+
type: 'solid',
336+
gradient: {
337+
inverseColors: false,
338+
shade: 'light',
339+
type: 'vertical',
340+
opacityFrom: 0.65,
341+
opacityTo: 0.5,
342+
stops: [0, 100, 100]
343+
}
344+
}
334345
},
335346
fill: {
336347
type: 'gradient',

src/modules/settings/Options.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,23 @@ export default class Options {
876876
lineCap: 'butt', // round, butt , square
877877
width: 2,
878878
colors: undefined, // array of colors
879-
dashArray: 0 // single value or array of values
879+
dashArray: 0, // single value or array of values
880+
fill: {
881+
type: 'solid',
882+
colors: undefined, // array of colors
883+
opacity: 0.85,
884+
gradient: {
885+
shade: 'dark',
886+
type: 'horizontal',
887+
shadeIntensity: 0.5,
888+
gradientToColors: undefined,
889+
inverseColors: true,
890+
opacityFrom: 1,
891+
opacityTo: 1,
892+
stops: [0, 50, 100],
893+
colorStops: []
894+
}
895+
}
880896
},
881897
tooltip: {
882898
enabled: true,

0 commit comments

Comments
 (0)