//TH-Header //***************************************************************************************** // Copyright (c) 2022 Antwise Solutions // All rights reserved. // // $FileName : SyncFusion\AppSrc\csfWebChart.pkg // $ProjectName : SyncFusion Library // $Authors : Wil van Antwerpen // $Created : 2022-08-25 // // Contents: // This is a web framework wrapper class for the SyncFusion Chart control. // // Documentation for the API is here: // https://ej2.syncfusion.com/documentation/api/chart/ // and tips & tricks here: // https://ej2.syncfusion.com/javascript/documentation/chart/es5-getting-started/ // SyncFusion Chart control demo: // https://ej2.syncfusion.com/javascript/demos/#/material/chart/line.html // // //***************************************************************************************** //TH-RevisionStart // ******************** // MODIFICATION SUMMARY // ******************** // ####### DD/MM/YYYY WHO COMMENT //TH-RevisionEnd Use csfWebChartBase.pkg Use csfWebChartAxis.pkg Use csfWebChartSeries.pkg Struct tsfWebChartConfig tsfWebChartAxis[] Axes tsfWebChartSeries[] Series tsfWebChartArea Area tsfWebChartTooltip Tooltip End_Struct { OverrideProperty=pAxisHandles Visibility=Private } Class csfWebChart is a csfWebChartBase Procedure Construct_Object Forward Send Construct_Object // Description for chart. { WebProperty=Client } Property String psDescription "" // If set true, Animation process will be executed. // Default = true { WebProperty=Client } Property Boolean pbEnableAnimation True // The Chart subtitle. { WebProperty=Client } Property String psSubTitle "" // doesn't work atm // // // // It specifies whether the chart should be rendered in canvas mode // // Defaults to false // // // { WebProperty=Client } // Property Boolean pbEnableCanvas False // Private properties used for configuring the chart control. Property Handle[] pAxisHandles Property Handle[] pSeriesHandles Set psJSClass To "sf.WebChart" //Set piColumnSpan to 0 // Schedule will span the whole width by default (0 does this) End_Procedure { Visibility=Private } Procedure RegisterAxis Handle hoAxis Handle[] AxisHandles If (hoAxis<>0) Begin Get pAxisHandles To AxisHandles Move hoAxis To AxisHandles[SizeOfArray(AxisHandles)] Set pAxisHandles To AxisHandles End End_Procedure Function LoadChartAxesPrototypes Returns tsfWebChartAxis[] Integer iItem Integer iCount Handle hoAxis Handle[] AxisHandles tsfWebChartAxis Axis tsfWebChartAxis[] AxisPrototypes Get pAxisHandles to AxisHandles Move (SizeOfArray(AxisHandles)) To iCount For iItem From 0 To (iCount-1) Move AxisHandles[iItem] To hoAxis If (hoAxis) Begin Get LoadWebChartAxisProperties of hoAxis To Axis Move Axis To AxisPrototypes[SizeOfArray(AxisPrototypes)] End Loop Function_Return AxisPrototypes End_Function { Visibility=Private } Procedure RegisterSeries Handle hoSeries Handle[] SeriesHandles If (hoSeries<>0) Begin Get pSeriesHandles To SeriesHandles Move hoSeries To SeriesHandles[SizeOfArray(SeriesHandles)] Set pSeriesHandles To SeriesHandles End End_Procedure { Visibility=Private } Function LoadSeriesProtoTypes Returns tsfWebChartSeries[] Handle hoSeries Integer iItem Integer iCount Handle[] SeriesHandles tsfWebChartSeries Series tsfWebChartSeries[] SeriesPrototypes Get pSeriesHandles To SeriesHandles Move (SizeOfArray(SeriesHandles)) To iCount For iItem From 0 To (iCount-1) Move SeriesHandles[iItem] To hoSeries If (hoSeries<>0) Begin Move (SizeOfArray(SeriesPrototypes)) To iItem Set psObjectId Of hoSeries to (string(iItem)) Get LoadWebChartSeriesProperties of hoSeries To Series Move Series To SeriesPrototypes[iItem] End Loop Function_Return SeriesPrototypes End_Function // // Fix for live data update flicker issue // Procedure RefreshLiveData Send ClientAction "refreshLiveData" End_Procedure { Visibility=Private } Procedure ConnectChartAxes Integer iItem Integer iCount Handle hoAxis Handle[] AxisHandles Get pAxisHandles To AxisHandles Move (SizeOfArray(AxisHandles)) To iCount For iItem From 0 To (iCount-1) Move AxisHandles[iItem] To hoAxis If (hoAxis) Begin Send ConnectAxis Of hoAxis End Loop End_Procedure Function primaryXAxisName Returns String Integer iItem Integer iCount Integer eAxisType String sName Handle hoAxis Handle[] AxisHandles Move "" To sName Get pAxisHandles To AxisHandles Move (SizeOfArray(AxisHandles)) To iCount For iItem From 0 To (iCount-1) Move AxisHandles[iItem] To hoAxis If (hoAxis) Begin Get peAxisType Of hoAxis To eAxisType If (eAxisType=chartAxisX) Begin Get psName Of hoAxis To sName Move iCount to iItem End End Loop Function_Return sName End_Function Function primaryYAxisName Returns String Integer iItem Integer iCount Integer eAxisType String sName Handle hoAxis Handle[] AxisHandles Move "" To sName Get pAxisHandles To AxisHandles Move (SizeOfArray(AxisHandles)) To iCount For iItem From 0 To (iCount-1) Move AxisHandles[iItem] To hoAxis If (hoAxis) Begin Get peAxisType Of hoAxis To eAxisType If (eAxisType=chartAxisY) Begin Get psName Of hoAxis To sName Move iCount to iItem End End Loop Function_Return sName End_Function { Visibility=Private } Procedure ConnectChartSeries Integer iItem Integer iCount Handle hoSeries Handle[] SeriesHandles Get pSeriesHandles To SeriesHandles Move (SizeOfArray(SeriesHandles)) To iCount For iItem From 0 To (iCount-1) Move SeriesHandles[iItem] To hoSeries If (hoSeries) Begin Send ConnectSeries Of hoSeries End Loop For iItem From 0 To (iCount-1) Move SeriesHandles[iItem] To hoSeries If (hoSeries) Begin Send LoadSeriesData Of hoSeries End Loop End_Procedure { Visibility=Private } Procedure doPostConfigureChart // Send ConnectChartAxes Forward Send doPostConfigureChart End_Procedure { Visibility=Private } Procedure ConfigureChartControl String[] asParams tWebValueTree tVT tsfWebChartConfig Config tsfWebChartAxis[] AxisPrototypes tsfWebChartSeries[] SeriesPrototypes tsfWebChartArea AreaPrototype tsfWebChartTooltip TooltipPrototype Get LoadChartAxesPrototypes to AxisPrototypes If (SizeOfArray(AxisPrototypes)>0) Begin Move AxisPrototypes to Config.Axes End Get LoadAreaPrototype to AreaPrototype If (phoChartArea(Self)<>0) Begin Move AreaPrototype to Config.Area End Get LoadTooltipPrototype to TooltipPrototype If (phoChartTooltip(Self)<>0) Begin Move TooltipPrototype to Config.Tooltip End Get LoadSeriesProtoTypes to SeriesPrototypes If (SizeOfArray(SeriesPrototypes)>0) Begin Move SeriesPrototypes to Config.Series ValueTreeSerializeParameter Config To tVT Send ClientAction "configureChartControl" asParams tVT Send doPostConfigureChart Send doRenderChart End End_Procedure Procedure End_Construct_Object Forward Send End_Construct_Object End_Procedure End_Class