How to load the OlapChart control dynamically from a UserControl
This can be achieved by adding the OlapChart in a separate user control. The procedure to bind the data to OlapChart is, First the OlapChart’s framework must be loaded with applied templates and then the OlapDatamanager should set and bind the data. So while you add the OlapChart dynamically from the Usercontrol, we have to set the OlapDataManager in the Loaded event of OlapChart (i.e., After the OlapChart is initialized).
Please find the code snippet as below.
public MainPage() { InitializeComponent(); InitializeConnection(); SilverlightControl1.MyOlapChart.Loaded += new RoutedEventHandler(MyOlapChart_Loaded); string MdxString = " SELECT NONEMPTY({[Measures].[Internet Sales Amount]}) dimension properties member_type, PARENT_UNIQUE_NAME ON COLUMNS , NONEMPTY( VISUALTOTALS( ({{Drilldownlevel({ [Date].[Fiscal] })}}) ),{[Measures].[Internet Sales Amount]}) dimension properties member_type, PARENT_UNIQUE_NAME ON ROWS FROM [Adventure Works] CELL PROPERTIES VALUE, FORMAT_STRING, FORMATTED_VALUE"; this.DataManager = new OlapDataManager(); this.DataManager.DataProvider = dataProvider; this.DataManager.MdxQuery = MdxString; } void MyOlapChart_Loaded(object sender, RoutedEventArgs e) { SilverlightControl1.MyOlapChart.OlapDataManager = this.DataManager; }
|