Reputation: 388
I am using third party API to render some data in the table. In the table, I need to show the user a line chart. I am using dc.js to draw a chart.
But Somehow It is not creating a chart.
input JSON object :
coinData.histoday = [
{
"time": 1542240000,
"high": 0.5026,
"low": 0.4693,
"open": 0.4917,
"volumefrom": 34761.89,
"volumeto": 16974.23,
"close": 0.4883
},
...
{
"time": 1542326400,
"high": 0.4996,
"low": 0.4616,
"open": 0.483,
"volumefrom": 18359.92,
"volumeto": 8816.43,
"close": 0.4802
}
]
Javascript code :
var ndx = crossfilter(coinData.histoday),
dateDimension = ndx.dimension(function (d) {
var myDate = new Date( d.time *1000);
return myDate;
}),
dateGroup = dateDimension.group().reduceSum(function (d) {
console.log(d);
return d.close;
}),
priceDimension = ndx.dimension(function (d) {
var myDate = new Date( d.time *1000);
return myDate;
}),
priceGroup = priceDimension.group().reduceSum(function (d) {
return d.close;
});
lineChart.width(100)
.height(40)
.dimension(priceGroup)
.group(dateGroup)
.margins({left: 0, top: 0, right: 0, bottom: 0})
.brushOn(true)
.x(d3.scaleLinear().domain([6,20]));
dc.renderAll();
You can see the code at link
Upvotes: 1
Views: 153
Reputation: 28633
if I hard code a scaleTime().domain()
I see a line
.x(d3.scaleTime().domain([new Date(1542240000*1000),new Date(1542844800*1000)]));
You should determine it based on the histoday
values.
Upvotes: 1