Charting Basic Example

From GAB Help
Jump to: navigation, search

Embim27.png


V.Local.sRet.Declare(String)

V.Local.sPath.Declare(String)

V.Local.bExists.Declare(Boolean)

V.Local.sY1.Declare(String)

V.Local.sY2.Declare(String)

V.Local.sSeries1.Declare(String)

V.Local.sSeries2.Declare(String)

V.Local.sX.Declare(String)

V.Local.iX.Declare(Long)

V.Local.iY.Declare(Long)

'Create Chart -- Create a chart called "MyChart"

Global.Presentation.CreateChart("MyChart",V.Local.sRet)

'Create a Legend -- Create a legend called "MyLegend"

F.Global.Presentation.CreateChartMember("MyChart","Legend","MyLegend",V.Local.sRet)

'Create a Title -- Create a Title called "MyTitle" and Set the text of the title to say "My Chart Example"

F.Global.Presentation.CreateChartMember("MyChart","Title","MyTitle","My Chart Example",V.Local.sRet)

'Create Series -- Create two series called "Sales North" and "Sales South" and Set their initial data points

V.Local.sX.Set("Jan*!*Feb*!*Mar*!*Apr*!*May*!*Jun*!*Jul*!*Aug*!*Sep*!*Oct*!*Nov*!*Dec")

V.Local.sY1.Set("304*!*382*!*193*!*401*!*363*!*197*!*83*!*200*!*64*!*930*!*870*!*690")

V.Local.sY2.Set("699*!*405*!*15*!*265*!*199*!*481*!*898*!*187*!*595*!*550*!*322*!*556")

F.Intrinsic.String.Concat(V.Local.sX,"!*!",V.Local.sY1,V.Local.sSeries1)

F.Intrinsic.String.Concat(V.Local.sX,"!*!",V.Local.sY2,V.Local.sSeries2)

F.Global.Presentation.CreateChartMember("MyChart","Series","Sales North","Line",V.Local.sSeries1,V.Local.sRet)

F.Global.Presentation.CreateChartMember("MyChart","Series","Sales South","Line",V.Local.sSeries2,V.Local.sRet)

'Set Chart Property -- Change the chart color palette to the Pastel palette

F.Global.Presentation.SetChartProperty("MyChart","Palette","Pastel",V.Local.sRet)

'Set Chart Area Property -- Enable 3d chart style and change backcolor

F.Global.Presentation.SetChartProperty("MyChart","ChartArea","Area3DStyle:Enable3D","True",V.Local.sRet) 

F.Global.Presentation.SetChartProperty("MyChart","ChartArea","BackColor","LightYellow",V.Local.sRet)

'Set Axis X Property -- Change the X Axis interval to 1 so that every month label is displayed

F.Global.Presentation.SetChartProperty("MyChart","Axis","AxisX","Interval",1,V.Local.sRet)

'Set a Series Property -- Add labels to the Sales South series that are formatted "$#VALYK", where "#VALY" is the point Y Value

F.Global.Presentation.SetChartProperty("MyChart","Series","Sales South","Label","$#VALYK",V.Local.sRet)

'Set a DataPoint Property -- Change the marker point 9 of Sales North (the highest point) size to 20, color to red, and style shape to Star5

F.Global.Presentation.SetChartProperty("MyChart","DataPoint","Sales North:9","MarkerSize","20",V.Local.sRet)

F.Global.Presentation.SetChartProperty("MyChart","DataPoint","Sales North:9","MarkerColor",V.Color.Red,V.Local.sRet)

Global.Presentation.SetChartProperty("MyChart","DataPoint","Sales North:9","MarkerStyle","Star5",V.Local.sRet)

'Set a Title Property -- Change the font of the title to Trebuchet MS, size 20, and Bold

F.Global.Presentation.SetChartProperty("MyChart","Title","MyTitle","Font","Trebuchet MS|20|Bold",V.Local.sRet)

'Set a Legend Property – Add a border to the legend

F.Global.Presentation.SetChartProperty("MyChart","Legend","MyLegend","BorderWidth","2",V.Local.sRet) 

F.Global.Presentation.SetChartProperty("MyChart","Legend","MyLegend","BorderColor", V.Color.Black,V.Local.sRet)

'Render -- Save to \Global\Temp\MyChart.bmp, and overwrite If File already Exists

F.Intrinsic.String.Concat(V.Caller.TempDir,"\MyChart.bmp",V.Local.sPath)

F.Intrinsic.Math.Div(V.Screen.F_Chart!picChart.Width,V.Ambient.TwipsPerPiXelX,V.Local.iX)

F.Intrinsic.Math.Div(V.Screen.F_Chart!picChart.Height,V.Ambient.TwipsPerPiXelX,V.Local.iY)

F.Global.Presentation.RenderChart("MyChart",V.Local.sPath,"True",V.Local.iX,V.Local.iY,V.Local.sRet)

'Load Picture to PictureBox

F.Intrinsic.File.Exists(V.Local.sPath,V.Local.bExists)

F.Intrinsic.Control.If(V.Local.bExists,=,"True")

Gui.F_Chart.picChart.Picture(V.Local.sPath)

F.Intrinsic.Control.EndIf

'Clear Chart -- Necessary for Re-Rendering

F.Global.Presentation.ClearChart("MyChart",V.Local.sRet)