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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Angular pipe in axis labelFormat

Thread ID:

Created:

Updated:

Platform:

Replies:

148211 Oct 10,2019 07:45 AM UTC Oct 11,2019 12:08 PM UTC Angular - EJ 2 1
loading
Tags: Chart
dskLux
Asked On October 10, 2019 07:45 AM UTC

Hello.
Is it possible to use a pipe in the axis property labelFormat?
I am drawing the chart based on a numeric value that I need to display as HH:MM

I have tried using the pipe in the property but it is not displayed correctly:

      this.ChartPrimaryYAxis = {
        title: "Time",
        valueType: "Double",
        labelFormat: "{'value' | ConvertTime}"
      };

Thanks

Srihari Muthukaruppan [Syncfusion]
Replied On October 11, 2019 12:08 PM UTC

Hi dskLux,  

Greetings from syncfusion 

We have validated your query. From that, we would like to let you know that we can achieve your requirement by using “axislabelRender” event through which we can customize the axis labels. Based on that we have prepared a sample and also provided the code snippet for your reference.    
    
    
Code Snippet:     
[App.component.ts]: 
 
export class AppComponent { 
    public data: Object[] = [ 
        { x: 16, y: 20 }, { x: 17, y: 30 }, 
        { x: 18, y: 70 }, { x: 19, y: 80 }, 
        { x: 20, y: 100 } 
    ]; 
    //Initializing Primary X Axis 
    public primaryXAxis: Object = { 
        title: 'Death Overs', 
        minimum: 15, 
        maximum: 21, 
        interval: 1, 
        majorGridLines: { width: 0 } 
    }; 
    public primaryYAxis: Object = { 
      interval: 20 
    }; 
    public labelRender(args: IAxisLabelRenderEventArgs): void { 
        if (args.axis.name === "primaryYAxis") { 
          let hours: number = 0; 
        let minutes: number = 0; 
        hours = parseInt((args.value/60).toFixed(1)); 
        minutes = args.value % 60; 
        args.text = hours + ':' + minutes; 
        } 
    }; 
    constructor() { 
        //code 
    }; 
 
} 
  
[App.component.html]: 
 
<div class="control-section"> 
        <div align='center'> 
            <ejs-chart style='display:block;' [width]='width' align='center' id='chartcontainer'  
[primaryXAxis]='primaryXAxis' [primaryYAxis]='primaryYAxis' (axisLabelRender)='labelRender($event)'> 
                <e-series-collection> 
                    <e-series [dataSource]='data' type='Column' xName='x' yName='y' fill = '#1e90ff' width=2> </e-series> 
                </e-series-collection> 
            </ejs-chart> 
        </div> 
</div> 
    
 
Screenshot:   
 
   
Let me know, if you have any concerns.    
    
Regards,    
Srihari 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon