ngx-charts icon indicating copy to clipboard operation
ngx-charts copied to clipboard

Add yScaleMin/xScaleMin to more chart types

Open ascottb opened this issue 6 years ago • 4 comments

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

  • [ ] bug report - search github for a similar issue or PR before submitting
  • [x] feature request
  • [ ] support request - use StackOverflow (add the ngx-charts tag) or the gitter chat for support questions

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:

  • ngx-charts version: 9.0.0

ascottb avatar Aug 21 '18 19:08 ascottb

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 avatar Nov 19 '18 15:11 ClaudioKirchmair

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.

ClaudioKirchmair avatar Nov 19 '18 15:11 ClaudioKirchmair

Related PRs #866 , #909

MarcoDeJong avatar Apr 24 '19 09:04 MarcoDeJong

Has this been resolved?

nurulhaya avatar Jan 31 '24 21:01 nurulhaya