Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Add a legend to a xamdatachart programmatically
posted

Hi,

I'm using a xamDataChart into a tile manager to display datas.

Every new data dropped into the tile manager generate a xamdatachart programmatically, every thing is ok, but I can't add a legend to the Chart.

The legend is ok, I can add it into a tile, but not in a XamDataChart...

I'm missong something, but can't figure out what :

Here is may code :

                XamDataChart AcquisDataChart = new XamDataChart();
                AcquisDataChart.WindowPositionHorizontal = 0;
                AcquisDataChart.WindowPositionVertical = 0;
                AcquisDataChart.WindowScaleHorizontal = 0.05;
                AcquisDataChart.WindowScaleVertical = 1;
                AcquisDataChart.HorizontalZoomable = true;
                AcquisDataChart.HorizontalZoombarVisibility = Visibility.Visible;
                AcquisDataChart.VerticalZoomable = true;
                AcquisDataChart.VerticalZoombarVisibility = Visibility.Visible;
                AcquisDataChart.UseTiledZooming = true;
                AcquisDataChart.AllowDrop = true;
                AcquisDataChart.Drop += AcquisDataChart_DropSerie;
                AcquisDataChart.VerticalAlignment = VerticalAlignment.Stretch;
                AcquisDataChart.Margin = new Thickness(0, 0, 0, 0);
                AcquisDataChart.Padding = new Thickness(0, 0, 0, 0);

                legend = new Legend
                {
                    Content = "Legend",
                    Margin = new Thickness(20),
                    VerticalAlignment = VerticalAlignment.Top,
                    HorizontalAlignment = HorizontalAlignment.Right
                };

                TileManager.Items.Add(AcquisDataChart);

                //On crée les axes et on binde au nouveau jeu de données.
                CategoryDateTimeXAxis catXAxis = new CategoryDateTimeXAxis();
                catXAxis.ItemsSource = newData.listOfDatas;
                catXAxis.DateTimeMemberPath = "Time";
                catXAxis.LabelSettings = new AxisLabelSettings();
                catXAxis.LabelSettings.Extent = 30;
                catXAxis.LabelSettings.Location = AxisLabelsLocation.OutsideBottom;
                catXAxis.Label = "{Time:HH:mm:ss}";

                NumericYAxis numYAxis = new NumericYAxis();
                numYAxis.LabelSettings = new AxisLabelSettings();
                numYAxis.LabelSettings.Extent = 30;

                LineSeries line = new LineSeries();
                line.Name = data.ToString();
                line.ValueMemberPath = "Y";
                line.ItemsSource = newData.listOfDatas;
                line.XAxis = catXAxis;
                line.YAxis = numYAxis;
                line.MarkerType = MarkerType.None;
                line.Thickness = 1;
                line.Resolution = 1.5;
                line.IsHighlightingEnabled = true;
                line.IsTransitionInEnabled = true;
                line.IsCustomCategoryStyleAllowed = true;
                line.MouseLeftButtonDown += Line_MouseLeftButtonDown;
                line.MouseLeftButtonUp += Line_MouseLeftButtonUp;
                line.MouseMove += Line_MouseMove;
                line.Title = newData.Name + "-" + newData.AcquiSource + "-" + newData.LapSource;

                line.Legend = legend;
                legend.Visibility = Visibility.Visible;

                AcquisDataChart.Axes.Add(catXAxis);
                AcquisDataChart.Axes.Add(numYAxis);
                AcquisDataChart.Series.Add(line);

Thank you for your help !

Parents Reply Children
No Data