Dynamically set the number of decimals of a number in the tooltip format

Hello Syncfusion, would you please help me with this?

I have this that defines the data series of a y axis of a chart.

return {
     yAxisName: axisName,
     xName: 'time',
     yName: 'value',
     name: seriesName,
     tooltip: {
          visible: true,
          format: `#series.name#: ej.format(#point.y#,n2) ${measurementUnit.unitSymbol}`
     },
     dataSource: sortedData,
     fill: color
};

As you see in the tooltip format, I use ej.format(#point.y#, n2) to set the number of decimals. My question is that is there a way to dynamically pass either n1, n2, or n3 into the function ej.format() based on a condition such as a timezone set by a user? Thanks a lot for your help

















3 Replies

BP Baby Palanidurai Syncfusion Team May 3, 2018 04:37 PM UTC

Hi HT, 
  
Thanks for using syncfusion products, 
  
We have analyzed your query. There is no option to change the format like n1, or n2 into the ej.format() function dynamically. If you want change the format tooltip, you can use lableFormat property in the primaryYAxis options. By default tooltip takes  format from axis label format, so you can change in label format options. As for your requirement, we have prepared a sample with button click. In that button, we have changed the axis label format dynamically. Kindly find the code snippet below to achieve this requirement. 
 
HTML: 
<ej-chart id="chartcontainer" [primaryYAxis.labelFormat]='labelFormat' > 
</ej-chart> 
 
     <button id='button' (click)='click()'>Click to Change format</button> 
 
TS: 
   export class AppComponent { 
   labelFormat : string = 'n2'; 
 
    click() { 
      this.labelFormat = 'n4'; 
    } 
} 
 
Screenshot: 
Initial label format n2: 
 
Dynamically change the label format: 
 
Sample for your reference, can be find from below link, 
 
 https://www.syncfusion.com/downloads/support/forum/137356/ze/angular-ej1-1731302622 
 
  
Kindly revert us, if you have any concerns.  
 
 
Thanks, 
Baby 



H8 HT 89 May 28, 2018 04:23 AM UTC

Hi Baby Palanidurai,
Your solution works. Thanks for your help. 


BP Baby Palanidurai Syncfusion Team May 29, 2018 12:33 PM UTC

Hi HT, 

Thanks for your update, 

   Please let us know if you need any further assistance on this. 


Thanks, 
Baby. 


Loader.
Up arrow icon