發表文章

目前顯示的是 3月 26, 2019的文章

How to align x axis with bars respectively in Combo Chart (Bars and Lines)?

圖片
1 I have a combo/ bars & lines chart based on D3.js . The x axis domain contains min and max dates, and bars are based on values. But the last bar (rect) is outside the chart. I can bring it in by forcing it (manually) but it won't reflect the data. var data = [ fcst_valid_local: "2018-11-13T14:00:00-0600", pop: 20, rh: 67, temp: 38, wspd: 7 , fcst_valid_local: "2018-11-14T15:00:00-0600", pop: 15, rh: 50, temp: 39, wspd: 8 , fcst_valid_local: "2018-11-15T16:00:00-0600", pop: 10, rh: 90, temp: 40, wspd: 9 ]; // Margins, width and height. var margin = top: 20, right: 20, bottom: 30, left: 50, width = 500 - margin.left - margin.right, height = 200 - margin.top - margin.bottom; // Date parsing. const parseDate = d3.timeParse("%Y-%m-%dT%H:%M:%S%Z"); data.forEach(function (d) d.date = parseDate(d.fcst_valid_local); ); // Set scale domains. var x = d3.scaleTime().range([0, width]) .domain(d3.extent(data, f...