简体   繁体   中英

Highcharts Error #13 for bullet charts

I'm trying to use bullet graph in my page but I have an error "Highcharts Error #13", I found solutions here, but it didn't help me at all.

I took this code from fiddle, and just wanted to insert it to my code. This code works fine in fiddle but after I found error in my console, I moved this in plunker and nothing happens, same problem in console.

Somebody can me define what I'm doing wrong?

there is my js file:

//-------------------------------------------------------
Highcharts.Renderer.prototype.symbols.line = function(x, y, width, height) {
    return ['M',x ,y + width / 2,'L',x+height,y + width / 2];
};
//-------------------------------------------------------
Highcharts.setOptions({
    chart:{
        type:'bar',
        margin:[5,15,10,100],
    },
    credits:{enabled:false},
    exporting:{enabled:false},
    legend:{enabled:false},
    title:{text:''},
    xAxis:{
        tickLength:0,
        lineColor:'#999',
        lineWidth:1,
        labels:{style:{fontWeight:'bold'}}
    },
    yAxis:{
        min:0,
        minPadding:0,
        maxPadding:0,
        tickColor:'#ccc',
        tickWidth:1,
        tickLength:3,
        gridLineWidth:0,
        endOnTick:true,
        title:{text: ''},
        labels:{
            y:10,
            style:{
                fontSize:'8px'
            },
            formatter:function(){
                if (this.isLast){
                    return this.value + ' %';
                }
                else{
                    return this.value;
                }
            }
        }
    },
    tooltip:{
        enabled:true,
        backgroundColor:'rgba(255, 255, 255, .85)',
        borderWidth:0,
        shadow:true,
        style:{fontSize:'10px',padding:8},
        formatter:function() {
            return this.series.name + ": <strong>" + Highcharts.numberFormat(this.y,2) + "</strong>";
        }
    },
    plotOptions:{
        bar:{
            color:'#000',
            shadow:false,
            borderWidth:0,
        },
        scatter:{
            marker:{
                symbol:'line',
                lineWidth:3,
                radius:8,
                lineColor:'#000'
            }
        }
    }
});
//-------------------------------------------------------
$(document).ready(function() {

var chart1 = new Highcharts.Chart({
    chart:{renderTo:'container'},
    xAxis:{categories:['bar']},
    yAxis:{
        max:100,
        labels:{y:10,style:{fontSize:'8px'}},
        plotBands:[{from:0,to:70,color: 'rgba(103,103,103,.35)'},
            {from:70,to:85,color: 'rgba(153,153,153,.35)'},
            {from:85,to:100,color: 'rgba(204,204,204,.35)'}]
    },
    series:[{name:'Measure',pointWidth:10,data:[80]},
        {name:'Target',type: 'scatter',data:[90],}]
});
}(jQuery));
//-------------------------------------------------------

and this div in my page

<div id="container" style="height:36px;width:350px;"></div>

You all code should be placed in document.ready.

$(document).ready(function() {
//-------------------------------------------------------
Highcharts.Renderer.prototype.symbols.line = function(x, y, width, height) {
  return ['M', x, y + width / 2, 'L', x + height, y + width / 2];
};

Fixed demo: http://jsfiddle.net/hqykwrjd/1/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM