Formating axis label as absolute numbers

1 Answer 32 Views
Chart
Guillermo
Top achievements
Rank 1
Iron
Guillermo asked on 25 Aug 2023, 07:30 AM | edited on 25 Aug 2023, 09:29 AM

Hi, I have the following graph:

I would like to keep the values in the left side but without showing the negative sign, because they represent quantities. I tried several things for formatting the ValueAxis in order to perform some sort of Math.abs operation but nothing works. Is it possible what I want to achieve?

Otherwise, I wouldn't mid not showing the value axis if I can show the absolutes quantities using label template. However, I get a lot of undefined values that I don't know how to remove:

 .Series(series =>
            {

            series.Bar(
                model => model.Quantity,
                categoryExpression: model => model.Price
            ).Labels(l => l.Visible(true).Template("#= customLabelFormat(value) #").Position(ChartBarLabelsPosition.OutsideEnd).Color("#RGBA"));
        })

 

 

 function customLabelFormat(value) {
           
             return Math.abs(value).toString();
 
        }

 

Thanks a lot.

 

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 29 Aug 2023, 06:56 AM

Hi Guillermo,

I further examined the established series definition, as well as its respective template, but did not find anything evident within the configuration that would indicate the culprit that is causing the rendering anomaly.

Normally, such a behavior may be perseverant if the JSON Serialization is not configured for the application. When you use a Chart or other data-bound widgets in your code, make sure that the property name casing doesn't change during serialization.

This is further documented in the following resource that you might find helpful in this regard:

JSON Serialization - (Documentation)

Additionally, make sure that the passed "value" field is present within the dataItem instance. You can verify this by outputting the "data" object within the console via the following implementation:

.Labels(l => l.Visible(true).Template("#= console.log(data) #").Position(ChartBarLabelsPosition.OutsideEnd).Color("#RGBA"))

And observe the outputted result within the browser:

If this does not help, I have created a standalone Telerik REPL example with an identical scenario as yours. Would it be possible for you to try and replicate the behavior within the attached sample and send it back for further examination?

Finally, I noticed that you have no active license associated with your account which limits our support service. In order to get a hold of all the newly inducted features, bug fixes, and timely support, I would personally recommend reviewing our support plans:

Kind Regards,
Alexander
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.
Tags
Chart
Asked by
Guillermo
Top achievements
Rank 1
Iron
Answers by
Alexander
Telerik team
Share this question
or