DataAdapter: Object;
DataAdapter: Object;
The DataAdapter property determines a factor data source.
Executing the example requires a form, a button named Button1 on the form, the UiMap component named UiMap1 that is a data source for the MapBox component. A map with the USA identifier must also be present in the repository. The VisualDataAdapter class implements a dynamic data source. The example is executed on clicking the button.
Var Count: Integer;
Class VisualDataAdapter: Object, IMapDynamicDataAdapter
Function Get_PartCount(Attribute: Variant; TimePoint: Integer): Integer;
Begin
Return Count;
End Function Get_PartCount;
Function Get_TimePointName(TimePoint: Integer): String;
Begin
Return "TimePoint " + TimePoint.ToString;
End Function Get_TimePointName;
Function Get_TimePointsCount: Integer;
Begin
Return 4;
End Function Get_TimePointsCount;
Function Get_Data(Attribute: Variant; PartvIndex: Integer; TimePoint: Integer): Variant;
Var t: Integer;
i: Integer;
Begin
t := 1;
For i := 0 To TimePoint Do
t := t + 10;
End For;
Return Math.Rand * 10 * t;
End Function Get_Data;
Function Get_CustomFormat: String;
Begin
Return "#0,000";
End Function Get_CustomFormat;
End Class VisualDataAdapter;
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Map: IMap;
Layer: IMapLayer;
BarVisual: IMapBarVisual;
Begin
UiMap1.Map.Topobase := MetabaseClass.Active.ItemById("USA").Bind As IMapTopobase;
Map := UiMap1.Map;
Layer := Map.Layers.FindByName("Regions");
BarVisual := Layer.Visuals.AddBarVisual;
BarVisual.BeginUpdate;
BarVisual.DataAdapter := New VisualDataAdapter.Create As IMapDynamicDataAdapter;
BarVisual.AttributeName := "Id";
BarVisual.Name := "Bar0";
BarVisual.Width.Value := 4;
BarVisual.EndUpdate;
End Sub Button1OnClick;
After executing the example the bar factor named Bar0 is added to the Regions layer.
Executing the example requires a form, a button named Button1 on the form, the UiMap component named UiMap1 that is a data source for the MapBox component. A map with the USA identifier must also be present in the repository. The VisualDataAdapter class implements a dynamic data source. The example is executed on clicking the button.
Class VisualDataAdapter: IMapTimeDynamicDataAdapter
Public Property PartCount[Attribute: Object; TimePoint: Integer]: Integer
Get
Begin
Return Count;
End Get
End Property;
Public Property Data[Attribute: Object; PartvIndex: Integer; TimePoint: Integer]: Object
Get
Var Math: MathClass = New MathClass();
t: Integer;
i: Integer;
Begin
t := 1;
For i := 0 To TimePoint Do
t := t + 10;
End For;
Return Math.Rand() * 10 * t;
End Get
End Property;
Public Property TimePointsCount: Integer
Get
Begin
Return 4;
End Get
End Property;
Public Property TimePointName[TimePoint: Integer]: String
Get
Begin
Return "TimePoint " + TimePoint.ToString();
End Get
End Property;
Public Property CustomFormat: String
Get
Begin
Return "#0,000";
End Get
End Property;
End Class;
Var Count: Integer;
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
Map: IMap;
Layer: IMapLayer;
BarVisual: IMapBarVisual;
Begin
UiMapNet1.Map.Topobase := Self.Metabase.ItemById["USA"].Bind() As DxMapTopobase;
Map := UiMapNet1.Map;
Layer := Map.Layers.FindByName["Regions"];
BarVisual := Layer.Visuals.AddBarVisual();
BarVisual.BeginUpdate();
BarVisual.DataAdapter := New VisualDataAdapter() As IMapDynamicDataAdapter;
BarVisual.AttributeName := "Id";
BarVisual.Name := "Bar0";
BarVisual.Width.Value := 4;
BarVisual.EndUpdate();
End Sub;
After executing the example the bar factor named Bar0 is added to the Regions layer.
See also: