The TRSCandleStickChart component is a RSBarCharts.TRSHighLowAverageChart descendant that represents a candlestick chart. The CandleStick Chart displays each chart value ( RSBarCharts.TRSCandleStickChartValue ) as a vertical or horizontal candlestick (depending on Orientation).
A candlestick chart is a style of financial chart used to describe price movements of a security, derivative, or currency. Each "candlestick" typically shows one day; so for example a one month chart may show the 20 trading days as 20 "candlesticks". It is something like a combination of line-chart and a bar-chart: each bar represents all four important pieces of information for that day: the open, the close, the high and the low.
Each value draws a separate candlestick and the order of the candlesticks is based on the order of the TRSCandleStickChartValue in the collection.
The TRSCandleStickChartValue class uses the Value property to specify the height of each candlestick. The X property specifies where in the horizontal axis that candlestick is located. The UpShape property specifies the Bar Style and Brush/Pen to use when a candlestick closes higher than it opens. The DownShape property specifies the Bar Style and Brush/Pen to use when a candlestick closes lower than it opens.
Note |
---|
Charts are TGraphicControl descendants for VCL and TControl descendants for FMX. Display charts on a chart panel (with integrated axes, legend, header, footers, etc) or stand-alone (allowing use of FMX effects or embedding within other controls). Set the Panel property to the RSChartPanel.TRSChartPanel you want the chart displayed inside or nil for stand-alone use. |
Namespace: RSBarCharts
TGraphicControl |
Delphi |
type |
|
|
(Inherited from RSChartPanel.TRSCustomChart.) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Draw(TCanvas,TCanvasRect,TRSChartAxis,TRSChartAxis,Boolean,Boolean) |
Overloaded. Paints the chart to the specified Canvas in the specified location. The Draw Method uses the supplied TRSChartAxis (instead of the HorizontalAxis and VerticalAxis properties) to convert the chart values into pixel coordinates. Unlike the regular Draw method, this method draws the axes as well (useful for when the chart is not connected to a panel). Use the Draw method to paint the chart to any canvas and anywhere and with any size on the canvas. |
(Inherited from RSChartPanel.TRSCustomChart.)
DrawAverageLine(TCanvas,TCanvasRect,TRSHighLowAverageChartValue,THighLowAverageStyle,Boolean)
Draw the line for the average on the side of the bar (Inherited from RSBarCharts.TRSHighLowAverageChart.)
DrawAxes(TCanvas,TCanvasRect,TRSChartAxis,TRSChartAxis)
Draws the specified axes to the Canvas (Inherited from RSChartPanel.TRSCustomChart.)
DrawBar(TCanvas,TCanvasRect,TRSBarChartValue)
Represents method DrawBar(TCanvas,TCanvasRect,TRSBarChartValue). (Inherited from RSBarCharts.TRSCustomBarChart.)
DrawGlyph(TCanvas,TCanvasRect)
Overloaded. Represents method DrawGlyph(TCanvas,TCanvasRect). (Inherited from RSChartPanel.TRSCustomChart.)
DrawGlyph(TCanvas,TRSChartValue,TCanvasRect)
Represents method DrawGlyph(TCanvas,TRSChartValue,TCanvasRect). (Overrides RSBarCharts.TRSHighLowAverageChart.DrawGlyph(TCanvas,TRSChartValue,TCanvasRect).)
DrawHLABar(TCanvas,TCanvasRect,TRSHighLowAverageChartValue,Boolean)
Draw the High/Low/Average Bar Shape (Overrides RSBarCharts.TRSHighLowAverageChart.DrawHLABar(TCanvas,TCanvasRect,TRSHighLowAverageChartValue,Boolean).)
Calls the OnDrawing event and returns True if the draw process should continue.
This method is called before the InternalDraw method.
DrawLabel(TCanvas,String,TCanvasPixel,TCanvasPixel,Single)
Overloaded. Draws the text caption centered above the X, Y point without clipping.
Note |
---|
The Opacity is ignored in VCL |
DrawLabel(TCanvas,String,TCanvasRect,Single)
Overloaded. Draws the text caption centered within the rectangle. The text is clipped
Note |
---|
The Opacity is ignored in VCL |
DrawLabel(TCanvas,TRSChartValue,TCanvasPixel,TCanvasPixel)
Overloaded. Draws the text caption centered above the X, Y point without clipping.
Note |
---|
The Opacity is specified by the RSChartPanel.TRSChartValue.Opacity property |
DrawLabel(TCanvas,TRSChartValue,TCanvasRect)
Overloaded. Draws a label for the TRSChartValue on the canvas. The text of the label is controlled by the ValueLabelStyle property.
The label is drawn within the specified rectangle.
Note |
---|
The Opacity is specified by the RSChartPanel.TRSChartValue.Opacity property |
Calls the OnDraw event.
This method is called after the InternalDraw method.
Re-enables screen repainting and change events. Use EndUpdate to re-enable screen repainting and change events that were turned off with the BeginUpdate method. (Inherited from RSChartPanel.TRSCustomChart.)
FormatValue(TRSChartValue,TRSLabelTextStyle)
Generates a label for the Value based on the TextStyle (Inherited from RSChartPanel.TRSCustomChart.)
Returns the vertical offset ( OffsetVertical).
If coUseVerticalOffset is not in Options, this method always returns 0. If coUseVerticalOffset is in Options, the function returns the OffsetVertical value.
Returns the adjusted origin for the bar chart. If the UseOriginproperty is set, this value is the Origin. If the UseOrigin property is false, the adjusted origin equals 0.
Note that when bar charts are stacked (see GroupStyle=gsStacked), the bottom-most bar chart adjusted origin is used as the origin for all the bar charts.
GetAxisCaption(TRSChartAxis,Integer,Double)
Represents method GetAxisCaption(TRSChartAxis,Integer,Double). (Inherited from RSBarCharts.TRSCustomSparseBarChart.)
GetBarRect(TCanvasRect,TRSBarChartValue)
Overloaded. Returns the canvas rectangle in pixels for the bar value (Inherited from RSBarCharts.TRSCustomBarChart.)
Returns the canvas rectangle in pixels for the bar value. (Overrides RSBarCharts.TRSCustomSparseBarChart.GetBarRect(TCanvasRect,TRSBarChartValue,TRSCustomChart,TRSChartValueType,TRSChartValueType,TRSChartValueType).)
Returns the bar style of the value (Overrides RSBarCharts.TRSCustomBarChart.GetBarStyle(TRSBarChartValue).)
Returns the chart type enumerated value for this class. Each chart class overrides this class function to return the RSChartConsts|TRSChartType enumerated value (Overrides RSBarCharts.TRSHighLowAverageChart.GetChartType.)
Overloaded. Represents method GetColor. (Inherited from RSChartPanel.TRSCustomChart.)
Returns the color of the chart value. The color of the TRSChartValue can change depending on the Options property as well as any other chart states (e.g., the TRSCandleStickChart class overrides this method to turn the color red or green depending on if the Open value is greater than the Closing Value) (Overrides RSChartPanel.TRSCustomChart.GetColor(TRSChartValue).)
GetCumulativeTotal(Integer,Integer,TRSCustomChartClass)
Determine the cumulative value at this index for all charts in the Group. The ValIndex specifies the TRSChartValue.Values dimension to compare.
Used for stacking charts.
GetCumulativeValue(Integer,Integer,TRSCustomChartClass)
Determine the cumulative value at this index for all charts below (spatially) this chart in the same Group. The ValIndex specifies the TRSChartValue.Values dimension to compare.
Used for stacking charts.
Represents method GetGroupDimension. (Overrides RSChartPanel.TRSCustomChart.GetGroupDimension.)
Returns a new chart color based on the ChartColorScheme and ChartColorList. Every time a chart is created, it is assigned a new color from the current ChartColorList. (Inherited from RSChartPanel.TRSCustomChart.)
Initialize the OnChange events of structures. Use this method to assign event handlers for structures (e.g., Pen.OnChange := MyChangeMethod).
Notes to Inheritors |
---|
The constructor calls this method after it calls the InitializeChart method, which is where the structures should be actually created and initialized. |
Creates and initialize structures and values of chart. This method is the safe place to initialize chart values without change events occurring.
Notes to Inheritors |
---|
The constructor calls this method. Use this method to actually create and initialize properties. Do not assign event properties in this method (use the InitializeChangeEvents method instead) |
InternalDraw(TCanvas,TCanvasRect)
Overloaded. Paints the chart graphic to the specified canvas at the specified rectangle. The InternalDraw method is called by the Draw method.
Descendant classes of TRSCustomChart override the InternalDraw method to actually paint themselves.
Notes to Inheritors |
---|
The default InternalDraw method implementation assigns the Brush, Pen , and Font to the Canvas. |
InternalSelect(TCanvasRect,TRSChartSelectionAction)
Selects or deselects chart Values ( RSChartPanel.TRSChartValue ) based on whether they intersect with the selection rectangle (which is in pixel coordinates).
The base method converts the SelectionRect to chart coordinates (based on HorizontalAxis and VerticalAxis) and then selects values based on the TRSChartValue.Selectable method
Returns True if any value in the chart intersects with the SelectionRect (Inherited from RSChartPanel.TRSCustomChart.)
Represents method IsValuesStored. (Inherited from RSChartPanel.TRSCustomChart.)
Indicates whether the chart is visible. A chart is visible if its Visible property is True and both axes have been assigned. (Inherited from RSChartPanel.TRSCustomChart.)
Represents method Loaded. (Inherited from RSChartPanel.TRSCustomChart.)
Represents method MouseHover(TCanvasRect). (Inherited from RSChartPanel.TRSCustomChart.)
Notification(TComponent,TOperation)
Represents method Notification(TComponent,TOperation). (Overrides RSChartPanel.TRSCustomChart.Notification(TComponent,TOperation).)
Represents method Paint. (Inherited from RSChartPanel.TRSCustomChart.)
Represents method PanelChanged. (Inherited from RSChartPanel.TRSCustomChart.)
Represents method RSVisibleChanged. (Inherited from RSChartPanel.TRSCustomChart.)
SaveCanvasResources(TCanvas,TBrush,TRSPen,TFont)
Represents method SaveCanvasResources(TCanvas,TBrush,TRSPen,TFont). (Inherited from RSChartPanel.TRSCustomChart.)
Select(TCanvasRect,TRSChartSelectionAction)
Selects or deselects chart Values ( RSChartPanel.TRSChartValue ) based on whether they intersect with the selection rectangle (which is in pixel coordinates).
The base method converts the SelectionRect to chart coordinates (based on HorizontalAxis and VerticalAxis) and then selects values based on the TRSChartValue.Selectable method
Notes to Inheritors |
---|
Descendant classes override the InternalSelect method |
Represents method SelectionColorChanged. (Inherited from RSChartPanel.TRSCustomChart.)
Overloaded. Represents method SenderChanged(TObject). (Inherited from RSChartPanel.TRSCustomChart.)
SetCanvasResources(TCanvas,TBrush,TRSPen,TFont,Boolean,Boolean)
Overloaded. Represents method SetCanvasResources(TCanvas,TBrush,TRSPen,TFont,Boolean,Boolean). (Inherited from RSChartPanel.TRSCustomChart.)
SetCanvasResources(TCanvas,TRSChartValue,Boolean,Boolean)
Represents method SetCanvasResources(TCanvas,TRSChartValue,Boolean,Boolean). (Overrides RSChartPanel.TRSCustomChart.SetCanvasResources(TCanvas,TRSChartValue,Boolean,Boolean).)
Represents method SetColor(TCanvasColor). (Inherited from RSChartPanel.TRSCustomChart.)
Represents method SetOptions(TChartOptions). (Inherited from RSChartPanel.TRSCustomChart.)
Represents method UpdateAxisInfo(TRSChartAxis). (Overrides RSChartPanel.TRSCustomChart.UpdateAxisInfo(TRSChartAxis).)
Updates the values to the current color scheme. If PanelColorScheme is True then uses the Panel's color scheme (Inherited from RSChartPanel.TRSCustomChart.)
ValueSelectionChanged(TRSChartValue)
Represents method ValueSelectionChanged(TRSChartValue). (Inherited from RSChartPanel.TRSCustomChart.)
ValueVisibleChanged(TRSChartValue)
Represents method ValueVisibleChanged(TRSChartValue). (Inherited from RSChartPanel.TRSCustomChart.)
Returns true if the chart prefers Captions over Values for its labels on the input Axis. This method provides a hint to the TRSChartAxis when LabelStyle is alsAutomatic. (Overrides RSBarCharts.TRSCustomSparseBarChart.WantsCaptions(TRSChartAxis).)
|
To display a chart, you drop the component on a form and optionally connect its Panel property to the RSChartPanel.TRSChartPanel component where you want it to be displayed. The Values property is the most important property of the chart type and allows you to define the chart values at design-time or run-time. For the CandleStick Chart, the Values property contains TRSCandleStickChartValue collection items which define the X location and Open, Close, Low, High, and Average of the candlestick. To display a candlestick chart inside a chart panel: • Drop a TRSCandleStickChart component on a form • Drop a TRSChartPanel component where you want the chart to be displayed. (Note, more than one chart can share the same chart panel) • Connect the Panel property of the chart to the chart panel |
To add a candlestick to the chart (at Design-Time):
• Select the TRSCandleStickChart component • Click the ellipsis button (...) for the Values property of the chart. This action displays Delphi's Collection Editor for the TRSCandleStickChartValues collection. • Use the Add button to add candlesticks (TRSCandleStickChartValue collection item) to the chart. • Edit the X property for the horizontal location of the candlestick • Edit the Open, Close, High, Low, and Average properties to specify the candlestick vertically • Optionally, change the Style of the candlestick chart. This changes all candlestick shapes. |
The following code sets up a TRSCandleStickChart to display a couple of candlesticks:
Delphi |
---|
var |