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

Overlay Candlestick Chats

1 Answer 82 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Alex Witkowski
Top achievements
Rank 1
Alex Witkowski asked on 26 Aug 2009, 08:48 AM
Hi there,
I have coded something for creating an cnadlestick-chart with datetime values on x-axis using time.ToOADate().
The problem I have is that the Candlesticks Overlay each other somtimes.

Heres some Code:
RadChart1.PlotArea.XAxis.MinValue = startTime.ToOADate(); 
RadChart1.PlotArea.XAxis.MaxValue = endTime.ToOADate(); 
RadChart1.PlotArea.XAxis.IsZeroBased = false
RadChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime; 
RadChart1.PlotArea.XAxis.Step = DateTime.Now.AddMinutes(10).ToOADate() - DateTime.Now.ToOADate(); 
RadChart1.PlotArea.XAxis.LabelStep = 6; 
 
while (startTime < endTime) 
RadChart1.Series[0].Items.Add(new Telerik.Charting.ChartSeriesItem { XValue = startTime.ToOADate(), YValue = begin, YValue2 = end, YValue3 = max, YValue4 = min }); 
startTime = startTime.AddMinutes(10); 
Please help.

Greetings Alex ;)

Edit:
Second problem, how can i add a linebreak to an tooltip-text?


1 Answer, 1 is accepted

Sort by
0
Velin
Telerik team
answered on 28 Aug 2009, 10:30 AM
Hi Alex,

Unfortunately, this seems to be a problem which our developers will further investigate and will provide a solution in a future version of the control. In the meanwhile, I can suggest you to create the ChartSeriesItems without XValue and after that setting the labels right on the XAxis. Here is how you could do this:
List<string> xLabels = new List<string>(); 
 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        DateTime today = DateTime.Today; 
        DateTime startTime = today.AddHours(8); 
        DateTime endTime = today.AddHours(10); 
 
        ChartSeries candleStickSeries = new ChartSeries("Candles", ChartSeriesType.CandleStick); 
        RadChart1.Series.Add(candleStickSeries); 
 
        RadChart1.PlotArea.XAxis.LabelStep = 6
 
        int timeShift = 0
 
        while (startTime.AddMinutes(timeShift)<= endTime) 
        { 
            ChartSeriesItem item = new ChartSeriesItem { YValue = 1YValue2 = 5YValue3 = 8YValue4 = 0 }; 
            xLabels.Add(startTime.AddMinutes(timeShift).ToShortTimeString()); 
            RadChart1.Series[0].Items.Add(item); 
            timeShift += 10; 
        } 
 
        RadChart1.BeforeLayout += new EventHandler<EventArgs>(RadChart1_BeforeLayout); 
    } 
 
    void RadChart1_BeforeLayout(object sender, EventArgs e) 
    { 
        for (int i = 0; i < RadChart1.PlotArea.XAxis.Items.Count; i++) 
        { 
            RadChart1.PlotArea.XAxis.Items[i].TextBlock.Text = xLabels[i]; 
        } 
    } 

  Hope this will help.

Regards,
Velin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Chart (Obsolete)
Asked by
Alex Witkowski
Top achievements
Rank 1
Answers by
Velin
Telerik team
Share this question
or