SVG Renderer in ECharts Fails to Display Base64 Encoded Data URI Image

omjgkv6w  于 3个月前  发布在  Echarts
关注(0)|答案(1)|浏览(67)

Version

5.5.1

https://codepen.io/Srikanth-Sangana/pen/ZEZQyMd

Steps to Reproduce

  1. Define a chart option with a background image using an SVG base64 data URI.
  2. Render the chart using the canvas renderer and confirm the background image displays correctly.
  3. Change the renderer to svg by setting { renderer: 'svg' } during chart initialization.
  4. Render the chart again and observe that the background image does not appear in SVG mode.

The E-chart options are below:
var dom = document.getElementById('chart-container');
var myChart = echarts.init(dom, null, {
renderer: 'svg',
useDirtyRect: false
});
var app = {};

var option;

const base64ImageUpArrow = 'data:png;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMDAwMDAwQEBAQFBQUFBQcHBgYHBwsICQgJCAsRCwwLCwwLEQ8SDw4PEg8bFRMTFRsfGhkaHyYiIiYwLTA+PlT/wgALCAFoAWgBAREA/8QAHgABAQEBAQEBAQEBAQAAAAAAAAYCAQkIBQQHAwr/2gAIAQEAAAAA9JXK8kO8ryQ7yvJDvK8kO8ryQ7yvJDvK8kOjleSHeV5Id5Xkh3leSHeV5Id5Xkh3leSHXGbEjtZsSO1mxI7WbEjtZsSO1mxI7WbEjtK8jtZsSO1mxI7WbEjtZsSO1mxI7WbEjtZsQSHeV5Id5Xkh3leSHeV5Id5Xkh3leSHeV4I7WbEjtZsSO1mxIX5v+iv9AI7WbEjtZsSO1mxJBmxI7WbEjtZsSO1/B4n/ACL9Pe4H7ebEjtZsSO1mxI7TrleSHeV5Id5Xkh/F4j/JZ9Le5f7FeSHeV5Id5Xkh1xmxI7WbEjtZsSB8SfksPpb3I/0ojtZsSO1mxI7SvI7WbEjtZsSO1/B4ofIgH097gft5sSO1mxI7WbEEh3leSHeV5IfxeJHyUAfS/uZ+tXkh3leSHeV4I7WbEjtZsSA8SvksAPpz3F/0cjtZsSO1mxJBmxI7WbEjtfweKHyIAB9S+3n7GbEjtZsSO065Xkh3leSH8XiR8lAAH057j/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uGMe4Yx/asY/tWMf2rGPcMY9wxj3DGEEExUhiMF/wAlrCVHEBrk4sRhPsQgak8SpRupRuTc/wBcv//Z';
var labelFormatters =['{{title|$61,18M} (-37,31M {upArrow|})', '$23,87M (-0,00M {upArrow|})', '$3,32M (20,55M {upArrow|})']

option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed']
},
yAxis: {
type: 'value'
},
series: [
{
data: [120, 200, 150],
type: 'bar',
label: {
show: true,
fontSize: 10,
position: 'outside',
"formatter": (params) =>{
return ${labelFormatters[params.dataIndex]} ;
},
rich: {
upArrow: {
height: 15,
align: 'center',
backgroundColor: {
image: base64ImageUpArrow // Path to your icon
}
},
}
}
}
]
};

if (option && typeof option === 'object') {
myChart.setOption(option);
}

window.addEventListener('resize', myChart.resize);

Current Behavior

When rendering an ECharts chart with a background image set using an SVG base64 data URI:

  • The background image renders correctly when using the canvas renderer.
  • The background image does not render when switching to the SVG renderer, leaving the background empty

Expected Behavior

The background image set using an SVG base64 data URI should render correctly in both canvas and SVG rendering modes.

Environment

- OS:Windows
- Browser:Chrome
- Framework:

Any additional comments?

No response

ztyzrc3y

ztyzrc3y1#

Setting a specific width for the up arrow may solve this issue, but the different behavior between SVG renderer and Canvas renderer is unexpected.

相关问题