PrimaryXAxis Label offset/start

Hi,

Thanks for the great product.

Consider the dataset for the the line chart:

{ x: 1, y: 1014 },
{ x: 1.5, y: 1000 },
{ x: 2, y: 1020 },
{ x: 2.5, y: 1044 },
{ x: 3, y: 1065 },
{ x: 3.5, y: 1054 },
{ x: 4, y: 1110 },
{ x: 4.5, y: 1214 },
{ x: 5, y: 1130 },
{ x: 5.5, y: 1030 },
{ x: 6, y: 1190 },
I want to show the x values between 1.5 and 4.5 but have labels for only 2,3, and 4.

I read all the documentation, tried different ways but could not achieve it.

Is there a way to do it?

Kind regards.



5 Replies

DG Durga Gopalakrishnan Syncfusion Team March 16, 2022 11:11 AM UTC

Hi Ugunay, 

Greetings from Syncfusion. 

We request you to specify interval as 0.5 to display decimal numbers and interval as 1 to display whole numbers. You can use minimum and maximum property to start and end at required position. Please check with the below sample. 

 


Kindly revert us if you have any concerns. 

Regards, 
Durga G. 



UG ugunay March 16, 2022 03:17 PM UTC

With the sample, we have 7 labels which are: 1.5, 2, 2.5, 3, 3.5, 4 and 4.5

I want to show the same data with only 3 labels: 2, 3 and 4


Thanks.



DG Durga Gopalakrishnan Syncfusion Team March 17, 2022 10:09 AM UTC

Hi Ugunay, 

We request you to use axisLabelRender event to cancel the decimal axis label rendering. We have attached modified sample for your reference. 

onAxisLabelRender(args){ 
        if(args.axis.name == "primaryXAxis"){ 
            args.cancel = args.value % 1 != 0; 
        } 
    } 

 

Kindly revert us if you have any concerns. 

Regards, 
Durga G. 



UG ugunay March 17, 2022 02:18 PM UTC

Thank you!



SB Swetha Babu Syncfusion Team March 21, 2022 01:26 PM UTC

Hi Ugunay, 
  
Most Welcome! Please get back to us if you need further assistance. 
  
Regards, 
Swetha 


Loader.
Up arrow icon