Simple line chart not drawing data points

79 views
Skip to first unread message

Graham Wheeler

unread,
Mar 12, 2015, 5:10:55 PM3/12/15
to dc-js-us...@googlegroups.com
I must be missing something fundamental with dc. I have a function I wrote to draw line charts of unmunged data (I want to provide X and Y value pairs). Sometimes it works, and sometimes it doesn't, and I can't figure out what is different between when it works and not.

Below is an example that doesn't work. The axes are drawn and labelled appropriately (0-60 on Y axis), but there is no line; the graph is empty. Can someone explain what the issue is?



function makeLineChart2(div, data) {
require(["dc"], function(dc) {
var xfilter = dc.crossfilter(data);
var dimFunc = function (r) {
return r['Row'];
};

var dimension = xfilter.dimension(dimFunc);
var minX = dimFunc(dimension.bottom(1)[0]);
var maxX = dimFunc(dimension.top(1)[0]);

var group = dimension.group().reduceSum(function (d) {
return d['max_temperature'];
});

var lc = dc.lineChart('#dc-chart');
lc.dimension(dimension)
.colors(['red'])
.group(group, 'max_temperature')
.brushOn(true);

lc.width(300).height(200)
.legend(dc.legend().x(50).y(10).itemHeight(13).gap(5));

lc.x(d3.scale.linear().domain([minX, maxX]));
lc.render();
});
}

var data3 = [
{Row:8, max_temperature:36.900001525878906},
{Row:1, max_temperature:63},
{Row:3, max_temperature:39.20000076293945},
{Row:4, max_temperature:53.599998474121094},
{Row:5, max_temperature:46},
{Row:6, max_temperature:18},
{Row:7, max_temperature:54},
{Row:2, max_temperature:35.79999923706055},
{Row:9, max_temperature:43.29999923706055},
{Row:10, max_temperature:41},
{Row:11, max_temperature:54},
{Row:12, max_temperature:9},
{Row:13, max_temperature:43.70000076293945},
{Row:14, max_temperature:46.400001525878906},
{Row:15, max_temperature:39.20000076293945},
];

makeLineChart2('#dc-chart', data3);

Gordon Woodhull

unread,
Mar 12, 2015, 6:15:59 PM3/12/15
to dc.js user group
It looks like you may have pulled some code from an outdated example.  The .colors() parameter now takes a scale rather than a list of colors.  If you want the list of colors you can use .ordinalColors() instead.


--
You received this message because you are subscribed to the Google Groups "dc-js user group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dc-js-user-gro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dc-js-user-group/2769b52d-10ad-4c7c-98c8-6bbef005c622%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages