コード例 #1
0
ファイル: ChartControl.xaml.cs プロジェクト: bdecori/win8
        public void ResultChartAddSeries(List<ResultData> listdata)
        {
            
            
                CategoricalSeries series = Activator.CreateInstance(typeof(LineSeries)) as CategoricalSeries;

                series.CategoryBinding = new PropertyNameDataPointBinding("Category");
                series.ValueBinding = new PropertyNameDataPointBinding("Value");
                series.Name = listdata[0].ResultName;
                series.Tag = listdata[0].OrderName;
                this.chart.VerticalAxis.ShowLabels = false;
                this.chart.HorizontalAxis.Margin = new Thickness(10, 5, 5, 10);

                ChartSeriesLabelDefinition csld = new ChartSeriesLabelDefinition();
            
         
                csld.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Right;
                csld.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
                csld.Template = CreateScatterDataLabelTemplate();

                series.LabelDefinitions.Add(csld);
                ResultData[] rdArray = null;
                rdArray = new ResultData[listdata.Count()];

                listdata.CopyTo(rdArray);

                for (int b = 0; b < rdArray.Length; b++)
                {
                    CategoricalDataPoint cdp = new CategoricalDataPoint();

                    cdp.Category = rdArray[b].Category;
                    cdp.Value = (double)rdArray[b].Value;
                    
                    cdp.Label = rdArray[b].ResultDisplayValue;
                   
                    series.DataPoints.Add(cdp);
                   
                }
          
                this.chart.Series.Add(series);

                ChartLegend leg = new ChartLegend();
                leg.ChartControl = this.chart;

                leg.BrushColor = chart.Palette.GetBrush(chart.Series.Count - 1, PaletteVisualPart.Stroke);
                leg.Text = listdata[0].ResultName + "\r\n" + listdata[0].ResultUnits;
                leg.SeriesName = series.Name;
                leg.ChartTitleParent = this.stackTitle;
                leg.StackPanelParent = this.legend;
                this.legend.Children.Add(leg);
          
           
        }
コード例 #2
0
ファイル: ChartLegend.xaml.cs プロジェクト: bdecori/win8
        private void move_legend_item_click(object sender, RoutedEventArgs e)
        {
           
            foreach (CartesianSeries cs in this.ChartControl.Series)
            {
                if (cs.Name == this.SeriesName)
                {
                    if (this.Location == "title")
                    {
                        cs.Visibility = Windows.UI.Xaml.Visibility.Visible;
                        cs.ShowLabels = false;
                        ChartLegend hold = new ChartLegend();
                        hold.ChartTitleParent = this.ChartTitleParent;
                        hold.StackPanelParent = this.StackPanelParent;
                        hold.SeriesName = this.SeriesName;
                        hold.BrushColor = this.BrushColor;
                        hold.Text = this.Text;
                        hold.ChartControl = this.ChartControl;
                        hold.Location = "legend";

                        this.StackPanelParent.Children.Add(hold);

                        this.ChartTitleParent.Children.Remove(this);
                    }
                    else
                    {
                        cs.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                        cs.ShowLabels = false;
                        ChartLegend hold = new ChartLegend();
                        hold.ChartTitleParent = this.ChartTitleParent;
                        hold.StackPanelParent = this.StackPanelParent;
                        hold.SeriesName = this.SeriesName;
                        hold.BrushColor = this.BrushColor;
                        hold.Text = this.Text;
                        hold.ChartControl = this.ChartControl;
                        hold.Location = "title";

                        this.StackPanelParent.Children.Remove(this);

                        this.ChartTitleParent.Children.Add(hold);
                    }
                    return;
                }
            }
           
        }
コード例 #3
0
ファイル: ChartControl.xaml.cs プロジェクト: bdecori/win8
        public void MedsAddSeries(List<MedData> listdata)
        {
            stackTitle.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
          

            string sPrevDrugname = "";
            string sPrevDrugStr = "";

            this.chart.HorizontalAxis =new LinearAxis();
            this.chart.VerticalAxis = new  LinearAxis();
            
            this.chart.VerticalAxis.ShowLabels = false;
            this.chart.HorizontalAxis.ShowLabels = false;

           
            ChartSeriesLabelDefinition csld = new ChartSeriesLabelDefinition();
            
            csld.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Right;
            csld.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
            csld.Template = CreateScatterDataLabelTemplate();

            int i = 0;
            int iTotalDays = 0;

            ScatterPointSeries sls = null;
           
            bool bSwitch = false;
            foreach (MedData md in listdata)
            {
               
                if (md.Drugname.Trim() != sPrevDrugname)
                {
                    sls = new ScatterPointSeries();
                    sls.Name = md.Drugname.Trim() + "_"+md.Strength.Trim();
                    sls.XValueBinding = new PropertyNameDataPointBinding("XValue");
                    sls.YValueBinding = new PropertyNameDataPointBinding("YValue");
                    sls.ShowLabels = true;
                    sls.LabelDefinitions.Add(csld);

                    sPrevDrugname = md.Drugname.Trim() ;
                    sPrevDrugStr = md.Strength;

                    bSwitch = true;
                    i = i + 20;
                    iTotalDays = 0;
                }
                
                for (int b = 0; b < md.Days; b++)
                {
                    
                        ScatterDataPoint sdp = new ScatterDataPoint();

                        sdp.XValue = b + iTotalDays;
                        sdp.YValue = i;

                        if (b == 1 )
                        {
                            sdp.Label = md.Drugname + " " + md.Strength;
                           
                        }
                        //only paint if there is data.
                        if (!string.IsNullOrEmpty(md.Strength))
                        {
                           sls.DataPoints.Add(sdp);
                        }
                }
                iTotalDays = iTotalDays + md.Days;
    
               
                if (bSwitch)
                {
                    this.chart.Series.Add(sls);
                    bSwitch = false;
                   
                   
                }

                SolidColorBrush br = chart.Palette.GetBrush(chart.Series.Count - 1, PaletteVisualPart.Stroke) as SolidColorBrush;
                sls.PointTemplate = CreateScatterDataTemplate(br.Color.ToString(), 1); 
            

                
            }
            int z = this.chart.Series.Count();
            z--;
            while( z >= 0)
            {
                ChartLegend leg = new ChartLegend();
                leg.ChartControl = this.chart;
                SolidColorBrush scb = new SolidColorBrush();
                scb.Color = Windows.UI.Colors.Black;

                leg.BrushColor = scb;
                leg.HideRect = true;
                string[] smed = this.chart.Series[z].Name.Split('_');

                leg.Text = smed[0];

                leg.SeriesName = this.chart.Series[z].Name;
                leg.StackPanelParent = this.legend;
                leg.ChartTitleParent = this.stackTitle;

                this.legend.Children.Add(leg);
                z--;
            }
            
        }