Class
DesktopChart
Description
Displays data you provide in chart form of various types.
Properties
Name |
Type |
Read-Only |
Shared |
---|---|---|---|
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
Methods
Name |
Parameters |
Returns |
Shared |
---|---|---|---|
dataset As ChartDataset |
|||
index As Integer, Dataset As ChartDataset |
|||
Datasets() As ChartDataset |
|||
name As String |
|||
names() As String |
|||
index As Integer |
|||
index As Integer |
|||
index As Integer |
|||
index As Integer |
|||
Events
Name |
Parameters |
Returns |
---|---|---|
Base As DesktopMenuItem, x As Integer, y As Integer |
||
selectedItem As DesktopMenuItem |
||
obj As DragItem, Action As DragItem.Types |
||
obj As DragItem, Action As DragItem.Types |
||
x As Integer, y As Integer, obj As DragItem, Action As DragItem.Types |
||
Obj As DragItem, Action As DragItem.Types |
||
DataSet As ChartDataSet |
||
Key As String |
||
Key As String |
||
dataset As ChartDataset, index As Integer |
Enumerations
DesktopChart.Modes
Modes
The various types of charts available.
Enum |
---|
Bar |
Bubble |
Doughnut |
Line |
Pie |
PolarArea |
Radar |
Scatter |
Property descriptions
DesktopChart.AllowPopover
AllowPopover As Boolean
If True, a popover will be displayed when the user positions the mouse over items that have additional information.
The default value is True.
DesktopChart.BackgroundColor
BackgroundColor As ColorGroup
The color of the background of the chart.
DesktopChart.DatasetCount
DatasetCount As Integer
The number of datasets that have been added to the chart.
This property is read-only.
DesktopChart.Enabled
Enabled As Boolean
When True the control is drawn enabled and responds to user action. When False, the control appears as disabled and does not respond to user actions.
DesktopChart.FontName
FontName As String
Name of the font used to display the text content.
You can enter any font that is installed on the computer or the names of the two metafonts, "System" and "SmallSystem".
The System font is the font used by the system software as its default font. Different operating systems use different default fonts. If the system software supports both a large and small System font, you can also specify the "SmallSystem" font as your FontName.
On macOS, "SmallSystem" specifies the OS's smaller system font and may make the control smaller in size as well. On Windows and Linux, "SmallSystem" is the same as "System".
This code sets the FontName property.
Me.FontName = "Helvetica"
DesktopChart.FontSize
FontSize As Double
Point size of the font used to display the caption.
If you enter zero as the FontSize, your app will use the font size that works best for the platform on which it is running.
This code sets the font size to 16 points.
Me.FontSize = 16
DesktopChart.GridColor
GridColor As ColorGroup
The color of the chart's grid.
DesktopChart.HasLegend
HasLegend As Boolean
If True, the chart's legend will be displayed.
DesktopChart.Height
Height As Integer
The height (in points) of the control.
DesktopChart.Left
Left As Integer
The position of the left side of the control in pixels, relative to the window.
DesktopChart.LockBottom
LockBottom As Boolean
Determines whether the bottom edge of the control should stay at a set distance from the bottom edge of the parent control, if there is one, or the owning window.
This property is read-only.
DesktopChart.LockLeft
LockLeft As Boolean
Determines whether the left edge of the control should stay at a set distance from the left edge of the parent control, if there is one, or the owning window.
This property is read-only.
DesktopChart.LockRight
LockRight As Boolean
Determines whether the right edge of the control should stay at a set distance from the right edge of the parent control, if there is one, or the owning window.
This property is read-only.
DesktopChart.LockTop
LockTop As Boolean
Determines whether the top edge of the control should stay at a set distance from the top edge of the parent control, if there is one, or the owning window.
This property is read-only.
DesktopChart.Mode
Mode As Modes
Indicates the type of chart the control is currently displaying.
This property is read-only.
Labels are required for a Bar chart to draw.
This example checks the mode of the chart:
If Chart1.Mode = DesktopChart.Modes.Bar then
Chart1.Title = "Sales Bar Chart"
End If
DesktopChart.Name
Name As String
The name of the control.
This property is read-only.
DesktopChart.Parent
Parent As Object
Used to get the control's parent control or page. If the parent control is a DesktopContainer, then it returns the DesktopContainer. If it is on a DesktopWindow, it returns the DesktopWindow.
This property is read-only.
DesktopChart.PopoverBackgroundColor
PopoverBackgroundColor As ColorGroup
The background color of the chart's popover.
DesktopChart.PopoverTextColor
PopoverTextColor As ColorGroup
The color of text in the chart's popover.
DesktopChart.TabIndex
TabIndex As Integer
The control's position in the Tab Order. The control with a TabIndex of 0 is the first control to get the focus when the window opens.
This example sets the control's TabIndex.
Me.TabIndex = 2
DesktopChart.TextColor
TextColor As ColorGroup
Gets or sets the color of the text. The default value is black.
The following example sets the TextColor.
Me.TextColor = Color.Red
DesktopChart.Title
Title As String
The title of the chart.
DesktopChart.Tooltip
Tooltip As String
Text of a message displayed as a tooltip.
The tip is displayed when the user places the mouse on the control and leaves it there.
This code in the Opening event of a Button sets the tooltip:
Me.Tooltip = "Save changes"
DesktopChart.Top
Top As Integer
The top of the control in local coordinates relative to the window.
DesktopChart.Visible
Visible As Boolean
If True, the control is drawn. If False, it's not.
Hide a control based on a checkbox setting:
If ShowEmailCheckbox.Value Then
EmailField.Visible = True
Else
EmailField.Visible = False
End If
DesktopChart.Width
Width As Integer
The width (in points) of the control.
This code in the Shown event handler increases the size of the control:
Me.Width = Me.Width + 50
Method descriptions
DesktopChart.AddDataset
AddDataset(dataset As ChartDataset)
Adds the dataset to the chart. Incompatible datasets are ignored.
DesktopChart.AddDatasetAt
AddDatasetAt(index As Integer, dataset As ChartDataset)
Adds the dataset to the chart at the index passed. Incompatible datasets are ignored.
DesktopChart.AddDatasets
AddDatasets(datasets() As ChartDataset)
Adds the array of datasets to the chart.
DesktopChart.AddLabel
AddLabel(name As String)
Adds the label to the chart.
DesktopChart.AddLabelAt
AddLabelAt(index As String, name As String)
Adds the label to the chart at the index passed.
DesktopChart.AddLabels
AddLabels(names() As String)
Adds the array of labels to the chart.
DesktopChart.Close
Close
Closes the control.
DesktopChart.DatasetAt
DatasetAt(index As Integer) As ChartDataset
Returns the ChartDataset at the index passed.
DesktopChart.DrawInto
DrawInto(g As Graphics, x As Integer, y As Integer)
Draws the contents of the control into the specified Graphics context. The parameters x and y are the coordinates of the top, left corner.
Note
DrawInto will only work if the control is on a window or container.
This example draws the current control into the Graphics of a Picture and then displays it as the Backdrop of a Canvas:
Var p As New Picture(Me.Width, Me.Height)
Me.DrawInto(p.Graphics, 0, 0)
Canvas1.Backdrop = p
DesktopChart.LabelAt
LabelAt(index As Integer) As String
Returns the label at the index passed.
DesktopChart.RemoveAllDatasets
RemoveAllDatasets
Removes all datasets from the chart.
DesktopChart.RemoveAllLabels
RemoveAllLabels
Removes all labels from the chart.
DesktopChart.RemoveDatasetAt
RemoveDatasetAt(index As Integer)
Removes the ChartDataset at the index passed.
DesktopChart.RemoveLabelAt
RemoveLabelAt(index As Integer)
Removes the label at the index passed.
DesktopChart.SetFocus
SetFocus
Sets the focus to the DesktopChart control.
Event descriptions
DesktopChart.Activated
Activated
The control is activated. In a single window interface, the Activate event fires when the parent window is activated. See the DesktopApplication and DesktopWindow Activate events.
This can be because the app is launched or a window belonging to another app is no longer frontmost (active). The Deactivate event fires when another window becomes active. In a single window interface, the Activate event fires when the window is activated, e.g., when the app first displays the window.
DesktopChart.Closing
Closing
The control is about to be removed from the window either because the window is closing or the control's Close method was called.
DesktopChart.ConstructContextualMenu
ConstructContextualMenu(Base As DesktopMenuItem, x As Integer, y As Integer) As Boolean
This event is called when it is appropriate to display a contextual menu for the control.
This event handler is the recommended way to handle contextual menus because this event figures out whether the user has requested the contextual menu, regardless of how they did it. Depending on platform, it might be in the MouseUp or MouseDown event and it might be a right+click or by pressing the contextual menu key on the keyboard, for example.
Base is analogous to the menu bar for the contextual menu. Any items you add to Base will be shown as menu items. If you return False, the event is passed up the parent hierarchy.
If you return True, the contextual menu is displayed. The parameters x and y are the mouse locations. If the event was fired because of a non-mouse event, then x and y are both set to -1. See the example of a contextual menu in the following section.
The following ConstructContextualMenu event handler builds a menu with three menu items plus a submenu with three additional menu items.
// Add some items
base.AddMenu(New DesktopMenuItem("Test 1"))
base.AddMenu(New DesktopMenuItem("Test 2"))
base.AddMenu(New DesktopMenuItem("Test 3"))
// Add a Separator
base.AddMenu(New DesktopMenuItem(DesktopMenuItem.TextSeparator))
// Add a sub menu
Var submenu As New DesktopMenuItem("SubMenu")
submenu.AddMenu(New DesktopMenuItem("SubMenu Test 1"))
submenu.AddMenu(New DesktopMenuItem("SubMenu Test 2"))
submenu.AddMenu(New DesktopMenuItem("SubMenu Test 3"))
base.AddMenu(submenu)
// Add a Separator
base.AddMenu(New DesktopMenuItem(DesktopMenuItem.TextSeparator))
Return True
DesktopChart.ContextualMenuSelected
ContextualMenuSelected(selectedItem As DesktopMenuItem)
Called when selectedItem is chosen from a contextual menu.
This code populates a contextual menu in the Opening event of a Chart control:
Var menu As New DesktopMenuItem
menu.AddMenuItem("One")
menu.AddMenuItem("Two")
menu.AddMenuItem("Three")
Me.ContextualMenu = menu
The menu selection is then handled by the ContextualMenuSelected event when the user right-clicks on the control. For example, it can be of the form:
Select case selectedItem.Text
Case "One"
MessageBox("One")
Case "Two"
MessageBox("Two")
Case "Three"
MessageBox("Three")
End Select
DesktopChart.Deactivated
Deactivated
The DesktopChart is deactivated. See the DesktopApplication and DesktopWindow Deactivated events.
In a multiple window interface, the Deactivated event fires when the parent window is deactivated because another window has been brought to the front or a window belonging to another app becomes frontmost. In a single window app, the Deactivated event fires when a window belonging to another app becomes frontmost.
DesktopChart.DragEnter
DragEnter(obj As DragItem, Action As DragItem.Types) As Boolean
Fires when the passed DragItem enters the DesktopChart control.
Returns a Boolean. Return True from this event to prevent the drop from occurring.
The Action parameter specifies the type of drag action.
To restrict file drops to just folders (and not files), you can put this code in the DragEnter event:
If Not obj.FolderItem.IsFolder Then Return True
DesktopChart.DragExit
DragExit(obj As DragItem, Action As DragItem.Types)
Fires when the passed DragItem exits the DesktopChart control.
The Obj parameter is the item being dragged. The Action parameter specifies the type of drag action.
DesktopChart.DragOver
DragOver(x As Integer, y As Integer, obj As DragItem, Action As DragItem.Types) As Boolean
Fires when the DragItem is over the DesktopChart control.
The Obj parameter is the object being dragged. The coordinates x and y are relative to the DesktopUIControl. Returns a Boolean. Return True from this event to prevent the drop from occurring.
The Action parameter specifies the type of drag action, which is typically done by holding down a modifier key (Shift, Alt, Option, Command, etc.) while doing the drag.
DesktopChart.DropObject
DropObject(Obj As DragItem Action As DragItem.Types)
The item represented by Obj has been dropped on the control.
The Obj parameter is the object being dragged. The Action parameter specifies the type of drag action.
The following DropObject event handler can handle either a dropped picture or a dropped file. The type of file that it can handle needs to have been specified in a call to AcceptFileDrop prior to the drop, for example, in the Opening event.
If Obj.PictureAvailable Then
Me.Image = obj.Picture
ElseIf Obj.FolderItemAvailable Then
Me.Image = Picture.Open(obj.FolderItem)
End If
DesktopChart.Error
Error(DataSet As ChartDataSet)
The chart either has no room to display the data or is too small to draw the grid. The DataSet is the ChartDataSet assigned to the control.
DesktopChart.FocusLost
FocusLost
The control has lost the focus.
This property must be set to True for the control to be capable of getting then losing the focus.
Note
On macOS, controls other than text fields and lists will accept and lose focus only if the full keyboard access option is enabled in System Preferences/Keyboard.
DesktopChart.FocusReceived
FocusReceived
The control has received the focus and has a selection rectangle around it.
This property must be set to True for the control to be capable of getting the focus.
Note
On macOS, controls other than text fields and lists will accept focus only if the full keyboard access option is enabled in System Preferences/Keyboard.
DesktopChart.KeyDown
KeyDown(Key As String) As Boolean
The user has pressed the Key passed while the control has the focus.
How KeyDown works depends on the type of control.
Returning True means the key is intercepted, preventing the key from actually reaching the control at all. This would be useful if you want to override the behavior of the tab key for example. Returning False means the key reaches the control.
DesktopChart.KeyUp
KeyUp(Key As String)
Fires when the passed Key is released in the control that has the focus.
It is not guaranteed to be the same key that received the KeyDown event.
DesktopChart.MenuBarSelected
MenuBarSelected
Indicates that the control has the focus and a menu (not a menu item) has been selected by the user.
DesktopChart.Opening
Opening
The control has been created and the page is opening but has not been sent to the browser yet.
The Opening event handler can be used to initialize non-visual properties and settings for controls.
DesktopChart.Pressed
Pressed(dataset As ChartDataset, index As Integer)
The user pressed on a part of the chart that represents data from the dataset.
Compatibility
Desktop projects on all supported operating systems.
See also
DesktopCanvas parent class; ChartCircularDataset, ChartDataset, ChartLinearDataset and ChartScatterDatapoint classes.