We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.

# Custom axis scale

Hello,

is it possible to extend ChartAxis to create a custom scale? What I specifically need is a square root scale, which is sadly not available for sfChart. What methods do I have to override to make this work?

Thank you,
Thanh

7 Replies

DA Devi Aruna Maharasi Murugan Syncfusion Team October 11, 2016 07:26 AM UTC

Hi Thanh,

Thanks for contacting Syncfusion Support.

We are able to achieve your requirement by overriding the GenearteVisibleLabels method with custom chart axis (SquareRootScale class). We have prepared a demo sample based on your requirement and it can be downloaded from below link,

Sample: Squarerootaxis

Regards,
Devi

TT Thanh Tomas Dang October 11, 2016 08:12 AM UTC

Hello Devi,

that's exactly what I needed. Thanks!

Thanh

DA Devi Aruna Maharasi Murugan Syncfusion Team October 12, 2016 04:35 AM UTC

Hi Thanh,

Thanks for your update.

Please let us know, if you need any further assistance.

Regards,
Devi

TT Thanh Tomas Dang October 28, 2016 07:53 PM UTC

Hello Devi,

I reviewed the square root axis code and it seems like it does not do exactly what I need.

In your last code example, you add the following:

Collection.Add(new Model() { XValue = 1, YValue = 18 });
Collection.Add(new Model() { XValue = 2, YValue = 32 });
Collection.Add(new Model() { XValue = 3, YValue = 24 });
Collection.Add(new Model() { XValue = 4, YValue = 42 });
Collection.Add(new Model() { XValue = 5, YValue = 30 });

but the chart displays the Y values as square roots of 18, 32, 24, 42, 30.

What it should do is display the original values (18, 32, 24, 42, 30), but show the labels for 1, 4, 16, 25 on the Y axis accordingly.

If I may compare to logarithmic axis: At position 0 of the axis, the label shows 1 (log 0 = 1), at position 1, the axis shows 10 (log 10 = 1) and at position 2, the axis shows 100 (log 100 = 2).

Would re-scaling the axis (not just changing the labels!) be possible?

Thanks,
Thanh

MK Muneesh Kumar G Syncfusion Team October 31, 2016 09:31 AM UTC

Hi Thanh,

We have modified our sample based on your requirement. Please find the modified sample from the below location.

Please let us know, if you need any further assistance.

Regards,
Muneesh Kumar G.

TT Thanh Tomas Dang November 4, 2016 12:30 PM UTC

Hello Muneesh,

this works! Thank you for your help!

-Thanh

DA Devi Aruna Maharasi Murugan Syncfusion Team November 7, 2016 03:42 AM UTC

Hi Thanh,

Thanks for your update.

Please let us know, if you need any further assistance.

Regards,
Devi