2016-05-31 57 views
1

嘿,我有一個Highchart時間序列的例子。 在這個例子中,我得到所有的點作爲小數組數組(每個數組是一對x和y)。 我想知道是否可以使用fillColor屬性爲當前格式的特定點着色,如果有的話我該怎麼做?我可以在highcharts時間系列中對點進行着色嗎?

我想高亮時間序列圖中的具體點,我該怎麼辦呢?

$(function() { 
 
    $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=usdeur.json&callback=?', function (data) { 
 

 
     $('#container').highcharts({ 
 
      chart: { 
 
       zoomType: 'x' 
 
      }, 
 
      title: { 
 
       text: 'USD to EUR exchange rate over time' 
 
      }, 
 
      subtitle: { 
 
       text: document.ontouchstart === undefined ? 
 
         'Click and drag in the plot area to zoom in' : 'Pinch the chart to zoom in' 
 
      }, 
 
      xAxis: { 
 
       type: 'datetime' 
 
      }, 
 
      yAxis: { 
 
       title: { 
 
        text: 'Exchange rate' 
 
       } 
 
      }, 
 
      legend: { 
 
       enabled: false 
 
      }, 
 
      plotOptions: { 
 
       area: { 
 
        fillColor: { 
 
         linearGradient: { 
 
          x1: 0, 
 
          y1: 0, 
 
          x2: 0, 
 
          y2: 1 
 
         }, 
 
         stops: [ 
 
          [0, Highcharts.getOptions().colors[0]], 
 
          [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')] 
 
         ] 
 
        }, 
 
        marker: { 
 
         radius: 2 
 
        }, 
 
        lineWidth: 1, 
 
        states: { 
 
         hover: { 
 
          lineWidth: 1 
 
         } 
 
        }, 
 
        threshold: null 
 
       } 
 
      }, 
 

 
      series: [{ 
 
       type: 'area', 
 
       name: 'USD to EUR', 
 
       data: data 
 
      }] 
 
     }); 
 
    }); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="https://code.highcharts.com/highcharts.js"></script> 
 
<script src="https://code.highcharts.com/modules/exporting.js"></script> 
 

 
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

+0

我想強調時間序列圖中的特定點,我該怎麼做? – Brk

+0

耶通過給每個它自己的色點和設置[colorByPoint(http://api.highcharts.com/highcharts#plotOptions.bar.colorByPoint)爲true –

+0

不是一個好主意,我要的顏色具體點而不亂所有點的顏色。 – Brk

回答

4

有兩個possibilites,

1)聲明所述顏色點對象

{ 
    x: 0, 
    y: 10, 
    color: 'red' 
} 

2)point.update()

chart.series[0].data[0].update({ 
    color: 'red' 
}); 
設置顏色
相關問題