在高图中添加图像

时间:2013-06-14 03:12:52

标签: javascript highcharts

我正在尝试在高光图中添加图像但我看不到图像。 请参阅以下代码:

var currentECGOptions = {
    chart: {
        renderTo: 'currentECGContainer',
        events: {  
            load: function () {
                alert("load this function");
               this.renderer.image('/Content/Images/logo.png', 100, 100, 30, 30)
                    .on('click' , function(){location.href='http://www.highcharts.com'})
                    .css({cursor:'Pointer'})

                    .add();
                    }
                }    
    },

    navigator: {
        enabled: true,
        maskFill: 'rgba(255, 255, 255, 0.45)',
        series: {
            type: 'areaspline',
            color: 'rgba(255, 255, 255, 0.00)',
            fillOpacity: 0.8,
            dataGrouping: {
                smoothed: true
            },
            lineWidth: 1,
            lineColor: 'blue',
            fillColor: {
                linearGradient: {
                    x1: 0,
                    y1: 0,
                    x2: 0,
                    y2: 1
                },
                stops: [[0, '#FF8000'], [1, '#FFFF00']]
            },
            marker: {
                enabled: false
            },
            shadow: false
        },
        yAxis: {
            reversed: false
        }
    },
    series: [{
        showInLegend: false,
        data: [null, null]
    }]
     };

currentECGOptions = jQuery.extend(true, {}, options, currentECGOptions);

var currentECG = new Highcharts.Chart(currentECGOptions);

currentECG.setTitle({ text: "CURRENT ECG" });
currentECG.showLoading();

2 个答案:

答案 0 :(得分:0)

您应该可以通过css设置图像:

HTML     

CSS     #mychart {         background-image:url('image.png');     }

JS     $('#mychart')。highcharts(...)

答案 1 :(得分:0)

尝试在创建图表后添加徽标,而不是在events选项中添加徽标。它可能看起来像这样:

/* create the chart */
var currentECG = new Highcharts.Chart(currentECGOptions);

/* add the image to the new chart, after it's been created */
currentECG.renderer.image('/Content/Images/logo.png', 100, 100, 30, 30).on('click' , function(){location.href='http://www.highcharts.com'}).css({cursor:'Pointer'}).add();

我希望这有帮助!