Highcharts根据图表宽度重绘图像

时间:2014-01-31 17:40:00

标签: javascript jquery html highcharts

我正在绘制基于一定宽度重绘我的高图上的图像。我已经取得了一些进展,但我仍然无法将这些图像重新绘制在我的图表上的值内。

http://jsfiddle.net/jimbob25/V446C/

我附上了一个显示我问题的小提琴。此外,下面的代码是我迄今为止解决方案的一部分。

//Line 18
redraw: function () { //Gets called when the chart resizes
                var offset = (750 - chart.chartWidth);
                initDrawing(chart, offset);
                console.log(offset);
            }

 //Line 96  Call the initDrawing function on initial load so that it draws the arrows
 var offset = (750 - chart.chartWidth);
  initDrawing(chart, offset);

//Line 99, I have to then call init drwaing and pass in the offset so i know how far to redraw. Also i have to remove each of the arrows after each redraw.
    function initDrawing(chart, offset) {

    var renderer = chart.renderer;
    $("#goal1").remove();
    $("#goal2").remove();

1 个答案:

答案 0 :(得分:1)

以下是您的代码版本,它不是自己进行计算并尝试使用chart.renderer放置图像,而是将它们添加为客户标记散点图。通过这种方式,highcharts为您进行定位数学运算,并且维护起来更容易:

series: [{
        name: null,
        data: [100, 100, 100, 100],
        color: "#E9E9E9"
    },{
        type: 'scatter',
        data: [[0,75], [1,50], [2,35], [3,65]],
        marker: {
            symbol: 'url(http://i.imgur.com/42P7k7o.png?1)'
        }            
}]  

更新了小提琴here