2013-05-30 17 views
1

我對每個圖表有多個圖形,對於某些未知(對我)來說,每個圖形的起點和終點都連接起來。 enter image description here 簡單的問題:如何刪除它?我無法在控制它的文檔中找到任何內容。AmCharts - 通過起點和終點連接的圖形

我的代碼如下:

lineChart = function(id, period) { 
    var chart, data = []; 
    var cData = chartData[id]; 
    AmCharts.ready(function() { 
     for (item in cData) { 
      var i = cData[item]; 
      data.push({ 
       date: new Date(i.date), 
       impressions: i.impressions, 
       clicks: i.clicks, 
       conversions: i.conversions, 
       ctr: i.ctr, 
       profit: i.profit, 
       cost: i.cost, 
       revenue: i.revenue 
      }); 
     } 

     chart = new AmCharts.AmSerialChart(); 
     chart.dataProvider = data; 
     chart.categoryField = "date"; 
     chart.balloon.color = "#000000"; 

     // AXES 
     // category 
     var categoryAxis = chart.categoryAxis; 
     categoryAxis.fillAlpha = 1; 
     categoryAxis.fillColor = "#FAFAFA"; 
     categoryAxis.gridAlpha = 0; 
     categoryAxis.axisAlpha = 0; 
     categoryAxis.minPeriod = period; 
     categoryAxis.parseDates = true; 
     categoryAxis.gridPosition = "start"; 
     categoryAxis.position = "bottom"; 

     // value 
     var valueAxis = new AmCharts.ValueAxis(); 
     valueAxis.dashLength = 5; 
     valueAxis.axisAlpha = 0; 
     valueAxis.integersOnly = true; 
     valueAxis.gridCount = 10; 
     chart.addValueAxis(valueAxis); 

     // GRAPHS 
     // Impressions graph            
     var graph = new AmCharts.AmGraph(); 
     graph.title = "Impressions"; 
     graph.valueField = "impressions"; 
     graph.balloonText = "[[title]]: [[value]]"; 
     //graph.lineAlpha = 1; 
     graph.bullet = "round"; 
     chart.addGraph(graph); 

     // Clicks graph 
     var graph = new AmCharts.AmGraph(); 
     graph.title = "Clicks"; 
     graph.valueField = "clicks"; 
     graph.balloonText = "[[title]]: [[value]]"; 
     graph.bullet = "round"; 
     chart.addGraph(graph); 

     // Conversions graph 
     var graph = new AmCharts.AmGraph(); 
     graph.title = "Conversion"; 
     graph.valueField = "conversions"; 
     graph.balloonText = "[[title]]: [[value]]"; 
     graph.bullet = "round"; 
     chart.addGraph(graph); 

     // LEGEND 
     var legend = new AmCharts.AmLegend(); 
     legend.markerType = "circle"; 
     chart.addLegend(legend); 

     var chartCursor = new AmCharts.ChartCursor(); 
     chartCursor.cursorPosition = "mouse"; 
     if(period == 'hh') 
      chartCursor.categoryBalloonDateFormat = "MMM DD, JJ:00"; 
     chart.addChartCursor(chartCursor); 
     // WRITE 
     chart.write(id); 
    }); 
}; 

回答

0

問題是每個圖表都是在它自己的AmCharts.ready方法中呈現的。該文檔聲明它是允許的,但它不適用於我,因此我將所有渲染都包含在一個ready方法中,並且問題已修復。

1

這看起來像數據的問題。確保您的數據點嚴格按照升序排列。

要驗證實際數據的外觀如何,請在代碼中添加以下第二行。然後運行您的谷歌瀏覽器與控制檯打開的圖表(F12然後選擇控制檯選項卡)

chart.dataProvider = data; 
console.debug(data); 

檢查數據點的不規則性。特別是最後兩個。