dc.js

Using an ordinal scale ('d3.scale.ordinal') for the x-axis in a bar chart

谁说胖子不能爱 提交于 2019-11-27 02:37:09
问题 I have a data array like this: var data = [{"Alphabet_Type":"a"}, {"Alphabet_Type":"b"}, {"Alphabet_Type":"a"}]; I am using: dc.js crossfilter.js d3.js I want to create a bar chart with: the x-axis having an alphabet name, and the y-axis having number of occurrences of the alphabet. Question: How can I plot a bar chart with an ordinal scale on the x-axis? My code: var data = [{"Alphabet_Type":"a"}, {"Alphabet_Type":"b"}, {"Alphabet_Type":"a"}]; var Filter = crossfilter(data); var Dimension =

dc.js - Listening for chart group render

五迷三道 提交于 2019-11-26 17:44:00
I'm trying to refactor some custom d3 code that I wrote to render a series of crossfilter-driven charts by bringing in dc.js. My main problem is that I have some chart types that are not supported by dc.js (e.g. a Sunburst Partition ) and I'm trying to figure out how to render them in conjunction with a dc.js chart group. Filtering a single dc.js chart will automatically render / redraw all other charts belonging to the same chartGroup . Is it possible to somehow hook into that global re-render event, so that I can re-draw the non-dc charts at the same time? I understand that there are

Loading external csv file in jsfiddle

别来无恙 提交于 2019-11-26 17:43:35
I am trying to create a jsfiddle for one of the dc.js examples. I am not able to load an external file using a URL and d3.csv() . Can someone please suggest how to load a csv file using d3.csv in jsfiddle. The approach I usually use for CSV data in JSFiddle examples is a. Put the data in a <pre> block at the end of the HTML mark-up, usually with the id "data". b. Add pre {display:none;} to the CSS. c. Replace the d3.csv(filename, callback) function call with a d3.csv.parse(text) call, using the text content of the <pre> block as the input to the parse function. Because the parse function doesn

Show values on top of bars in a barChart

梦想与她 提交于 2019-11-26 17:04:29
问题 I have a bar chart with ordinal scale for the x-axis. I want to display the y-values on the top of each bar or in the bottom of each bar. It would be also acceptable to display the y-values when one hovers over the bar. Is there a function or a way in a dc.js to do that? Here is the jsfiddle and my code is below the pic> Edit: Here is my code: HTML <body> <div id='Chart'> </div> </body> JS var data = [{ Category: "A", ID: "1" }, { Category: "A", ID: "1" }, { Category: "A", ID: "1" }, {

dc.js - how to create a row chart from multiple columns

丶灬走出姿态 提交于 2019-11-26 14:45:32
I need to create a rowchart in dc.js with inputs from multiple columns in a csv. So i need to map a column to each row and each columns total number to the row value. There may be an obvious solution to this but i cant seem to find any examples. many thanks S update: Here's a quick sketch. Apologies for the standard Row chart; column1 ----------------- 64 (total of column 1) column2 ------- 35 (total of column 2) column3 ------------ 45 (total of column 3) Interesting problem! It sounds somewhat similar to a pivot, requested for crossfilter here . A solution comes to mind using "fake groups"

Initial Range selection in DC.js chart

岁酱吖の 提交于 2019-11-26 09:55:10
问题 I would like to make an initial range selection in some dc.js charts (bar and line). So I add this for example: .filter([7,10]) And the range appears well on the chart, but apparently 0 observations are selected. I expected a few thousands observations selected. Like it does when I select the range [7,10] manually with the brush. Any hint on what I\'m missing here? Part of my code: var chart_globalscore = dc.barChart(\'#chart_globalscore\'); (...) var ndx = crossfilter(data_movies) ,all = ndx

Loading external csv file in jsfiddle

天涯浪子 提交于 2019-11-26 05:33:36
问题 I am trying to create a jsfiddle for one of the dc.js examples. I am not able to load an external file using a URL and d3.csv() . Can someone please suggest how to load a csv file using d3.csv in jsfiddle. 回答1: The approach I usually use for CSV data in JSFiddle examples is a. Put the data in a <pre> block at the end of the HTML mark-up, usually with the id "data". b. Add pre {display:none;} to the CSS. c. Replace the d3.csv(filename, callback) function call with a d3.csv.parse(text) call,

Is there a way to tell crossfilter to treat elements of array as separate records instead of treating whole array as single key?

此生再无相见时 提交于 2019-11-26 05:19:48
问题 I have data set where some of the field values are arrays and I\'d like to use crossfilter and d3.js or dc.js to display histogram of how many times each of those values was present in the dataset. Here\'s an example: var data = [ {\"key\":\"KEY-1\",\"tags\":[\"tag1\", \"tag2\"]}, {\"key\":\"KEY-2\",\"tags\":[\"tag2\"]}, {\"key\":\"KEY-3\",\"tags\":[\"tag3\", \"tag1\"]}]; var cf = crossfilter(data); var tags = cf.dimension(function(d){ return d.tags;}); var tagsGroup = tags.group(); dc

dc.js - Listening for chart group render

こ雲淡風輕ζ 提交于 2019-11-26 04:50:02
问题 I\'m trying to refactor some custom d3 code that I wrote to render a series of crossfilter-driven charts by bringing in dc.js. My main problem is that I have some chart types that are not supported by dc.js (e.g. a Sunburst Partition) and I\'m trying to figure out how to render them in conjunction with a dc.js chart group. Filtering a single dc.js chart will automatically render / redraw all other charts belonging to the same chartGroup. Is it possible to somehow hook into that global re

dc.js - how to create a row chart from multiple columns

好久不见. 提交于 2019-11-26 04:00:01
问题 I need to create a rowchart in dc.js with inputs from multiple columns in a csv. So i need to map a column to each row and each columns total number to the row value. There may be an obvious solution to this but i cant seem to find any examples. many thanks S update: Here\'s a quick sketch. Apologies for the standard Row chart; column1 ----------------- 64 (total of column 1) column2 ------- 35 (total of column 2) column3 ------------ 45 (total of column 3) 回答1: Interesting problem! It sounds