Category / Section
How to change the format of label values in OLAP Chart?
1 min read
You can change the format of label values in OLAP Chart using the following code example.
C#
public partial class MainPage : UserControl { private IOlapDataProvider dataProvider; public object OlapDataManager; public MainPage() { InitializeComponent(); InitializeConnection(); this.olapChart.DataRefreshCompleted(olapChart1_OnDataRefreshCompleted); } private void InitializeConnection() { Binding customBinding = new CustomBinding(new BinaryMessageEncodingBindingElement(), new HttpTransportBindingElement { MaxReceivedMessageSize = 2147483647 }); EndpointAddress address = new EndpointAddress("http://bi.syncfusion.com/OlapWcfProject/Services/OlapManager.svc/binary"); ChannelFactory<IOlapDataProvider> clientChannel = new ChannelFactory<IOlapDataProvider>(customBinding, address); dataProvider = clientChannel.CreateChannel(); OlapDataManager olapDataManager = new OlapDataManager(); olapDataManager.DataProvider = dataProvider; olapDataManager.SetCurrentReport(CreateOlapReport()); this.OlapDataManager = olapDataManager; } void olapChart1_OnDataRefreshCompleted(object sender, DataRefreshCompletedEventArgs e) { if (olapChart1.OlapArea.SecondaryAxis.LabelFormat.Contains("$")) olapChart1.OlapArea.SecondaryAxis.LabelFormat = "C"; else if (olapChart1.OlapArea.SecondaryAxis.LabelFormat.Contains("%")) olapChart1.OlapArea.SecondaryAxis.LabelFormat = "P"; else if (olapChart1.OlapArea.SecondaryAxis.LabelFormat == "#,##,##0.00") olapChart1.OlapArea.SecondaryAxis.LabelFormat = "N"; } }
VB
Partial Public Class MainPage Inherits UserControl Private dataProvider As IOlapDataProvider Public OlapDataManager As Object Public Sub New() InitializeComponent() InitializeConnection() Me.olapChart1.OnDataRefreshCompleted += New OlapChart.DataRefreshCompleted(olapChart1_OnDataRefreshCompleted) End Sub Private Sub InitializeConnection() Binding customBinding = New CustomBinding(New BinaryMessageEncodingBindingElement(), New HttpTransportBindingElement { MaxReceivedMessageSize = 2147483647 } ) Dim address As EndpointAddress = New EndpointAddress("http://bi.syncfusion.com/OlapWcfProject/Services/OlapManager.svc/binary") Dim clientChannel As ChannelFactory<IOlapDataProvider> = New ChannelFactory<IOlapDataProvider>(customBinding,address) dataProvider = clientChannel.CreateChannel() Dim olapDataManager As OlapDataManager = New OlapDataManager() olapDataManager.DataProvider = dataProvider olapDataManager.SetCurrentReport(CreateOlapReport()) Me.OlapDataManager = olapDataManager End Sub Private Sub olapChart1_OnDataRefreshCompleted(ByVal sender As Object, ByVal e As DataRefreshCompletedEventArgs) If olapChart1.OlapArea.SecondaryAxis.LabelFormat.Contains("$") Then olapChart1.OlapArea.SecondaryAxis.LabelFormat = "C" ElseIf olapChart1.OlapArea.SecondaryAxis.LabelFormat.Contains("%") Then olapChart1.OlapArea.SecondaryAxis.LabelFormat = "P" ElseIf olapChart1.OlapArea.SecondaryAxis.LabelFormat = "#,##,##0.00" Then olapChart1.OlapArea.SecondaryAxis.LabelFormat = "N" End If End Sub