问题描述
我想知道是否可以将图像添加到amChart中的CategoryAxes.
I was wondering if there's a way to add images to the CategoryAxes in amChart.
我找到了一个可以在每个图形中包含图像的演示,但是这些图像始终在图形附近和/或具有一定的偏移量,但是我需要使这些图像保持在图表顶部.
I found a demo that can include images in each graph, but these are always near the graph and/or given an offset of them, but I need to have those images stay on top of the chart.
我尝试在CategoryAxes的category字段中输入<img src ="">
,但是它仅显示文本,并显示所有标签.
I tried to give an <img src ="">
to the category field on the CategoryAxes, but it displays only text, showing all the tag.
我阅读了该类别可以具有的方法和选项,但是我没有找到任何可以显示图像的内容,因此,可以添加它们吗?
I read the methods and options this category can have, but I didn't find anything that says it can haves images displayed, so, it's possible to add them?
添加:
//Doesn't works the "category" option
"dataProvider": [
"category": "<img src='link_to_image.png'>",
"column-1": 120.99,
//other values...
"myBullet1": "<img src='link_to_image.png'>" //this with graph works, but doesn't puts it on top of the chart
],
"graphs": [
"customBulletField": "myBullet1",
"bulletOffset": 20,
"bulletSize": 34,
//other values
],
//other options
推荐答案
好吧,amCharts的支持回答了我这个问题.在这里,我将jsFiddle留给将来需要的人:
Well, the support from amCharts answered me making this question possible. Here I leave the jsFiddle for those who needs this in the future:
jsFiddle amCharts演示
jsFiddle Demo by amCharts
...
img.setAttributeNS('http://www.w3.org/1999/xlink', 'href', 'http://www.amcharts.com//lib/3/images/1.gif');
在这一行中,因为它位于for循环中,所以可以在数组中具有一组图像,然后使用可以使其递增的计数器可以将所需的图像放置在每个类别轴中.
In this line, as it's inside a for loop, you can have a set of images in an array, then with a counter that you can make it increment you can put the image you need in each category axis.
这篇关于带图标的amChart CategoryAxes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!