in

Software FX Community

Discuss and find help for all Software FX products.

Map style Zoom causes exception when chart contains Annotation

Last post 01-13-2010 11:50 AM by Coder. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 01-13-2010 11:50 AM

    • Coder
    • Top 200 Contributor
    • Joined on 12-30-2008

    Map style Zoom causes exception when chart contains Annotation

    I have version 8.0.3629.29517.

    When I try to zoom a chart with Zoom.Style set to Map and my chart contains an Annotation I get an exception.  Here is an example.  Double-click the chart to enter zoom selection mode.

    With this object defined...

    private class DateValue
    {
       
    public DateTime Date { get; set; }
       
    public double Value { get; set; }
       
    public DateValue(DateTime date, double value)
        {
           
    Date = date;
            Value = value;
        }
    }

    This recreates the problem...

    Chart chart1 = new Chart();
    chart1.Width = 1024.0;
    chart1.Height = 768.0;
    chart1.LegendBox.Visibility =
    Visibility.Collapsed;

    Random rnd = new Random(123);
    List<DateValue> list1 = new List<DateValue>();

    for
    (int i = 0; i < 100; i++)
    {
        list1.Add(
    new DateValue(DateTime.Today.AddYears(-2).AddDays(i * 7), (double)rnd.Next(0, 200)));
    }

    Axis axisX = new Axis();
    Axis axisY = new Axis();
    axisX.DataFormat.Format =
    AxisFormat.Date;
    axisX.Labels.HorizontalAlignment =
    HorizontalAlignment.Right;
    axisX.Labels.Position =
    AxisLabelPosition.Center;
    axisX.Labels.Format =
    AxisFormat.Date;
    axisX.Min =
    DateTime.Today.AddYears(-2);
    axisX.Max =
    DateTime.Today;
    axisX.FontSize = 14;
    axisX.Title.Content =
    "Test";
    axisX.Title.FontSize = 14.0;
    axisY.Min = 0.0;
    axisY.Max = 200.0;
    axisY.AxisStyle =
    AxisStyles.ShowEnds | AxisStyles.AutoFirstLabel;
    axisY.Labels.Decimals = 1;
    chart1.AxesX.Clear();
    chart1.AxesY.Clear();
    chart1.AxesX.Add(axisX);
    chart1.AxesY.Add(axisY);

    SeriesAttributes sa = new SeriesAttributes();
    sa.Gallery = chart1.Gallery =
    Gallery.Line;
    sa.ItemsSource = list1;
    sa.BindingPath =
    "Value";
    sa.BindingPathX =
    "Date";
    sa.Content =
    "Test";
    sa.AxisX = axisX;
    sa.AxisY = axisY;
    chart1.Series.Add(sa);
    chart1.MouseDoubleClick +=
    delegate
    {
        chart1.Zoom.Style =
    ZoomStyle.Map;
        chart1.Zoom.Mode =
    ZoomMode.Selection;
    };

    Annotations anno = new Annotations();
    TextBlock tb = new TextBlock();
    tb.Text =
    "Test";
    tb.HorizontalAlignment =
    HorizontalAlignment.Left;
    tb.VerticalAlignment =
    VerticalAlignment.Bottom;
    tb.FontSize = 20.0;
    Annotations.SetAttachX(tb, axisX.Min);
    Annotations.SetAttachY(tb, axisY.Min);
    Annotations.SetAxisX(tb, axisX);
    Annotations.SetAxisY(tb, axisY);
    anno.Children.Add(tb);
    chart1.Extensions.Add(anno);

Page 1 of 1 (1 items)
Copyright 2008 Software FX, Inc.