首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >dc.js不显示y轴

dc.js不显示y轴
EN

Stack Overflow用户
提问于 2019-02-26 14:17:09
回答 1查看 102关注 0票数 2

我有一组数据,我想在折线图上呈现该频率

数据解析

代码语言:javascript
运行
复制
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 +
    });

维度分组

代码语言:javascript
运行
复制
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(),我得到了以下数据

代码语言:javascript
运行
复制
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

呈现图表

代码语言:javascript
运行
复制
 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轴。

附件是一张图片

EN

回答 1

Stack Overflow用户

发布于 2019-02-27 13:28:19

对于任何可能正在关注这个问题的人来说,

错误出现在html中。

代码语言:javascript
运行
复制
<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>

当我使用另一个索引时

代码语言:javascript
运行
复制
<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时,这可能会导致一些有趣的错误

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54879469

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档