2011-10-21 12 views
9

Highchart tiene una opción que me permitirá establecer un marcador a cierto valor.establecer un marcador de símbolo con Highchart

highchart doc:

... 
    data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, { 
     y: 26.5, 
     marker: { 
      symbol: 'url(/demo/gfx/sun.png)' 
     } 
    }, 23.3, 18.3, 13.9, 9.6] 
... 

Como se puede ver, las posiciones 26,5 ganancias de una imagen PNG como su marcador.

Mi pregunta es: ¿Cómo puedo configurarlo en un cierto valor de mi matriz?

$.getJSON('ajax/lineChart.ajax.php', function(data) {   
    $.each(data, function(key, value) { 
     var series = { 
      data: [ { 
       y: 0, 
       marker: { 
        symbol: 'url(img/fail.png)' 
       } 
      }], //data array for new series 
      name: key, 
      marker: { 
        symbol: 'square' 
       } 
     }; 
     series.data = value; 
     options.series.push(series); // <-------- pushing series object 
    }); 
    var chart = new Highcharts.Chart(options); 
}); 

intenté esto, pero no apareció nada. La tabla se ejecutó sin el marcador.

Respuesta

2

La línea:

series.data = value; 

sobrescribir lo que escribió en

var series = { 
     data: [ { 

No estoy seguro de lo que tiene en los "datos" variable, pero supongo que su es como [clave: [val1 , val2, ...], ...], intente reemplazar "series.data = value" con lo siguiente:

var list= new Array(); 
foreach(var v as value){ 
    if (v==0){ //or what ever condition you need to use a different mark 
     var m={ 
      y: v, 
      marker: { 
       symbol: 'url(img/fail.png)' 
      }}; 
     list.push(m);  
    } 
    else{ 
     list.push(v); 
    } 
} 
series.data = list; 
Cuestiones relacionadas