dc.js не отображает ось Y - PullRequest
       35

dc.js не отображает ось Y

0 голосов
/ 26 февраля 2019

У меня есть набор данных, которые я хотел бы отобразить на линейном графике для частоты

Анализ данных

var volumeChart = dc.barChart('#monthly-volume-chart');
var dateFormatSpecifier = '%Y-%m-%dT%H:%M:%S.000Z';
    var dateFormat = d3.timeFormat(dateFormatSpecifier);
    var dateFormatParser = d3.timeParse(dateFormatSpecifier);
    var numberFormat = d3.format('.2f');

    data.forEach(function (d) {
        d.dd = dateFormatParser(d.timestamp);
        d.minute = d3.timeMinute(d.dd)
        //coerce to number with a +
    });

Группировка измерений

var freqByMins = ndx.dimension(function (d) {
    return d.minute;
});
var aa = freqByMins.group()
console.log(aa.all())
var freqByMinsGroup = aa.reduceCount(function (d) {
    return d.minute;
});
console.log(freqByMinsGroup.all())

Глядя на freqByMinsGroup.all(), я получаю следующие данные

0: {key: Thu Feb 21 2019 05:29:00 GMT+0800 (Singapore Standard Time), value: 2}
1: {key: Thu Feb 21 2019 05:30:00 GMT+0800 (Singapore Standard Time), value: 5}
2: {key: Thu Feb 21 2019 05:31:00 GMT+0800 (Singapore Standard Time), value: 6}
3: {key: Thu Feb 21 2019 05:32:00 GMT+0800 (Singapore Standard Time), value: 3}
4: {key: Thu Feb 21 2019 05:33:00 GMT+0800 (Singapore Standard Time), value: 1}
5: {key: Thu Feb 21 2019 05:34:00 GMT+0800 (Singapore Standard Time), value: 1}
6: {key: Thu Feb 21 2019 05:35:00 GMT+0800 (Singapore Standard Time), value: 3}
7: {key: Thu Feb 21 2019 05:36:00 GMT+0800 (Singapore Standard Time), value: 4}
8: {key: Thu Feb 21 2019 05:38:00 GMT+0800 (Singapore Standard Time), value: 4}
9: {key: Thu Feb 21 2019 05:39:00 GMT+0800 (Singapore Standard Time), value: 7}
length: 10

Рендеринг диаграмм

 volumeChart.width(960)
    .height(100)
    .margins({top: 10, right: 10, bottom: 20, left: 40})
    .dimension(freqByMins)
    .group(freqByMinsGroup)
    .transitionDuration(500)
    .elasticY(true)

    .x(d3.scaleTime().domain([new Date(2019, 2, 21, 5, 29, 0), new Date(2019, 2, 21, 5, 40, 0)]))
    .xAxis();

Однако моя диаграмма перекрестного фильтра не отображает никакую ось Y.

В приложенииэто изображение

enter image description here

1 Ответ

0 голосов
/ 27 февраля 2019

Для тех, кто может искать этот вопрос,

Ошибка появилась в html.

<div class="row">
    <div id="monthly-move-chart">
        <strong>Monthly Index Abs Move & Volume/500,000 Chart</strong>
        <span class="reset" style="display: none;">range: <span class="filter"></span></span>
        <a class="reset" href="javascript:moveChart.filterAll();volumeChart.filterAll();dc.redrawAll();"
           style="display: none;">reset</a>

        <div class="clearfix"></div>
    </div>
</div>

Когда я использовал другой индекс с

<div id="quarter-chart">
        <strong>Quarters</strong>
        <a class="reset" href="javascript:quarterChart.filterAll();dc.redrawAll();" style="display: none;">reset</a>

        <div class="clearfix"></div>
    </div>

Это сработало.Я предполагаю, что это потому, что он зависел от другого графика.Я буквально взламывал пример из https://dc -js.github.io / dc.datatables.js / , который мог привести к некоторым забавным ошибкам, когда я действительно не проверял html

...