Check out my code snippet on JSFiddle here: https://jsfiddle.net/8yf7j3k6/11/
I am currently working on replicating a similar visualization of my data for a range chart, allowing me to scrub through the chart while utilizing tooltips in the line chart representing circulation data. However, I have encountered two issues that seem to be affecting my crossfilter and causing discrepancies in the appearance of the range chart:
One issue arises when using the standard group generated by crossfilter, resulting in a value calculation that multiplies the circulation data by the number of regions in which the magazine was circulated. To address this, I created a mapping system to adjust the represented values based on the number of regions. I struggled to create a new group for this adjustment at the data level and instead incorporated it during the rendering step. Could this workaround potentially be causing the problems I am facing?
Another concern involves using the same group for both the line chart and the range chart. In referencing the NASDAQ sample, there seems to be a different treatment of the data, likely related to binning rather than significant alterations. I am puzzled by why my graph shows such a drastic negative value at point zero.
Below is the code snippets for the problematic charts. Please note that some boilerplate code is included in the fiddle due to the absence of a CDN for dateformat.
lineChart1
.width(lineChart1Width-50)
.height(lineChart1Height-50)
.xUnits(d3.timeMonths)
.margins({ top: 10, right: 10, bottom: 20, left: 80 })
.dimension(dimension1)
.rangeChart(lineChart1Range)
.group(circulationGroup1)
.colors(colorScales.blue[colorScales.blue.length - 1])
.elasticY(true)
.brushOn(false)
.valueAccessor(function (d) {
return d.value / circulationValuesMap[d.key]
})
.title(function (d) {
return `${d.key.format('mmm dd, yyyy')}\nCirculation: ${d.value / circulationValuesMap[d.key]} `
})
.x(d3.scaleTime().domain([new Date(1925, 0, 1), new Date(1927, 0, 1)]))
.render()
lineChart1Range
.width(getWidth('line-chart-1-range')) /* dc.barChart('#monthly-volume-chart', 'chartGroup'); */
.height(40)
.margins({top: 0, right: 50, bottom: 20, left: 80})
.dimension(dimension1)
.group(circulationGroup1)
.valueAccessor(d => d.value / circulationValuesMap[d.key])
.centerBar(true)
.x(d3.scaleTime().domain([new Date(1925, 0, 1), new Date(1927, 0, 1)]))
.round(d3.timeMonth.round)
.alwaysUseRounding(true)
.xUnits(() => 200);
lineChart1Range.yAxis().ticks(0)