Highchart with scaled images in column bars?

前端 未结 1 966
无人及你
无人及你 2021-01-16 07:28

How can i add images to the bar columns that scale correctly to the bar heights.

see jsfiddle example below, im trying to do a chart that compares heights using a Sk

相关标签:
1条回答
  • 2021-01-16 07:54

    I think it may be not possible using patterns, but you can add some images using renderer: http://jsfiddle.net/YZkPX/

        chart: {
            renderTo: 'container',
            type: 'column',
            events: {
                load: function () {
                    var chart = this,
                        d = chart.series[0].data;
    
                    for (var i = 0, len = d.length; i < len; i++) {
                        var p = d[i],
                            x = chart.plotLeft + p.plotX - p.pointWidth / 2,
                            y = chart.plotTop + p.plotY,
                            w = p.pointWidth,
                            h = p.graphic.height;
                        chart.renderer.image('http://www.aperfectworld.org/clipart/buildings/buildings08g.gif', x, y, w, h).add();
    
                    }
    
                }
            }
        },
    

    Now you need to recalculate x/y/w/h when series is redraw (zoom/show/hide etc.)

    0 讨论(0)
提交回复
热议问题