c3js / c3

:bar_chart: A D3-based reusable chart library
http://c3js.org
MIT License
9.35k stars 1.39k forks source link

Can't get "timeseries" to display with weekly intervals #2812

Open brianjenkins94 opened 4 years ago

brianjenkins94 commented 4 years ago

Basically I'm trying to build something of a gantt chart that shows the last 30 days.

See the 2 comments below on the solutions that I thought should have worked:

c3.generate({
    "bindto": "#chart1",
    "data": {
        "type": "bar",
        "json": data,
        "keys": {
            "x": "ticketNumber",
            "value": ["startDate", "endDate"]
        },
        "groups": [
            ["startDate", "endDate"]
        ],
        "colors": {
            "startDate": "transparent",
        }
    },
    "axis": {
        "x": {
            "type": "category",
            "tick": {
                "values": [],
            }
        },
        "y": {
            "type": "timeseries",
            "min": Date.now() - 1000 * 60 * 60 * 24 * 30,
            "max": Date.now(),
            "tick": {
                // Neither of these appear to change anything:
                //"culling": true,
                //"fit": true,
                "format": d3.timeFormat("%B %d, %Y"),
                "outer": false,
                // Nor does this:
                //"values": (function() {
                //  const values = [];
                //
                //  for (const x = new Date(Date.now() - 1000 * 60 * 60 * 24 * 30); x < Date.now(); x.setDate(x.getDate() + 1)) {
                //      if (x.getDay() === 0) {
                //          values.push(x);
                //
                //          x.setDate(x.getDate() + 6)
                //      }
                //  }
                //
                //  return values;
                //})()
            }
        },
        "rotated": true
    },
    "legend": {
        "hide": true
    }
});