2013-08-12 20 views
3

我正在使用nvd3.js顯示帶有3個不同鍵的圖形。在那些3,1中有很多的座標,其餘的2個只有一個座標。現在這些單一座標不能正確顯示。我的代碼是這樣的:點在nvd3 ghaph中不能清晰可見

nv.addGraph(function() { 
    var chart = nv.models.lineChart().margin({ 
     top: 30, 
     right: 20, 
     bottom: 50, 
     left: 45 
    }).showLegend(true).tooltipContent(function (key, y, e, graph) { 
     return '<h3>' + key + '</h3>' + '<p>' + e + '% at ' + y + '</p>' 
    }); 

    chart.xAxis.tickFormat(function (d) { 
     return d3.time.format('%x')(new Date(d)) 
    }); 

    d3.select('#lineChart svg') 
     .datum(data) 
     .transition().duration(500) 
     .call(chart); 

    nv.utils.windowResize(chart.update); 
    return chart; 
}); 

data = [{ 
    "values": [{ 
     "x": 1025409600000 , 
      "y": 2 
    }, { 
     "x": 1028088000000 , 
      "y": 4 
    }, { 
     "x": 1030766400000 , 
      "y": 1 
    }, { 
     "x": 1033358400000 , 
      "y": 3 
    }, { 
     "x": 1036040400000 , 
      "y": 0 
    }, { 
     "x": 1038632400000 , 
      "y": 3 
    }], 
     "key": "Cool" 
},{ 
"values": [{ 
     "x": 1025409600000 , 
     "y": 2 
      }], 
"key":hot 
    } 
] 

原以爲hot點出如果我鼠標光標,但它是不可見的位置。 請指導我如何使它可見,如果鑰匙只有一個座標。 在此先感謝。

更新了圖片 enter image description here enter image description here

+0

,你可以請你的輸出圖像 –

+0

請檢查更新的圖像。 – Mausumi

回答

6

你需要從0

.nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point { 
    fill-opacity: .7; 
} 

增加不透明度,您可以通過使用chart.size(300)

這裏增加了圓圈的大小是一個工作例如:http://plnkr.co/edit/fFqSny?p=preview

+0

非常感謝。它的工作和新對我來說。 – Mausumi

+0

對不起,它正在增加的大小。但是最初我只有一個座標,那麼直到我沒有把它放在那個特定點上時,它纔會顯示出來。但我想在鼠標懸停之前顯示這些點。 – Mausumi

+0

該plunk從一開始就使用默認大小和一個數據點。 http://plnkr.co/edit/4OnDy0?p=preview 你可以發佈你的CSS? – WolfgangCodes

-1

你也可以使用'fillOpacity'。

例如chart.bars1.fillOpacity(0.7)

參見:

Hand over fillOpacity for bars in multiBar and multiBarHorizontal charts #1614https://github.com/novus/nvd3/issues/707

+0

雖然這個鏈接可能回答這個問題,但最好在這裏包含答案的重要部分,並提供供參考的鏈接。如果鏈接頁面更改,則僅鏈接答案可能會失效。 - [來自評論](/評論/低質量帖/ 13341091) –

+0

任何建設性的批評我怎麼能改善這個答案?似乎沒有任何「答案的重要部分」,因此我只是舉了一個例子。 – j2k