[Chart] DataLabel

I am using DataLabel for the chart with some having values of 0. Unfortunately, the DataLabel also display 0 which I find irrelevant to the chart (with the value 0). Example below.



How can I remove the value "0" display?

Edit: Update picture.

3 Replies

DD Dharanidharan Dharmasivam Syncfusion Team November 27, 2017 05:16 AM UTC

Hi Dana, 

Thanks for using our products. 

We have analyzed your query. Your requirement can be achieved by using textRender event. This event will be triggered for each data label and we can able to customize the data label text. Kindly find the code  snippet below to achieve this requirement. 

TS: 
 
//Required module to be imported for text rendered event 
import { ITextRenderEventArgs } from '@syncfusion/ej2-charts'; 
 
let chart: Chart = new Chart({ 
    //... 
    textRender: function (args) { 
       if (args.text === '0') { 
                args.cancel = true; 
            } 
       } 
}); 
chart.appendTo('#container'); 


In the above code , we have cancelled the rendering of data label value 0. So that, the data label with text zero will not be visible. You can also customize the text with respect to your requirement using this event. 

Screenshot: 
 

Kindly find the sample for reference from the below plunker link. 

Kindly revert us, if you have any concerns. 

Thanks, 
Dharani. 



DA Dana November 30, 2017 01:24 AM UTC

Thank you, it works.


DD Dharanidharan Dharmasivam Syncfusion Team November 30, 2017 04:46 AM UTC

Hi Dana, 

Thanks for the update. 

Kindly revert us, if you need further assistance. 

Dharani. 



Loader.
Up arrow icon