我正在使用 dc.js/crossfilter/d3 绘制包含以下数据的图表
var jsonStr = ([
{"date": "2011-11-14", "value": 0.1121},
{"date": "2011-11-15", "value": 0.2221},
{"date":"2011-11-16", "value": 0.3321},
{"date":"2011-11-17", "value": 0.4221},
...
{"date":"2011-11-22", "value": -0.6544},
{"date":"2011-11-23", "value": -0.3131},
{"date":"2011-11-24", "value": -0.2122},
{"date":"2011-11-25", "value": -0.0231}
]);
像这样设置我的维度:
// set up my date objects
var timeFormat = d3.time.format("%Y-%m-%d");
jsonStr.forEach(function (e) {
e.date = timeFormat.parse(e.date);
e.dd = new Date(e.date);
e.month = d3.time.month(e.dd);
});
// feed it through crossfilter
var ndx = crossfilter(jsonStr);
var all = ndx.groupAll();
//setup dimmensions
var dateDimension = ndx.dimension(function (d) {
return d.dd;
});
//fluctuation chart, I bet i'm doing something wrong here...
var fluctuation = ndx.dimension(function (d) {
return d.value.toFixed(2);
// return Math.round(d.value);
});
绘制图表时,我无法选择单个负值。有人知道我需要做什么吗?
完整的小提琴:http: //jsfiddle.net/wbott70/Fvw9m/