Tôi đang sử dụng dc.js để tạo biểu đồ chuỗi. Tôi không thể đặt trục Y bắt đầu và kết thúc như mong muốn. Ai đó có thể đề nghị làm thế nào để đạt được trục Y bắt đầu từ 90 thay vì 0? Lý tưởng nhất là tôi muốn đặt trục Y bắt đầu ở mức tối thiểu của giá trị dữ liệu và kết thúc là giá trị dữ liệu tối đa.Đặt phạm vi trục Y trong biểu đồ loạt dc
Code:
d3.csv("data/compareData.txt", function(data) {
ndx = crossfilter(data);
runDimension = ndx.dimension(function(d) {return [+d3.time.format.iso.parse(d.timestamp), +d.meterid]; });
runGroup = runDimension.group().reduceSum(function(d) { return +d.voltagemagnitude*100; });
testChart
.width(768)
.height(480)
.chart(function(c) { return dc.lineChart(c).interpolate('basis'); })
.x(d3.time.scale().domain([1366621166000, 1366621179983]))
.y(d3.scale.linear().domain([90, 100]))
.brushOn(false)
.yAxisLabel("Measured Speed km/s")
.xAxisLabel("Run")
.elasticY(true)
.dimension(runDimension)
.group(runGroup)
.mouseZoomable(false)
.seriesAccessor(function(d) {return "PMU: " + d.key[1];})
.keyAccessor(function(d) {return +d.key[0];})
.valueAccessor(function(d) {return +d.value;})
.legend(dc.legend().x(350).y(350).itemHeight(13).gap(5).horizontal(1).legendWidth(140).itemWidth(70));
testChart.yAxis().tickFormat(function(d) {return d3.format(',d')(d);});
testChart.margins().left += 40;
dc.renderAll();
});
Đã hoạt động! Tôi phải thiết lập .yAxisPadding (-1) để nó hiển thị. Nhưng câu trả lời của bạn ít nhất là có được các dấu trục y của tôi để hiển thị. –
@MrWiLofDoom: Cảm ơn! –