- The Microsoft .NET team has extended the .NET API by introducing a Chart control.
- Microsoft Dynamics Client enables simple use of this control by creating a new X++ wrapper class for the MSChart control: Graphics.
- The Microsoft Dynamics Client has introduce a new companion control for the MSChart control: The Chart Toolbar control.
public class FormRun extends ObjectRun
{
Graphics graphics;
Microsoft.Dynamics.AX.Framework.Client.Controls.ChartToolBar chartToolbarControl;
}
public
void init(){
super();
// create an runtime reference to the toolbar control
chartToolbarControl = chartToolbarControlHost.control();
// bind the tool bar to the chart control by passing an instance of the chart control to it
chartToolbarControl.set_ChartControl(graphControl.control());
this.createSampleData();
this.showchart();
}
void showchart()
{
// create an instance of the X++ to .NET abstraction class and bind it to the chart control
graphics = new Graphics();
graphics.ManagedHostToControl(graphControl);
// set your abstracted chart options
graphics.parmCreateType(#CT_LEGEND | #CT_3D);
graphics.create();
graphics.parmTitle("@SYS95906");
graphics.parmTitleXAxis("@SYS106478");
graphics.parmTitleYAxis("@SYS3065");
// populate the chart with data
whileselect tmpAccountSum
orderby TransDate
{
graphics.loadData( date2str(tmpAccountSum.TransDate,-1,-1,-1,-1,-1,-1, DateFlags::None), tmpAccountSum.Txt, tmpAccountSum.Qty01);
}
graphics.showGraph();
}
// create some sample data
void createsampledata()
{
tmpAccountSum.TransDate = 01\01\2007;
tmpAccountSum.Qty01 = 1;
tmpAccountSum.Txt = 'Group1';
tmpAccountSum.insert();
tmpAccountSum.TransDate = 02\02\2007;
tmpAccountSum.Qty01 = 2;
tmpAccountSum.Txt = 'Group1';
tmpAccountSum.insert();
tmpAccountSum.TransDate = 02\02\2007;
tmpAccountSum.Qty01 = 1;
tmpAccountSum.Txt = 'Group2';
tmpAccountSum.insert();
tmpAccountSum.TransDate = 03\03\2007;
tmpAccountSum.Qty01 = 3;
tmpAccountSum.Txt = 'Group2';
tmpAccountSum.insert();
tmpAccountSum.TransDate = 04\04\2007;
tmpAccountSum.Qty01 = 1;
tmpAccountSum.Txt = 'Group1';
tmpAccountSum.insert();
tmpAccountSum.TransDate = 04\04\2007;
tmpAccountSum.Qty01 = 2;
tmpAccountSum.Txt = 'Group3';
tmpAccountSum.insert();
tmpAccountSum.TransDate = 05\05\2007;
tmpAccountSum.Qty01 = 3;
tmpAccountSum.Txt = 'Group3';
tmpAccountSum.insert();
tmpAccountSum.TransDate = 05\05\2007;
tmpAccountSum.Qty01 = 2;
tmpAccountSum.Txt = 'Group2';
tmpAccountSum.insert();
}