0
votes

Given the following dimensions specifications in Crossfilter's API - https://github.com/square/crossfilter/wiki/API-Reference

1.) The function must return naturally-ordered values

2.) .....incomparable values such as NaN and undefined are not supported

How would one go about charting a crossfilter (using dc.js) with two dimensions - one with daily data (7 days a week), and another with business-day data (5-days a week)? The data structure implies that the business-day data will have gaps on the weekend which should violate the specifications above.

For example, if I want to compare a company's store sales (7 days/week) vs its stock price (5 days + gaps on Saturday and Sunday), how would i go about it? The goal would be to have two dc.js charts filtering each other, but having data that isn't perfectly matched up i.e. the first chart will show sales data from Jan 1 till Jan 31 (7 days a week), while the second chart will show stock price data from the first till the last business day in Jan (excluding weekends).

2

2 Answers

0
votes

Your stock data would likely include no data for Saturday and Sunday. This is is different from having a data row with stock price as NaN.

For example: If you plotted the stock data on a row chart with the days of the weeks for the categories, then there would be no bars for saturdays and sundays.

Here is a crude example: DC.JS example of days of week chart

I made sure that no rows were added for saturdays and sundays:

if ((stockDate.getDay() != 6) && (stockDate.getDay() != 0))

The resulting row chart has no row for Saturday or Sunday.

0
votes

You could explore filtering your data, as I did, so you preselect what you want to show. Remember to include the additional code which preserves the bins.

Hide Specified Row in dc.js rowchart