2 Answers, 1 is accepted
0
Hi Jason,
Thank you for writing.
By default only the points which are falling have fill and you can set it's color like this:
If you want to have specific colors for all points you should create a cutom renderer. The following snippet shows how you can implement this for the candlestic series:
I hope this helps. Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Telerik
Thank you for writing.
By default only the points which are falling have fill and you can set it's color like this:
candlestickSeries.BorderColor = Color.Red;
If you want to have specific colors for all points you should create a cutom renderer. The following snippet shows how you can implement this for the candlestic series:
public
class
CustomCartesianRenderer : CartesianRenderer
{
public
CustomCartesianRenderer(CartesianArea area)
:
base
(area)
{ }
protected
override
void
Initialize()
{
base
.Initialize();
for
(
int
i = 0; i <
this
.DrawParts.Count; i++)
{
CandlestickSeriesDrawPart linePart =
this
.DrawParts[i]
as
CandlestickSeriesDrawPart;
if
(linePart !=
null
)
{
this
.DrawParts[i] =
new
CustomCandlestickSeriesDrawPart((CandlestickSeries)
this
.Area.Series[0],
this
);
}
}
}
}
public
class
CustomCandlestickSeriesDrawPart : CandlestickSeriesDrawPart
{
public
CustomCandlestickSeriesDrawPart(CandlestickSeries series, IChartRenderer renderer)
:
base
(series, renderer)
{ }
public
override
void
DrawSeriesParts()
{
// base.DrawSeriesParts();
RadGdiGraphics radGraphics =
new
RadGdiGraphics(((Graphics)
this
.Renderer.Surface));
for
(
int
i = 0; i <
this
.Element.Children.Count; i++)
{
DataPointElement childElement = (DataPointElement)
this
.Element.Children[i];
RadRect slot =
this
.Element.DataPoints[i].LayoutSlot;
RectangleF rect =
new
RectangleF((
float
)(
this
.OffsetX + slot.X), (
float
)(
this
.OffsetY + slot.Y), (
float
)slot.Width, (
float
)slot.Height);
rect.Y++;
OhlcDataPoint point =
this
.Element.DataPoints[i]
as
OhlcDataPoint;
GraphicsPath path = ConstructPath(point, rect);
if
(childElement.BackgroundShape !=
null
)
{
childElement.BackgroundShape.Paint((Graphics)radGraphics.UnderlayGraphics, rect);
}
if
(point.IsFalling)
{
childElement.BackColor = Color.Green;
FillPrimitiveImpl fill =
new
FillPrimitiveImpl(childElement,
null
);
fill.PaintFill(radGraphics, path, rect);
}
else
{
childElement.BackColor = Color.Red;
FillPrimitiveImpl fill =
new
FillPrimitiveImpl(childElement,
null
);
fill.PaintFill(radGraphics, path, rect);
}
BorderPrimitiveImpl border =
new
BorderPrimitiveImpl(childElement,
null
);
border.PaintBorder(radGraphics,
null
, path, rect);
}
}
}
I hope this helps. Should you have any other questions do not hesitate to ask.
Dimitar
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items
0

willie johnson
Top achievements
Rank 1
answered on 27 Feb 2018, 04:57 PM
thank you, Dimitar, please see my other post i was able to display them using SmartLabels, just need to figure out how to add connecting lines, please see attachment "snip_20180226163707.png", i want to add connecting line that connects the label to the candlestick with the ball on the end connecting to a single candlestick like in that pics, do i use the code u sent me to do that, also how do keep the label connected to candlestick when user uses mouse scroll, and pan?
See my post: https://www.telerik.com/forums/custom-smartlabel-scroll-pan-issue-help-format-smartlabel