putting an image in each category in Highcharts

℡╲_俬逩灬. 提交于 2020-01-04 05:54:22

问题


I have this code:

http://jsfiddle.net/waqLq62d/

and let me know how to put an image at the beginning of the category. so as it is shown in this picture.

I do not know how, thank you very much.

$('#container').highcharts({

        xAxis: {
            categories: [data.d[300].nomindicador, data.d[500].nomindicador, data.d[600].nomindicador,data.d[700].nomindicador, data.d[900].nomindicador],
            title: {
                text: null
            },
            labels: {

            align: 'left',
            x: 10,
            y: -20

            }

        },
        yAxis: {

            title: {
                text: 'Resultado',
                 align: 'right'
            }

        },
        tooltip: {
            valueSuffix: ' dollars'
        },
        plotOptions: {
            bar: {
                dataLabels: {
                    enabled: false
                }
            }
        },
        legend: {
            layout: 'vertical',
            align: 'center',
            verticalAlign: 'bottom',
            x: -40,
            y:40 ,
            floating: true,
            borderWidth: 1,
            backgroundColor: '#FFFFFF',
            shadow: true
        }

回答1:


To achieve this, you have to have to use the useHTML property on the labels object and set it to true.

Then, you have to use the format property to inject an HTML image in your label.

Full working example here:

http://jsfiddle.net/u3o416xb/

The code should look something like this:

labels: {
    x: -5,
    y: -20,
    useHTML: true,
    format: '<div style="position: absolute; left: 40px"> my label </div> <img style="height: 30px; width: 30px; margin-top: 10px"  src="https://cdn2.iconfinder.com/data/icons/free-3d-printer-icon-set/512/Plastic_model.png"></img>'
}



来源:https://stackoverflow.com/questions/34573692/putting-an-image-in-each-category-in-highcharts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!