Highchart with scaled images in column bars?

蹲街弑〆低调 提交于 2019-12-30 12:13:12

问题


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 Skyscraper image as the background for the bar columns, however the background image seems to loop/tile somewhat randomly, how can i fix this.

thanks

        color: {
           pattern: 'http://www.aperfectworld.org/clipart/buildings/buildings08g.gif',
           width: '100%',
           height: '100%'
        }

http://jsfiddle.net/2BqSY/4/


回答1:


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.)



来源:https://stackoverflow.com/questions/16260053/highchart-with-scaled-images-in-column-bars

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