This is a migrated thread and some comments may be shown as answers.

Add line in the candlestick / Items color

5 Answers 82 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Ricardo
Top achievements
Rank 1
Ricardo asked on 10 Aug 2010, 03:46 PM

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

Sort by
0
Giuseppe
Telerik team
answered on 13 Aug 2010, 09:51 AM
Hello Ricardo,

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
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 Public Issue Tracking system and vote to affect the priority of the items
0
Ricardo
Top achievements
Rank 1
answered on 16 Aug 2010, 04:41 PM

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

0
Giuseppe
Telerik team
answered on 19 Aug 2010, 05:20 PM
Hi Ricardo,

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
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 Public Issue Tracking system and vote to affect the priority of the items
0
Ricardo
Top achievements
Rank 1
answered on 09 Sep 2010, 05:41 PM
Hi,

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
0
Giuseppe
Telerik team
answered on 14 Sep 2010, 10:11 AM
Hi Ricardo,

Find attached a modified version of the sample application that demonstrates the desired functionality.

Hope this helps.


Best wishes,
Freddie
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Ricardo
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Ricardo
Top achievements
Rank 1
Share this question
or