customized formatter for kendo-chart-value-axis-item using kendo UI angular without kendo drawing visual

1 Answer 36 Views
Charts
Amit
Top achievements
Rank 1
Amit asked on 23 Oct 2024, 07:40 AM
Tried to use format property of labels but there can't customize it Also tried using visual but it gives error with kendo drawing library 
So I want simple way to format 1000 to 1K etc example of formatter for kendo-chart-value-axis-item using kendo UI angular without kendo drawing visual property 

1 Answer, 1 is accepted

Sort by
0
Zornitsa
Telerik team
answered on 28 Oct 2024, 05:46 AM

Hi Amit,

To customize the labels displayed on the value axis of the Chart without using custom visuals, the developer can implement a content function callback for the ValueAxisLabelsComponent:

To be more comprehensive, the content function represents the text of each label on the respective axis/series and it can be configured to return the values in the desired appearance. In your case, each value can be divided by 1000 (since "K" means a thousand) and the "K" suffix can be appended at the end of the values:

<kendo-chart>
    <kendo-chart-value-axis>
        <kendo-chart-value-axis-item>
          <kendo-chart-value-axis-item-labels [content]="labelContent">
          </kendo-chart-value-axis-item-labels>
        </kendo-chart-value-axis-item>
    </kendo-chart-value-axis>
     ...
</kendo-chart>
private suffix = " K";

public labelContent = (e: AxisLabelContentArgs): string => {
    return `${e.value/1000} ${this.suffix}`;
};

For a demonstration of the results from the above approach, please refer to the following StackBlitz example:

I hope this is what you are looking for. Let me know if any additional questions arise on the matter.

Regards,
Zornitsa
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.

Tags
Charts
Asked by
Amit
Top achievements
Rank 1
Answers by
Zornitsa
Telerik team
Share this question
or