ngx-charts can I set the y axis increment

4.6k Views Asked by At

I have a data set with whole number values less than 5. The ngx-charts y axis shows tick marks at 0, 0.5, 1, 1.5, etc. Is there a way to make it only put tick marks at whole number increments?

2

There are 2 best solutions below

1
On

In the doc, they talking about an Input property for normalized chart :
yAxisTicks of type any[] so you can pass an array of number value for exemple :

<ngx-charts-area-chart-normalized
  [view]="view"
  [scheme]="colorScheme"
  [legend]="legend"
  [showXAxisLabel]="showXAxisLabel"
  [showYAxisLabel]="showYAxisLabel"
  [xAxis]="xAxis"
  [yAxis]="yAxis"
  [xAxisLabel]="xAxisLabel"
  [yAxisLabel]="yAxisLabel"
  [yAxisTicks]= [0,2000,555550000,650000000]
  [timeline]="timeline"
  [results]="multi"
  (select)="onSelect($event)">
</ngx-charts-area-chart-normalized>
0
On

add [yScaleMin]="yScaleMin" [yScaleMax]="yScaleMax"

and in component yScaleMin = 0 yScaleMax = 5