Bar Chart - Error: Mandatory attribute chart.x is missing on chart
Hi guys,
I'm trying to render the barChart via angular-dc and I'm running into the following issue:
Error: Mandatory attribute chart.x is missing on chart
I'm using the same rundimension and grouping from the pieChart example:
$scope.runDimension = ndx.dimension(function(d) {return "run-"+d.Run;}) $scope.speedSumGroup = $scope.runDimension.group().reduceSum(function(d) {return d.Speed * d.Run;});
I've also tried to manually set the "dc-x" attribute and I have also tried to override the data within the angular-dc.js script to no avail.
I've seen someone on stackoverflow use the following with success:
<div dc-chart="barChart" dc-width="990" dc-height="180" dc-x="volumeScale" dc-x-units="d3.time.months" dc-dimension="ticketVolumeDim" dc-group="ticketVolumeGroup" dc-gap="4" class="dc-chart" dc-margins="{top: 0, right: 50, bottom: 20, left: 40}" dc-gap="1" dc-ordinal-colors="ordinalColors" dc-centerBar="true"> </div>
Can you tell me which of the above I have to include to get the bar chart to render - and if possible some of the value formats.
My pieCharts work perfectly. Can you guys let me know what I should be doing differently?
Any help is appreciated and I'd be willing to contribute my fixed version (along with the other charts I plan to work on) as angular-dc examples.
Thanks
@TomNeyland @webmaven @tardyp
I had the same problem and I've fixed it on my fork: https://github.com/tomsaleeba/angular-dc/tree/patch-2
The source of your problem might be different but I was using a fork that had updated deps including lodash v4. The new version had breaking changes from v3 (hence, the new major version) but the _.extend() call on arrays wasn't concatenating them together, instead it just replaced items in the first array with those from the second. The line I fixed for that was https://github.com/tomsaleeba/angular-dc/blob/patch-2/src/angular-dc.js#L104. There were a few other fixes too.