ContextMenu not available!

Apr 27, 2009 at 7:19 PM
Edited Apr 28, 2009 at 3:14 AM
Hi,

I want to report a bug that was quite difficult to spot in my own application because sometimes the context menu is available and sometimes it is not!

When you right click the chart which is inserted in a container (in this example a stack panel), the context menu is not available anymore.
Please run the following code.

As an other example, the context menu is not available in a chart inserted in a grid and then inserted in a dockable content of this EXCELLENT PROJECT:
http://www.codeplex.com/AvalonDock

Thanks,
Kamel

Xaml Code:

<Window x:Class="ddd_LiveSample.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:my="http://research.microsoft.com/DynamicDataDisplay/1.0"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <DockPanel>
        <my:ChartPlotter Margin="12,12.02,12,41" Name="plotter" >
        <my:ChartPlotter.HorizontalAxis>
            <my:HorizontalDateTimeAxis Name="dateAxis"/>
        </my:ChartPlotter.HorizontalAxis>
        </my:ChartPlotter>
            </DockPanel>
        <Button Height="23" Margin="98,0,80,12" Name="button1" VerticalAlignment="Bottom" Click="button1_Click">Begin Simulation!</Button>
    
        </Grid>
</Window>


C# Code:

    1 using System;

    2 using System.Collections.Generic;

    3 using System.Linq;

    4 using System.Text;

    5 using System.Windows;

    6 using System.Windows.Controls;

    7 using System.Windows.Data;

    8 using System.Windows.Documents;

    9 using System.Windows.Input;

   10 using System.Windows.Media;

   11 using System.Windows.Media.Imaging;

   12 using System.Windows.Navigation;

   13 using System.Windows.Shapes;

   14 using Microsoft.Research.DynamicDataDisplay;

   15 using Microsoft.Research.DynamicDataDisplay.DataSources;

   16 using System.Threading;

   17 

   18 namespace ddd_LiveSample

   19 {

   20     /// <summary>

   21     /// Interaction logic for Window1.xaml

   22     /// </summary>

   23     public partial class Window1 : Window

   24     {

   25         private ObservableDataSource<Trade> _source;

   26         private Random _Random;

   27 

   28         public Window1()

   29         {

   30             InitializeComponent();

   31             _Random = new Random();

   32             EditPlotter();

   33         }

   34 

   35 

   36 

   37         public void EditPlotter()

   38         {

   39             _source = new ObservableDataSource<Trade>();

   40 

   41             // Set identity mapping of point in collection to point on plot

   42             _source.SetXMapping(ci => TimeSpan.FromTicks(ci.Date.Ticks).TotalDays);

   43             _source.SetYMapping(p => p.Price);

   44 

   45             dateAxis.ConvertToDouble = dt => TimeSpan.FromTicks(dt.Ticks).TotalDays;

   46             dateAxis.ConvertFromDouble = d => new DateTime(TimeSpan.FromDays(d).Ticks);

   47 

   48 

   49             // Add graph. Colors are not specified and chosen random

   50             plotter.AddLineGraph(_source, 2, "Data row 1");

   51 

   52             // Force everyting to fit in view

   53             plotter.Viewport.FitToView();

   54 

   55         }

   56 

   57         private void button1_Click(object sender, RoutedEventArgs e)

   58         {

   59             Thread thread = new Thread(Simulation);

   60             thread.Start();

   61             thread.IsBackground = true;

   62         }

   63 

   64         private void Simulation()

   65         {

   66             for (int counter = 0; counter < 100; counter++)

   67             {

   68                 Trade trade = new Trade(DateTime.Now, _Random.NextDouble());

   69                 _source.AppendAsync(Dispatcher, trade);

   70 

   71                 Thread.Sleep(100);

   72             }

   73         }

   74 

   75 

   76     }

   77 

   78     public class Trade

   79     {

   80         public DateTime Date { get; set; }

   81         public double Price { get; set; }

   82 

   83 

   84         public Trade(DateTime dateTime, double price)

   85         {

   86             Date = dateTime;

   87             Price = price;

   88         }

   89     }

   90 

   91 

   92 }



Editor
Apr 28, 2009 at 8:22 AM
Edited Apr 28, 2009 at 8:25 AM
Hi,

I was unable to reproduce this bug with the most recent version of D3 I have.

But in this app I've found a bug in D3 with mayor axis labels - they are disappearing from time to time.

Regards,
Mikhail Brinchuk,
DynamicDataDisplay Dev team.

Apr 30, 2009 at 2:25 AM
Hi Mikhail,

You're right, the reported bug is not anymore in the new version.
However in the version posted in this discussion http://dynamicdatadisplay.codeplex.com/Thread/View.aspx?ThreadId=50835, we could compress x or y axis by just scrolling the mouse on the corresponding axis but, in your new version, we can not do this anymore.

Can you, please, put back this feature for the next release?

Thanks,
Kamel
Editor
Apr 30, 2009 at 10:39 AM
Hi Kamel,

I've specially ascertained that I have not forgot to include such AxisNavigation as a navigation, added to ChartPlotter by default - I didn't :)

By the way, DynamicDataDisplay has a new release v0.3 - it is here - http://dynamicdatadisplay.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=26761

Best regards,
Mikhail.