Hi,
Currently the candlestick graph has the LOW, OPEN, CLOSE and HIGH values. I need a line between the OPEN and CLOSE values.
To solve it, I thought in define two series for candlestick, one where the CLOSE and HIGH value go to this line and other where LOW and OPEN starts from it. The idea sounds good, but look what hapen in the image attached. There is a way to avoid that behavior? Is there another way to do this line?
Finally, I did one serie definition for a collection. But, I need that every item on this collection be painted with different collors. How I do that?
Thanks
5 Answers, 1 is accepted
You can achieve the desired effect through CandleStick re-templating and you will also need to create custom CandleStick / CandleStickSeriesDefinition pair of classes -- see the attached sample application.
As for the colors question -- the easiest way is to set SeriesDefinition.LegendDisplayMode to LegendDisplayMode.DataPointLabel.
Hope this helps.
Greetings,
Freddie
the Telerik team
Hi,
thank you for the answer.
The example works fine, but what I really need is that line to be paralell with the X axis and the possibility to set his Y value (candlestick has OPEN, CLOSE, LOW and HIGH, this line could be the MIDDLE line). There is a way to do it? I really need this.
Thanks again
You can extend the CustomCandleStick implementation like this:
public
class
CustomCandleStick : CandleStick
{
private
ParametricLine CustomLine
{
get
{
return
this
.GetTemplateChild(
"PART_CustomLine"
)
as
ParametricLine;
}
}
protected
override
void
UpdateParametricLinesCoordinates(Size constraint)
{
base
.UpdateParametricLinesCoordinates(constraint);
double
middleValue = (
this
.DataPoint.Open +
this
.DataPoint.Close) / 2;
DataRange minRange =
this
.CalculateRange(middleValue) * constraint.Height;
UpdateParametricLineCoordinates(
this
.CustomLine,
this
.Center - constraint.Width / 2, minRange.From,
this
.Center + constraint.Width / 2, minRange.From);
}
protected
override
void
UpdateParametricLinesParameters()
{
base
.UpdateParametricLinesParameters();
UpdateParametricLineParameter(
this
.CustomLine,
false
);
}
private
DataRange CalculateRange(
double
value)
{
DataRange axisRange =
new
DataRange(
this
.ChartArea.AxisY.ActualMinValue,
this
.ChartArea.AxisY.ActualMaxValue);
double
itemY = axisRange.Normalize(value);
double
zero = axisRange.Normalize(0d);
DataRange restrictedRange =
new
DataRange(DataRange.Unit.Restrict(zero), itemY);
return
DataRange.Unit.Invert(restrictedRange);
}
}
Hope this helps.
Sincerely yours,
Freddie
the Telerik team
Hi, this worked fine for me, but it's just almost what I need. I need set the y-value of the middle line between to OPEN and CLOSE bindings. It will not be in the exact middle. And I need to do it using bindings. There is a way to do that?
Thanks
Find attached a modified version of the sample application that demonstrates the desired functionality.
Hope this helps.
Best wishes,
Freddie
the Telerik team