Search code examples
javascriptangularjsd3.jsnvd3.jslinegraph

I am not able to get all X and Y axis points in nvd3 graph. Am I missing out any options?


graph which shows expenditure.

as graph shown in image I am not able to get all the X and Y intersection points on axis. As well as I want to highlight intersection points with dark circle. Help will be appreciated

code to fill the chart is:
options :
chart: { type: 'lineChart', height: 300, margin : { top: 120, right: 100, bottom: 40, left: 100 }, x: function(d){ return d.x; }, y: function(d){ return d.y; }, useInteractiveGuideline: false, tooltips: false, xAxis: { tickFormat: function(d) { return d3.time.format('%x')(new Date(d)); }, showMaxMin: false
}, yAxis: { tickFormat: function(d) { return '$' + d3.format('.0f')(d) } }, }

var dates = [new Date('12/1/2017'),new Date('12/2/2017'),new Date('12/3/2017'),new Date('12/4/2017'),new Date('12/5/2017')];
var spend = [22, 14, 13, 11, 12];
data = genrateData();
function generateData() {
    var dailySpend = [];                
    for(var i=0; i < dates.length; i++){
        dailySpend.push({x: dates[i], y: spend[i]})
    }
    return [
        {
            values: dailySpend,
            key: 'Daily Spend'
        }
    ];
}

Solution

  • I think I've got an answer.

    Actually I have removed grid lines from css by giving .tick class a display: none property, which also removed points from the graph.

    If want to remove ONLY grid lines then edit the css by adding property display: none to .tick line class.