Zander
Zander

Reputation: 1086

amChart CategoryAxes with icons

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.

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?

Add:

//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

Upvotes: 0

Views: 1298

Answers (1)

Zander
Zander

Reputation: 1086

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 Demo by amCharts

...
img.setAttributeNS('http://www.w3.org/1999/xlink', 'href', 'http://www.amcharts.com//lib/3/images/1.gif');

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.

Upvotes: 2

Related Questions