swimlane / ngx-charts

:bar_chart: Declarative Charting Framework for Angular
https://swimlane.github.io/ngx-charts/
MIT License
4.28k stars 1.15k forks source link

Add yScaleMin/xScaleMin to more chart types #959

Open ascottb opened 5 years ago

ascottb commented 5 years ago

I'm submitting a ... (check one with "x")

What is the motivation / use case for changing the behavior? Charts like vertical bar chart have a yScaleMin value, but the grouped vertical bar chart does not. I would like to set a min value to set a better focus for the difference in values.

Please tell us about your environment:

ClaudioKirchmair commented 5 years ago

I need xScaleMin for ngx-charts-bar-horizontal-stacked.

I want to have a chart with a x-axis going from -100 to +100. I added xAxisTicks: [-100, -50, 0, 50, 100] but it doesn't get used. He only uses the Ticks where he has values in the data.

I can force him to get to +100 with xScaleMax. I also want to set the min (eg. with xScaleMin) for that specific reason. Here you have your use case ;)

image

ClaudioKirchmair commented 5 years ago

Here is the code that needs to be changed in https://github.com/swimlane/ngx-charts/blob/master/src/bar-chart/bar-horizontal-stacked.component.ts

add after line 124: @Input() xScaleMin: number;

change line 234: const min = Math.min(0, ...domain); to: const min = this.xScaleMin ? Math.min(this.xScaleMin, ...domain) : Math.min(0, ...domain);

Then it should work for my use-case.

MarcoDeJong commented 5 years ago

Related PRs #866 , #909

nurulhaya commented 5 months ago

Has this been resolved?