Y axis needs to use integer numbers (without decimals)

2 Answers 1109 Views
Charts General Discussions
Nazareth
Top achievements
Rank 1
Nazareth asked on 23 Aug 2021, 08:24 PM

Hi, I have this line chart, which is generating decimal counts. I want to have an integer scale (without decimals), because it is a count of completed or not. 

<kendo-chart>
    <kendo-chart-tooltip format="Completed tasks: {0}"></kendo-chart-tooltip>
    <kendo-chart-category-axis>
    <kendo-chart-category-axis-item [labels]="{ format: 'd', rotation: 'auto' }">
    </kendo-chart-category-axis-item>
    </kendo-chart-category-axis>
    <kendo-chart-value-axis>
      <kendo-chart-value-axis-item [min]="0">
      </kendo-chart-value-axis-item>
    </kendo-chart-value-axis>
    <kendo-chart-series>
      <kendo-chart-series-item 
        type="line" 
        *ngFor="let item of workflowsLinechartData" 
        [data]="item.items" 
        [name]="item.value"
        aggregate="count"
        field="taskName"
        categoryField="endTime">
      </kendo-chart-series-item>
    </kendo-chart-series>
  </kendo-chart>

 

Already tried this:

 

<kendo-chart-value-axis>
      <kendo-chart-value-axis-item [labels]="{format: 'n0'}" [min]="0">
      </kendo-chart-value-axis-item>
    </kendo-chart-value-axis>

 

but the output is repeating the integers:

 

How I can manage this?

Thanks

 

2 Answers, 1 is accepted

Sort by
0
Stoyan
Telerik team
answered on 26 Aug 2021, 08:45 AM

Hi Nazareth,

Thanks for the provided information and snapshots.

To set an integer scale without decimals, the developer could set the min and max properties of the kendo-chart-value-axis-item respectively to 0 and 3:

<kendo-chart>
      <kendo-chart-value-axis>
        <kendo-chart-value-axis-item
          [min]="0"
          [max]="3"
        >
        </kendo-chart-value-axis-item>
      </kendo-chart-value-axis>
...

I hope this helps. If any other questions come to mind, please do not hesitate to address them to us.

Regards,
Stoyan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Nazareth
Top achievements
Rank 1
commented on 26 Aug 2021, 03:42 PM

Hi Stoyan, 

Thanks a lot for your response.

I added more data, and the problem was solved. I did not want to fix the axis because the data can change over time, I am using an angular service.

Best regards, 

Nazareth

0
Ivan
Telerik team
answered on 31 Aug 2021, 11:21 AM

Hi Nazareth,

One thing you can try is to set "majorUnit" attribute of <kendo-chart-value-axis-item>, it may be adjusted even with decimals less that 1 , i.e. 0.5, 0.6, 0.7 .... Please refer to this stackblitz sample which demonstrates this approach.

Let us know if that would help and please do not hesitate to ask further assitance if needed.

Regards,
Ivan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Charts General Discussions
Asked by
Nazareth
Top achievements
Rank 1
Answers by
Stoyan
Telerik team
Ivan
Telerik team
Share this question
or