I have applied linear gradient color codes in one svg . Now i wants replace the color codes to any one image as background within the svg.
My linear color gradient code below :
var ctx = ['rgba(243, 234, 255, 0.5)', 'rgba(134,104,155, 0.5)'];
var ctxValue = this.svg
.append('defs')
.append('linearGradient')
.attr('x1', '0%')
.attr('x2', '0%')
.attr('y1', '0%')
.attr('y2', '100%');
ctxValue
.selectAll('stop')
.data(ctx)
.enter()
.append('stop')
.style('stop-color', function(d) {
return d;
})
.attr('offset', function(d, i) {
return 100 * (i / (ctx.length - 1)) + '%';
});
var linearColor = '#ctxValue-' + valId;
this.ctxPattern.style('fill', 'url(' + linearColor + ')');
Now color gradient working as a background of svg .
how to applied the image in the svg instead of color gradient. any one please help .