Open PierBJX opened 6 years ago
Try using below code, solved my problem of x-axis consistent dates-
xAxis: {
axisLabel: '',
tickValues: function(d){
var between = []
var secondDate = d[0].values[d[0].values.length-1].date;
var firstDate = d[0].values[0].date;
//get all dates between max and min date
while (firstDate <= secondDate) {
between.push(new Date(firstDate));
firstDate.setDate(firstDate.getDate() + 4);
}
return between;
},
showMaxMin: false,
rotateLabels: -90,
tickFormat: function (d) {
return d3.time.format('%m/%d/%y ')(new Date(d));
}
}
I am doing a scatter plot with ng2-nvd3. The data is fetch on the server. From the response I create my data and the option in order to display the chart. This works properly, however the X-Axis is equal to 0. So all the points are the Y-Axis. See the picture.
However, when I resize the windows of the browser (minimise or maximise) or I open the console browser, the chart changes and everything is alright.
Like if it was updated the layout. Maybe it is related to the callback or something like that I don't know. I tried to add detectChanges() of ChangeDetectorRef but nothing changes.
In my component.ts: Goto_PCA is a function called in the ngOnInit().
And in my HTML:
<nvd3 [options]="chart" [data]="data"></nvd3>