Пример #1
0
 public LineChart(ChartSize size, ChartData data, AxisType axisTypes, AxisLabels labels, AxisRange ranges)
     : base(LineTypeDefinition, size, data)
 {
     _labels = labels;
     _axisType = axisTypes;
     _ranges = ranges;
 }
Пример #2
0
        public DataSetMultiSeries(List<SeriesDataPoints> datapoints_col, AxisLabels labels)
        {
            if (datapoints_col == null)
            {
                throw new System.ArgumentNullException("datapoints_col");
            }

            if (labels == null)
            {
                throw new System.ArgumentNullException("labels");
            }

            foreach (var series in datapoints_col)
            {
                int num_rows = series.Count;
                if (num_rows != labels.Count)
                {
                    string msg =
                        string.Format("Number of values and labels do not match. {0} values given and {1} labels given",
                                      series.Count, labels.Count);

                    throw new System.ArgumentException(msg);
                }
            }

            this.DataPointsCollection = datapoints_col;
            this.XAxisLabels = labels;
        }
        public Chart3DControl()
        {
            //BUG in WPF probably - really slow performance - dont do it

            /*ParentControl = new ElementHost
             * {
             *  Child = this,
             *  BackColor = System.Drawing.Color.White,
             *  Dock = DockStyle.Fill
             * };*/
            InitializeComponent();

            axisLabels = new AxisLabels(canvasOn3D);

            Focusable = true;


            Mode = Chart3DMode.Surface;

            MouseDown += OnViewportMouseDown;
            MouseMove += OnViewportMouseMove;
            MouseUp   += OnViewportMouseUp;
            // this.MouseEnter += new MouseEventHandler(Chart3DControl_MouseEnter);
            MouseWheel += OnViewportMouseWheel;
            KeyDown    += OnKeyDown;
            Quality     = 50;
        }
Пример #4
0
        void IRequireDataSourceUpdates.Remove(IChartRenderContext icrc, int startAt, IList items)
        {
            var remove = new List <FrameworkElement>();

            for (int ix = 0; ix < items.Count; ix++)
            {
                // remove requested item
                if (AxisLabels[startAt].element != null)
                {
                    remove.Add(AxisLabels[startAt].element);
                }
                AxisLabels.RemoveAt(startAt);
            }
            // re-sequence remaining items
            for (int ix = startAt; ix < AxisLabels.Count; ix++)
            {
                AxisLabels[ix].index = ix;
                AxisLabels[ix].value = ix;
            }
            // configure axis limits; just based on count-of-elements
            UpdateLimits(0);
            UpdateLimits(AxisLabels.Count);
            // finish up
            Layer.Remove(remove);
            RebuildAxisGeometry();
            Dirty = false;
        }
Пример #5
0
 public LineChart(ChartSize size, ChartData data, AxisType axisTypes, AxisLabels labels, DataScale dataScale)
     : base(LineTypeDefinition, size, data)
 {
     _labels = labels;
     _axisType = axisTypes;
     _dataScale = dataScale;
 }
        public void SetData(
            List <List <float> > lineData,
            float xMin,
            float xMax,
            int numberOfXLabels,
            float yMin,
            float yMax,
            int numberOfYLabels,
            float zMin,
            float zMax,
            int numberOfZLabels)
        {
            if (
                (_xAxisLabels == null) ||
                (_xAxisLabels.MaxValue != xMax) ||
                (_xAxisLabels.MinValue != xMin) ||
                (_xAxisLabels.Labels.Count != numberOfXLabels) ||
                (_yAxisLabels == null) ||
                (_yAxisLabels.MaxValue != yMax) ||
                (_yAxisLabels.MinValue != yMin) ||
                (_yAxisLabels.Labels.Count != numberOfYLabels) ||
                (_zAxisLabels == null) ||
                (_zAxisLabels.MaxValue != zMax) ||
                (_zAxisLabels.MinValue != zMin) ||
                (_zAxisLabels.Labels.Count != numberOfZLabels)
                )
            {
                _xAxisLabels = AxisLabels.Build(
                    xMin,
                    xMax,
                    numberOfXLabels,
                    _iConfiguration.ViewProjection == ViewProjection.BirdsEye_270,
                    ILabelFormatter.XLabel,
                    _textRenderer.MeasureTextLength);

                _yAxisLabels = AxisLabels.Build(
                    yMin,
                    yMax,
                    numberOfYLabels,
                    (_iConfiguration.ViewProjection == ViewProjection.BirdsEye_180),
                    ILabelFormatter.YLabel,
                    _textRenderer.MeasureTextLength);

                _zAxisLabels = AxisLabels.Build(
                    zMin,
                    zMax,
                    numberOfZLabels,
                    false,
                    ILabelFormatter.ZLabel,
                    _textRenderer.MeasureTextLength);
            }

            _axisScaling = 1000f / (float)Math.Max(lineData.Count - 1, lineData[0].Count - 1);

            _lineData = lineData;
            LoadVertices();
        }
Пример #7
0
        //在图表中显示信息
        private void Order_Chart(DataSeries series)
        {
            Chart chart = new Chart
            {
                //  Width = "Auto",
                //  Height = "Auto",
                View3D = true,
                Bevel  = true
            };

            chart.Titles.Add(new Title
            {
                Text = "在制品对比"
            });

            // X 坐标轴
            Axis xaxis = new Axis();

            // 设置坐标轴的背景色
            xaxis.Background = new SolidColorBrush(Colors.Gray);
            // 设置坐标轴上两点间的距离,这个属性不能和ScrollBarScale属性同时设置
            xaxis.ClosestPlotDistance = 2;
            // 坐标轴线的样式
            xaxis.LineStyle = LineStyles.Dashed;

            AxisLabels xal = new AxisLabels
            {
                Enabled = true,
                Angle   = -45
            };

            xaxis.AxisLabels = xal;
            // Y 坐标轴
            Axis       yaxis = new Axis();
            AxisLabels yal   = new AxisLabels
            {
                Enabled = true,
                Angle   = 45
            };

            yaxis.AxisLabels = yal;

            chart.AxesX.Add(xaxis);
            chart.AxesY.Add(yaxis);

            // 设置坐标轴的类型为 secondary
            series.AxisYType = AxisTypes.Secondary;
            series.RenderAs  = RenderAs.Column;
            chart.Series.Add(series);
            chart.SetValue(Grid.ColumnProperty, 1);
            LayoutRoot.Children.Add(chart);
        }
Пример #8
0
 public Axis(GraphPane pane)
 {
     mPane = pane;
     mMaximum = 0;
     mMinimum = 0;
     mScale = 1.0f;
     mTitle = new AxisTitle();
     mLabels = new AxisLabels();
     mMajorMark = new AxisMark(15.0f);
     mMinorMark = new AxisMark(6.0f);
     mAxisType = AxisType.Linear;
     mPen = SystemPens.ControlText;
 }
Пример #9
0
        /// <summary>
        /// Layout pass size changed.
        /// Just-in-time re-position of label element at exactly the right spot after it's done with (asynchronous) measure/arrange.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Element_SizeChanged(object sender, SizeChangedEventArgs e)
        {
#if false
            var vm = fe.DataContext as DataTemplateShim;
            _trace.Verbose($"{Name} sizeChanged ps:{e.PreviousSize} ns:{e.NewSize} text:{vm?.Text}");
#endif
            var fe    = sender as FrameworkElement;
            var state = AxisLabels.SingleOrDefault((sis) => sis.element == fe);
            if (state != null)
            {
                var loc = state.UpdateLocation();
                _trace.Verbose($"{Name} sizeChanged[{state.index}] loc:{loc} yv:{state.value} ns:{e.NewSize}");
            }
        }
Пример #10
0
        void IRequireDataSourceUpdates.Add(IChartRenderContext icrc, int startAt, IList items)
        {
            // mimic the DSRP sequence
            var widx = LabelStyle?.Find(FrameworkElement.WidthProperty);
            var bl   = new BindingEvaluator(LabelPath);
            // keep a separate list; easier at the end
            var reproc = new List <ItemState>();

            for (int ix = 0; ix < items.Count; ix++)
            {
                // add requested item
                var label  = bl.For(items[ix]);
                var istate = makeit(startAt + ix, label, widx == null);
                AxisLabels.Insert(startAt + ix, istate);
                reproc.Add(istate);
            }
            // re-sequence remaining items
            for (int ix = startAt + reproc.Count; ix < AxisLabels.Count; ix++)
            {
                AxisLabels[ix].index = ix;
                AxisLabels[ix].value = ix;
            }
            // render new items
            // run the element pipeline on the added items
            var recycler = new Recycler <FrameworkElement, ItemState>(CreateElement);
            var labels   = new List <ICategoryLabelState>(AxisLabels);
            var sc       = new SelectorContext(this, icrc.SeriesArea, labels);

            foreach (var istate in reproc)
            {
                ElementPipeline(sc, istate, recycler);
            }
            // configure axis limits; just based on count-of-elements
            UpdateLimits(0);
            UpdateLimits(AxisLabels.Count);
            // finish up
            Layer.Add(recycler.Created);
            RebuildAxisGeometry();
            Dirty = false;
        }
Пример #11
0
        public DataSetSingleSeries(SeriesDataPoints values, AxisLabels labels)
        {
            if (values == null)
            {
                throw new System.ArgumentNullException("values");
            }

            if (labels == null)
            {
                throw new System.ArgumentNullException("labels");
            }

            if (values.Count != labels.Count)
            {
                string msg =
                    string.Format("Number of values and labels do not match. {0} values given and {1} labels given",
                                  values.Count, labels.Count);

                throw new System.ArgumentException(msg);
            }
            this.DataPoints  = values;
            this.XAxisLabels = labels;
        }
Пример #12
0
        public DataSetSingleSeries(SeriesDataPoints values, AxisLabels labels)
        {
            if (values == null)
            {
                throw new System.ArgumentNullException("values");
            }

            if (labels == null)
            {
                throw new System.ArgumentNullException("labels");
            }

            if (values.Count != labels.Count)
            {
                string msg =
                    string.Format("Number of values and labels do not match. {0} values given and {1} labels given",
                                  values.Count, labels.Count);

                throw new System.ArgumentException(msg);
            }
            this.DataPoints = values;
            this.XAxisLabels = labels;
        }
Пример #13
0
        object IDataSourceRenderer.Preamble(IChartRenderContext icrc)
        {
            if (Theme?.TextBlockTemplate == null)
            {
                // already reported an error so this should be no surprise
                return(null);
            }
            if (String.IsNullOrEmpty(LabelPath))
            {
                return(null);
            }
            var bl = new BindingEvaluator(LabelPath);

            if (bl == null)
            {
                return(null);
            }
            var recycler = new Recycler <FrameworkElement, ItemState>(AxisLabels.Where(tl => tl.element != null).Select(tl => tl.element), CreateElement);

            ResetLimits();
            var widx = LabelStyle?.Find(FrameworkElement.WidthProperty);

            return(new State(new List <ItemState>(), recycler, icrc, widx == null, bl));
        }
        public void CreateChartSpline()
        {
            if (pros == null)
            {
                return;
            }
            if (maplist == null)
            {
                return;
            }
            if (sols == null)
            {
                return;
            }
            Calculation ca = new Calculation();

            ca.pros    = pros;
            ca.maplist = maplist;
            ca.sols    = sols;
            List <DeliverabilityDaily> listDd = new List <DeliverabilityDaily>();
            winProgressBar             wp     = new winProgressBar();
            var enconfig     = dao.CurrentDBContext.energyconfigs.Where(c => c.ProID == pros.id).ToList();
            var coals        = enconfig.Where(c => c.EnergyType == 7).FirstOrDefault();
            var naturalgases = enconfig.Where(c => c.EnergyType == 8).FirstOrDefault();
            var dust         = Convert.ToDouble(constanlist.Where(c => c.Name == "dust").FirstOrDefault().Value);
            var SO2          = Convert.ToDouble(constanlist.Where(c => c.Name == "SO2").FirstOrDefault().Value);
            var NOX          = Convert.ToDouble(constanlist.Where(c => c.Name == "NOX").FirstOrDefault().Value);

            wp.pb.Minimum      = 0;
            wp.pb.Value        = 0;
            wp.txtMessage.Text = "正在查询能源数据....";
            wp.pb.Maximum      = 2;
            wp.Owner           = Application.Current.MainWindow;
            wp.ShowInTaskbar   = false;
            wp.Show();
            listDd = ca.GetCalculation1(wp);
            if (listDd.Count == 0)
            {
                wp.Close();
                return;
            }
            txtModelName.Text = pros.name;
            txtSolName.Text   = sols.Name;
            txtTime.Text      = ca.Start.ToShortDateString() + "-" + ca.End.ToShortDateString();
            Chart chart = new Chart();

            GridChart.Children.Add(chart);
            var Canuse     = listDd.Sum(c => c.Canuse);
            var Coal       = listDd.Sum(c => c.Coal);
            var NaturalGas = listDd.Sum(c => c.NaturalGas);

            #region 图表初始化设置
            chart.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            chart.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
            chart.Margin = new Thickness(0, 100, 0, 0);
            //是否启用打印和保持图片
            chart.ToolBarEnabled = false;
            //设置图标的属性
            chart.ScrollingEnabled = false; //是否启用或禁用滚动
            chart.View3D           = false; //3D效果显示
            //创建一个标题的对象
            Title title = new Title();

            //设置标题的名称
            title.Padding = new Thickness(0, 10, 5, 0);

            //向图标添加标题
            chart.Titles.Add(title);
            chart.Titles[0].FontSize = 25;
            //chart.Titles[0].FontColor = Brushes.Blue;
            chart.LightingEnabled = true;


            //初始化一个新的Axis
            Axis xaxis = new Axis();
            //设置Axis的属性
            //图表的X轴坐标按什么来分类,如时分秒

            //图表的X轴坐标间隔如2,3,20等,单位为xAxis.IntervalType设置的时分秒。
            xaxis.Interval = 1;
            //设置X轴的时间显示格式为7-10 11:20
            xaxis.IntervalType = IntervalTypes.Auto;
            AxisLabels xal = new AxisLabels();
            xaxis.AxisLabels = xal;
            //给图标添加Axis
            chart.AxesX.Add(xaxis);
            Axis yAxis = new Axis();
            //设置图标中Y轴的最小值永远为0
            //yAxis.AxisMinimum = 0;
            //设置图表中Y轴的后缀
            yAxis.Suffix = "吨";
            chart.AxesY.Add(yAxis);
            #endregion

            #region 两条数据线操作
            // 创建产能数据线。
            DataSeries dataSeries = new DataSeries();
            // 设置数据线的格式。
            dataSeries.LegendText = "基准方案排放量(吨)";
            dataSeries.Color      = new SolidColorBrush(Color.FromRgb(255, 153, 0));
            dataSeries.RenderAs   = RenderAs.Column;//柱状图
            dataSeries.XValueType = ChartValueTypes.Auto;
            dataSeries.Width      = 20;
            chart.Series.Add(dataSeries);
            // 创建用能数据线。
            DataSeries dataSeries2 = new DataSeries();
            // 设置数据线的格式。
            dataSeries2.LegendText = "优化方案放量(吨)";
            dataSeries2.Color      = new SolidColorBrush(Color.FromRgb(51, 204, 102));
            dataSeries2.RenderAs   = RenderAs.Column;//柱状图
            dataSeries2.XValueType = ChartValueTypes.Auto;
            chart.Series.Add(dataSeries2);
            #endregion
            for (int i = 0; i < 4; i++)
            {
                //wp.DoEvents();
                // 创建一个数据点的实例。
                DataPoint dataPoint = new DataPoint();
                // 设置X轴点
                dataPoint.XValue = i;
                //设置Y轴点
                dataPoint.MarkerSize = 2;
                //dataPoint.Tag = tableName.Split('(')[0];
                //设置数据点颜色
                dataPoint.Color = new SolidColorBrush(Color.FromRgb(255, 153, 0));
                //添加数据点
                //wp.DoEvents();
                // 创建一个数据点的实例。
                DataPoint dataPoint1 = new DataPoint();
                // 设置X轴点
                dataPoint1.XValue = i;
                //设置Y轴点
                dataPoint1.MarkerSize = 2;
                //dataPoint.Tag = tableName.Split('(')[0];
                //设置数据点颜色
                dataPoint1.Color = new SolidColorBrush(Color.FromRgb(51, 204, 102));
                //添加数据点
                if (i == 0)
                {
                    dataPoint.AxisXLabel  = "二氧化碳";
                    dataPoint1.AxisXLabel = "二氧化碳";
                    Benchmark             = dataPoint.YValue = Convert.ToDouble(Canuse * coals.Rhl);
                    Optimization          = dataPoint1.YValue = Convert.ToDouble(Coal * coals.Rhl + NaturalGas * naturalgases.Rhl);
                    txtBenchmark1.Text    = dataPoint.YValue.ToString();
                    txtOptimization1.Text = dataPoint1.YValue.ToString();
                    txtEmission1.Text     = ((dataPoint.YValue - dataPoint1.YValue) / dataPoint.YValue * 100).ToString();
                    txrEmission.Text      = Math.Round(Convert.ToDouble(txtBenchmark1.Text) - Convert.ToDouble(txtOptimization1.Text), 2).ToString();
                }
                else if (i == 1)
                {
                    dataPoint.AxisXLabel  = "碳粉尘";
                    dataPoint1.AxisXLabel = "碳粉尘";
                    dataPoint.YValue      = Convert.ToDouble(Canuse) * dust;
                    dataPoint1.YValue     = Convert.ToDouble(Coal) * dust;
                    txtBenchmark2.Text    = dataPoint.YValue.ToString();
                    txtOptimization2.Text = dataPoint1.YValue.ToString();
                    txtEmission2.Text     = ((dataPoint.YValue - dataPoint1.YValue) / dataPoint.YValue * 100).ToString();
                }
                else if (i == 2)
                {
                    dataPoint.AxisXLabel  = "二氧化硫";
                    dataPoint1.AxisXLabel = "二氧化硫";
                    dataPoint.YValue      = Convert.ToDouble(Canuse) * SO2;
                    dataPoint1.YValue     = Convert.ToDouble(Coal) * SO2;
                    txtBenchmark3.Text    = dataPoint.YValue.ToString();
                    txtOptimization3.Text = dataPoint1.YValue.ToString();
                    txtEmission3.Text     = ((dataPoint.YValue - dataPoint1.YValue) / dataPoint.YValue * 100).ToString();
                }
                else if (i == 3)
                {
                    dataPoint.AxisXLabel  = "氮氧化物";
                    dataPoint1.AxisXLabel = "氮氧化物";
                    dataPoint.YValue      = Convert.ToDouble(Canuse) * NOX;
                    dataPoint1.YValue     = Convert.ToDouble(Coal) * NOX;
                    txtBenchmark4.Text    = dataPoint.YValue.ToString();
                    txtOptimization4.Text = dataPoint1.YValue.ToString();
                    txtEmission4.Text     = ((dataPoint.YValue - dataPoint1.YValue) / dataPoint.YValue * 100).ToString();
                }

                dataSeries.DataPoints.Add(dataPoint);
                dataSeries2.DataPoints.Add(dataPoint1);
            }
            wp.Close();
            GridTable.Visibility  = Visibility.Visible;
            GridIcon.Visibility   = Visibility.Visible;
            GridIncome.Visibility = Visibility.Visible;
        }
Пример #15
0
        /// <summary>
        /// 绑定数到柱状图
        /// </summary>
        /// <param name="dtChart"></param>
        void InputDataTableToChart(DataTable dtChart)
        {
            try
            {
                SystemHelper.logger.LogDebug("HRVTodayControl_ZZGA ==============InputDataTableToChart.start============= ");
                //判空
                if ((dtChart == null) || (dtChart.Rows.Count == 0))
                {
                    SystemHelper.logger.LogDebug("InputDataTableToChart  dtChart 数据为空");
                    return;
                }
                this.chart.Series.Clear();

                DataSeries dataSeries = new DataSeries();
                dataSeries.RenderAs = RenderAs.Bar;

                DataPoint datapoint = null;
                for (int i = 0; i < dtChart.Rows.Count; i++)
                {
                    string name  = "";
                    int    value = 0;

                    if (i < dtChart.Rows.Count)
                    {
                        if (dtChart.Rows[i][0] != DBNull.Value)
                        {
                            name = dtChart.Rows[i][0].ToString();
                        }
                        else
                        {
                            SystemHelper.logger.LogDebug("InputDataTableToChart  name[" + i.ToString() + "][0]数据为空");
                        }

                        try
                        {
                            if (dtChart.Rows[i][1] != DBNull.Value)
                            {
                                value = Convert.ToInt32(dtChart.Rows[i][1]);
                            }
                            else
                            {
                                SystemHelper.logger.LogDebug("InputDataTableToChart  value[" + i.ToString() + "][1]数据为空");
                            }
                        }
                        catch (Exception)
                        {
                            value = 0;
                        }
                    }
                    datapoint            = new DataPoint();
                    datapoint.AxisXLabel = name;
                    datapoint.YValue     = Convert.ToDouble(value);
                    datapoint.Tag        = value;

                    // double value = Convert.ToDouble(dtChart.Rows[i][1].ToString());
                    LinearGradientBrush pointbrush = new LinearGradientBrush();
                    string[]            colorArr   = { "#a7e4ff", "#007ee6", "#FAFAD2", "#FFFF00", "#FFE4C4", "#FF8C00" };
                    int stage = getStage(value) - 1;
                    pointbrush.GradientStops.Add(new GradientStop(color: (Color)ColorConverter.ConvertFromString(colorArr[stage * 2]), offset: 0));
                    pointbrush.GradientStops.Add(new GradientStop(color: (Color)ColorConverter.ConvertFromString(colorArr[stage * 2 + 1]), offset: 1));

                    datapoint.Color = pointbrush;
                    dataSeries.DataPoints.Add(datapoint);
                }

                #region 设置char
                chart.LightingEnabled       = false;
                chart.SmartLabelEnabled     = true;
                dataSeries.LabelAngle       = 0;//字体角度
                this.chart.AnimationEnabled = true;
                this.chart.ThemeEnabled     = true;
                this.chart.Series.Add(dataSeries);
                this.chart.FontSize      = 18;
                this.chart.ShadowEnabled = false;
                #endregion

                #region 设置x轴
                AxisLabels xLabel = new AxisLabels();
                xLabel.FontColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#99cccc")); //x轴刻度文本信息颜色
                ChartGrid xGrid = new ChartGrid();                                                          //设置x轴的纵向刻度虚线
                xGrid.Enabled = false;
                Axis xAxis = new Axis();
                xAxis.Enabled             = true; //是否显示X轴刻度、文本
                xAxis.AxisLabels          = xLabel;
                xAxis.AxisLabels.FontSize = 18;   //字体大小
                xAxis.FontFamily          = new System.Windows.Media.FontFamily("宋体");
                xAxis.Grids.Add(xGrid);
                chart.AxesX.Add(xAxis);
                #endregion

                #region 设置y轴
                AxisLabels yLabel = new AxisLabels();
                yLabel.FontColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#99cccc")); //y轴刻度文本信息颜色
                ChartGrid yGrid = new ChartGrid();                                                          // 设置y轴的横向刻度虚线
                yGrid.Enabled = true;
                Axis yAxis = new Axis();
                yAxis.Enabled = true;         //是否显示Y轴刻度、文本
                yAxis.Grids.Add(yGrid);
                yAxis.AxisMinimum       = 0;  //y轴刻度最小值
                dataSeries.LabelEnabled = true;
                yAxis.Interval          = 10; //设置y轴刻度的增量 -- 即2个刻度值之间的的间隔
                yAxis.IntervalType      = IntervalTypes.Number;
                yAxis.LineColor         = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#003333"));
                xAxis.FontFamily        = new System.Windows.Media.FontFamily("微软雅黑");
                yAxis.AxisLabels        = yLabel;
                chart.AxesY.Add(yAxis);
                #endregion

                SystemHelper.logger.LogDebug("HRVTodayControl_ZZGA ==============InputDataTableToChart.end============= ");
            }
            catch (Exception ex)
            {
                SystemHelper.logger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName,
                                             System.Reflection.MethodBase.GetCurrentMethod().Name, ex.Message.ToString(), ex.ToString());
            }
        }
Пример #16
0
        /// <summary>
        /// Create AxisY elements for circular chart
        /// </summary>
        /// <param name="height"></param>
        /// <param name="point"></param>
        /// <param name="minAngle"></param>
        /// <param name="index"></param>
        /// <param name="center"></param>
        /// <param name="isAxisLabelsEnabled"></param>
        private void CreateAxisYElements4RadarChart(Double height, Point point, Double minAngle, Double index, Point center, Boolean isAxisLabelsEnabled)
        {
            AxisElementsContainer = new StackPanel()
            {
                Background = InternalBackground
            };
            AxisElementsContainer.Orientation = Orientation.Horizontal;

            ApplyAxisProperties4CircularChart();

            CreateAxisLine(0, height, (Double)LineThickness / 2, (Double)LineThickness / 2, (Double)LineThickness, height);

            RotateTransform transform = null;

            if (isAxisLabelsEnabled)
            {
                AxisLabels.CreateVisualObject();

                if (AxisLabels.Visual != null)
                {
                    AxisElementsContainer.Children.Add(AxisLabels.Visual);
                }
            }
            else
            {
                transform       = new RotateTransform();
                transform.Angle = minAngle * index;
            }

            Double ticksWidth = 0;

            List <Ticks> ticks = Ticks.Reverse().ToList();

            foreach (Ticks tick in ticks)
            {
                tick.SetParms(PlacementTypes.Left, Double.NaN, height);

                tick.CreateVisualObject();

                if (tick.Visual != null)
                {
                    AxisElementsContainer.Children.Add(tick.Visual);
                    ticksWidth += tick.Visual.Width;
                }
            }

            if (AxisLine != null)
            {
                AxisElementsContainer.Children.Add(AxisLine);
            }

            Double axisLabelsWidth = 0;

            if (isAxisLabelsEnabled)
            {
                if (AxisLabels.Visual != null)
                {
                    if (!Double.IsNaN(AxisLabels.Visual.Width))
                    {
                        axisLabelsWidth = AxisLabels.Visual.Width;
                    }
                }
            }

            AxisElementsContainer.SetValue(Canvas.LeftProperty, point.X - axisLabelsWidth - ticksWidth);
            AxisElementsContainer.SetValue(Canvas.TopProperty, point.Y);

            if (!isAxisLabelsEnabled)
            {
                if (transform != null)
                {
                    AxisElementsContainer.RenderTransformOrigin = new Point(0.75, 0);
                    AxisElementsContainer.RenderTransform       = transform;
                }
            }

            CircularAxisVisual.Children.Add(AxisElementsContainer);
        }
Пример #17
0
        private void CreateAxisYElements4PolarChart(Double height, Double minAngleInDegree, Point point, Double angle, Double index, Point center)
        {
            AxisElementsContainer = new StackPanel()
            {
                Background = InternalBackground
            };
            AxisElementsContainer.Orientation = Orientation.Horizontal;

            ApplyAxisProperties4CircularChart();

            CreateAxisLine(0, height, (Double)LineThickness / 2, (Double)LineThickness / 2, (Double)LineThickness, height);

            RotateTransform transform             = new RotateTransform();
            Double          rotationAngleIndegree = Visifire.Commons.CircularLabel.ResetMeanAngle(CalculateAngleByCoordinate(point, center)) * 180 / Math.PI;

            transform.Angle = rotationAngleIndegree + 90;

            Double axisLabelsWidth = 0;

            if (Math.Round(minAngleInDegree) == Math.Round(rotationAngleIndegree))
            {
                AxisLabels.CreateVisualObject();

                if (AxisLabels.Visual != null)
                {
                    AxisElementsContainer.Children.Add(AxisLabels.Visual);

                    if (!Double.IsNaN(AxisLabels.Visual.Width))
                    {
                        axisLabelsWidth = AxisLabels.Visual.Width;
                    }
                }
            }

            Double ticksWidth = 0;

            List <Ticks> ticks = Ticks.Reverse().ToList();

            foreach (Ticks tick in ticks)
            {
                tick.SetParms(PlacementTypes.Left, Double.NaN, height);

                tick.CreateVisualObject();

                if (tick.Visual != null)
                {
                    AxisElementsContainer.Children.Add(tick.Visual);
                    ticksWidth += tick.Visual.Width;
                }
            }

            if (AxisLine != null)
            {
                AxisElementsContainer.Children.Add(AxisLine);
            }

            AxisElementsContainer.SetValue(Canvas.LeftProperty, point.X - axisLabelsWidth - ticksWidth);
            AxisElementsContainer.SetValue(Canvas.TopProperty, point.Y);

            if (transform != null)
            {
                AxisElementsContainer.RenderTransformOrigin = new Point(1, 0);
                AxisElementsContainer.RenderTransform       = transform;
            }

            CircularAxisVisual.Children.Add(AxisElementsContainer);
        }
Пример #18
0
        /// <summary>
        /// Applies axis settings for circular type axis
        /// </summary>
        private void ApplyAxisSettings4CircularChart()
        {
            if (AxisOrientation == AxisOrientation.Circular)
            {
                CircularPath = new Path();

                // Set the parameters for the axis labels
                AxisLabels.Placement = PlacementTypes.Circular;
                AxisLabels.Width     = Width;
                AxisLabels.Height    = Height;

                // Generate the visual object for the required elements
                AxisLabels.CreateVisualObject();

                if (AxisLabels.Visual != null)
                {
                    CircularAxisVisual.Children.Add(AxisLabels.Visual);
                }

                ApplyCircularPathProperties();

                if (CircularPlotDetails.ListOfPoints4CircularAxis.Count > 0)
                {
                    CircularPath.Data = GetPathGeometry(CircularPlotDetails.ListOfPoints4CircularAxis);
                }

                CircularAxisVisual.Children.Add(CircularPath);
            }
            else
            {
                if (CircularPlotDetails.ListOfPoints4CircularAxis.Count == 0)
                {
                    return;
                }

                Double height = Math.Max(CircularPlotDetails.Radius, 0);

                // Set the parameters for the axis labels
                AxisLabels.Placement = PlacementTypes.Left;
                AxisLabels.Height    = height;

                for (Int32 i = 0; i < CircularPlotDetails.ListOfPoints4CircularAxis.Count; i++)
                {
                    if (CircularPlotDetails.CircularChartType == RenderAs.Radar)
                    {
                        if (i == 0)
                        {
                            CreateAxisYElements4RadarChart(height, CircularPlotDetails.ListOfPoints4CircularAxis[i], CircularPlotDetails.MinAngleInDegree, i, CircularPlotDetails.Center, true);
                        }
                        else
                        {
                            CreateAxisYElements4RadarChart(height, CircularPlotDetails.ListOfPoints4CircularAxis[i], CircularPlotDetails.MinAngleInDegree, i, CircularPlotDetails.Center, false);
                        }
                    }
                    else
                    {
                        Double newMinAngle = 0;
                        if (CircularPlotDetails.MinAngleInDegree > 360)
                        {
                            Double tempMinAngle = 0;
                            Int32  indexCount   = Convert.ToInt32(Math.Floor(CircularPlotDetails.MinAngleInDegree / 360));
                            for (Int32 index = 1; index <= indexCount; index++)
                            {
                                tempMinAngle = Math.Max(tempMinAngle, index * 360);
                            }

                            newMinAngle = CircularPlotDetails.MinAngleInDegree - tempMinAngle;
                        }
                        else
                        {
                            newMinAngle = CircularPlotDetails.MinAngleInDegree;
                        }

                        CreateAxisYElements4PolarChart(height, newMinAngle, CircularPlotDetails.ListOfPoints4CircularAxis[i], CircularPlotDetails.AnglesInRadian[i], i, CircularPlotDetails.Center);
                    }
                }

                CleanUpGrids();

                foreach (ChartGrid grid in Grids)
                {
                    grid.IsNotificationEnable = false;
                    grid.Chart = Chart;

                    grid.ApplyStyleFromTheme(Chart, "Grid");

                    if (grid.Visual == null)
                    {
                        grid.CreateVisualObject(Width, height, (Chart as Chart)._internalAnimationEnabled, ChartArea.GRID_ANIMATION_DURATION);

                        if (grid.Visual != null)
                        {
                            CircularAxisVisual.Children.Add(grid.Visual);
                        }
                    }
                    else
                    {
                        grid.CreateVisualObject(Width, height, (Chart as Chart)._internalAnimationEnabled, ChartArea.GRID_ANIMATION_DURATION);
                    }

                    if (grid.Visual != null)
                    {
                        grid.Visual.SetValue(Canvas.ZIndexProperty, (Int32)(-1000));
                    }

                    grid.IsNotificationEnable = true;
                }
            }
        }
Пример #19
0
        private void WekaAnalysis(List <string> permissionList, string modelname)
        {
            List <string> wekaret  = new List <string>();
            string        tmparff  = System.AppDomain.CurrentDomain.BaseDirectory + "tmp.arff";
            string        J48model = algorithmpath + modelname + ".model";

            try
            {
                WekaSharp WS = new WekaSharp();
                WS.GenerateARFF(permissionList, tmparff);
                wekaret = WS.Classify(J48model, tmparff);
                if (wekaret.Count == 0)
                {
                    return;
                }
                //转成ClassifyResult型
                List <ClassifyResult> result = new List <ClassifyResult>();
                foreach (string wekadata in wekaret)
                {
                    string[]       strs      = wekadata.Split(',');
                    string         classname = strs[0];
                    double         value     = double.Parse(strs[1]);
                    ClassifyResult cr        = new ClassifyResult(classname, value);
                    result.Add(cr);
                }
                result.Sort(new ClassifyResultComparer());

                //Draw
                //////////////////////////////////////
                Chart chart = new Chart();
                chart.View3D = true;
                //chart.ColorSet = "Picasso";
                Title title = new Title();
                title.Text = "Classify: " + modelname;
                chart.Titles.Add(title);
                //X坐标
                Axis       xaxis = new Axis();
                AxisLabels xal   = new AxisLabels
                {
                    Enabled = true,
                    Angle   = 0
                };
                xaxis.AxisLabels = xal;
                // Y坐标
                Axis       yaxis = new Axis();
                AxisLabels yal   = new AxisLabels
                {
                    Enabled = true,
                    Angle   = 0
                };
                yaxis.AxisLabels = yal;
                yaxis.Suffix     = "%";

                chart.AxesX.Add(xaxis);
                chart.AxesY.Add(yaxis);

                DataSeries dataSeries = new DataSeries();
                dataSeries.RenderAs = RenderAs.Pie;

                foreach (ClassifyResult cr in result)
                {
                    if (cr.value > 0)
                    {
                        DataPoint dataPoint = new DataPoint {
                            AxisXLabel = cr.name, YValue = cr.value * 100
                        };
                        dataSeries.DataPoints.Add(dataPoint);
                    }
                }
                chart.Series.Add(dataSeries);
                Grid grid = new Grid();
                grid.Height = 250;
                grid.Children.Add(chart);
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new DelegateAddPanel(delegatedAddPanel), panel1, grid);
                //panel1.Children.Add(grid);
            }
            catch
            {
            }
        }
Пример #20
0
        private void PermissionAnalysis(List <string> permissionList)
        {
            try
            {
                List <Threat> threatList = new List <Threat>();
                foreach (string permission in permissionList)
                {
                    int    threatvalue = GetThreatValue(permission);
                    Threat threat      = new Threat(permission.Replace("android.permission.", ""), threatvalue);
                    threatList.Add(threat);
                }
                threatList.Sort(new ThreatResultComparer());
                //Draw
                //////////////////////////////////////
                Chart chart = new Chart();
                chart.View3D = true;
                Title title = new Title();
                title.Text = "Permission Threats";
                chart.Titles.Add(title);
                chart.ColorSet = "VisiRed";
                //X坐标
                Axis       xaxis = new Axis();
                AxisLabels xal   = new AxisLabels
                {
                    Enabled = true,
                    Angle   = 0
                };
                xaxis.AxisLabels = xal;
                // Y坐标
                Axis       yaxis = new Axis();
                AxisLabels yal   = new AxisLabels
                {
                    Enabled = true,
                    Angle   = 0
                };
                yaxis.AxisLabels = yal;
                yaxis.Suffix     = "/10";

                chart.AxesX.Add(xaxis);
                chart.AxesY.Add(yaxis);

                DataSeries dataSeries = new DataSeries();
                dataSeries.RenderAs = RenderAs.Bar;

                foreach (Threat threat in threatList)
                {
                    DataPoint dataPoint = new DataPoint {
                        AxisXLabel = threat.name, YValue = threat.value
                    };
                    dataSeries.DataPoints.Add(dataPoint);
                    //dataSeries.ShowInLegend = true;
                }
                chart.Series.Add(dataSeries);
                Grid grid = new Grid();
                grid.Height = 250;
                grid.Children.Add(chart);
                panel1.Children.Add(grid);
            }
            catch
            {
            }
        }
Пример #21
0
        /// <summary>
        /// 绑定柱状图数据
        /// </summary>
        /// <param name="dtChart"></param>
        /// <param name="ChartType"></param>
        public void InputTableToChart(DataTable dtChart, int ChartType)
        {
            try
            {
                SystemHelper.logger.LogDebug("HRVChartInfo ==============InputTableToChart.start============= ");
                //判空
                if ((dtChart == null) || (dtChart.Rows.Count == 0))
                {
                    SystemHelper.logger.LogDebug("InputDataTableToChart  dtChart 数据为空");
                    return;
                }
                //绑定Chart前先清空
                chart.Series.Clear();
                chart.Titles.Clear();

                chart.AnimationEnabled = true;
                chart.ThemeEnabled     = true;
                chart.DataPointWidth   = 5; //柱体宽度

                #region 设置柱状图的柱体颜色
                ColorSet cs = new ColorSet();
                cs.Id = "colorset1";
                LinearGradientBrush brush = new LinearGradientBrush();
                brush.GradientStops.Add(new GradientStop(color: (Color)ColorConverter.ConvertFromString("#a7e4ff"), offset: 0));//使用渐变色作为主体颜色
                brush.GradientStops.Add(new GradientStop(color: (Color)ColorConverter.ConvertFromString("#007ee6"), offset: 1));
                cs.Brushes.Add(brush);
                chart.ColorSets.Add(cs);
                chart.ColorSet = "colorset1";
                #endregion

                chart.LightingEnabled = false;
                chart.ShadowEnabled   = false;
                chart.View3D          = false; //使Chart显示三维

                DataSeries dataSeries = new DataSeries();
                DataPoint  datapoint  = null;
                dataSeries.LabelFontStyle = FontStyles.Normal;
                dataSeries.RenderAs       = RenderAs.Column;
                dataSeries.LabelStyle     = LabelStyles.OutSide;
                dataSeries.LabelEnabled   = true;

                #region 设置x轴信息
                AxisLabels xLabel = new AxisLabels();
                xLabel.FontColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#c5e9ff")); //x轴刻度文本信息颜色

                ChartGrid xGrid = new ChartGrid();                                                          //设置x轴的纵向刻度虚线
                xGrid.Enabled = false;

                Axis xAxis = new Axis();
                xAxis.Enabled             = true; //是否显示X轴刻度、文本
                xAxis.AxisLabels          = xLabel;
                xAxis.AxisLabels.FontSize = 7;
                xAxis.FontFamily          = new System.Windows.Media.FontFamily("宋体");
                xAxis.Grids.Add(xGrid);
                chart.AxesX.Add(xAxis);
                #endregion

                #region 设置y轴信息
                AxisLabels yLabel = new AxisLabels();
                yLabel.FontColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#c5e9ff")); //y轴刻度文本信息颜色

                ChartGrid yGrid = new ChartGrid();                                                          // 设置y轴的横向刻度虚线
                yGrid.Enabled = true;

                Axis yAxis = new Axis();
                yAxis.Enabled = true;       //是否显示Y轴刻度、文本
                yAxis.Grids.Add(yGrid);
                yAxis.AxisMinimum = 0;      //y轴刻度最小值
                //yAxis.AxisMaximum = 100;  //y轴刻度最大值
                //yAxis.Interval = 20;      //设置y轴刻度的增量 -- 即2个刻度值之间的的间隔
                yAxis.IntervalType = IntervalTypes.Number;
                yAxis.AxisLabels   = yLabel;
                chart.AxesY.Add(yAxis);
                #endregion

                //各项警力数量
                int policeNum    = 0;
                int carNum       = 0;
                int onlineCar    = 0;
                int onLinePolice = 0;

                for (int i = 0; i < dtChart.Rows.Count; i++)
                {
                    if (dtChart.Rows[i][1] != DBNull.Value)
                    {
                        policeNum += Convert.ToInt32(dtChart.Rows[i][1]);
                    }
                    else
                    {
                        SystemHelper.logger.LogDebug("InputDataTableToChart  value[" + i.ToString() + "][1]数据为空");
                    }
                    if (dtChart.Rows[i][2] != DBNull.Value)
                    {
                        carNum += Convert.ToInt32(dtChart.Rows[i][2]);
                    }
                    else
                    {
                        SystemHelper.logger.LogDebug("InputDataTableToChart  value[" + i.ToString() + "][2]数据为空");
                    }
                    if (dtChart.Rows[i][3] != DBNull.Value)
                    {
                        onlineCar += Convert.ToInt32(dtChart.Rows[i][3]);
                    }
                    else
                    {
                        SystemHelper.logger.LogDebug("InputDataTableToChart  value[" + i.ToString() + "][3]数据为空");
                    }
                    if (dtChart.Rows[i][4] != DBNull.Value)
                    {
                        onLinePolice += Convert.ToInt32(dtChart.Rows[i][4]);
                    }
                    else
                    {
                        SystemHelper.logger.LogDebug("InputDataTableToChart  value[" + i.ToString() + "][4]数据为空");
                    }
                    datapoint            = new DataPoint();
                    datapoint.AxisXLabel = dtChart.Rows[i][0].ToString();
                    double value;
                    string tag;
                    int    val1 = 0;
                    int    val2 = 0;
                    int    val3 = 0;
                    int    val4 = 0;
                    if (dtChart.Rows[i][1] != DBNull.Value)
                    {
                        val1 = Convert.ToInt32(dtChart.Rows[i][1]);
                    }
                    else
                    {
                        SystemHelper.logger.LogDebug("InputDataTableToChart  value[" + i.ToString() + "][1]数据为空");
                    }
                    if (dtChart.Rows[i][2] != DBNull.Value)
                    {
                        val2 = Convert.ToInt32(dtChart.Rows[i][2]);
                    }
                    else
                    {
                        SystemHelper.logger.LogDebug("InputDataTableToChart  value[" + i.ToString() + "][2]数据为空");
                    }
                    if (dtChart.Rows[i][3] != DBNull.Value)
                    {
                        val3 = Convert.ToInt32(dtChart.Rows[i][3]);
                    }
                    else
                    {
                        SystemHelper.logger.LogDebug("InputDataTableToChart  value[" + i.ToString() + "][3]数据为空");
                    }
                    if (dtChart.Rows[i][4] != DBNull.Value)
                    {
                        val4 = Convert.ToInt32(dtChart.Rows[i][4]);
                    }
                    else
                    {
                        SystemHelper.logger.LogDebug("InputDataTableToChart  value[" + i.ToString() + "][4]数据为空");
                    }
                    switch (ChartType)
                    {
                    case 2:
                        value = Convert.ToDouble(val2);
                        tag   = val2.ToString();
                        break;

                    case 3:
                        value = Convert.ToDouble(val3);
                        tag   = val3.ToString();
                        break;

                    case 4:
                        value = Convert.ToDouble(val4);
                        tag   = val4.ToString();
                        break;

                    default:
                        value = Convert.ToDouble(val1);
                        tag   = val1.ToString();
                        break;
                    }
                    datapoint.YValue = value;
                    datapoint.Tag    = tag;

                    dataSeries.DataPoints.Add(datapoint);
                }
                Run runPolice       = (grid_PoliceNum.FindName("PoliceNum") as Run);
                Run runCar          = (grid_PoliceNum.FindName("CarNum") as Run);
                Run runOnlinePolice = (grid_PoliceNum.FindName("OnlinePoliceNum") as Run);
                Run runOnlineCar    = (grid_PoliceNum.FindName("OnlineCarNum") as Run);

                runPolice.Text       = policeNum.ToString();
                runCar.Text          = carNum.ToString();
                runOnlinePolice.Text = onLinePolice.ToString();
                runOnlineCar.Text    = onlineCar.ToString();

                chart.Series.Add(dataSeries);

                Title title = new Title();
                title.Text      = "各区县警力配置详情";
                title.FontSize  = 15;
                title.FontColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#81d5ff"));
                chart.Titles.Add(title);
                SystemHelper.logger.LogDebug("HRVChartInfo ==============InputTableToChart.end============= ");
            }
            catch (Exception ex)
            {
                SystemHelper.logger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name,
                                             ex.Message.ToString(), ex.ToString());
                SystemHelper.logger.LogDebug("加载柱状图出错--- 柱状图数据长度:" + dtChart.Rows.Count.ToString() + ",错误信息:" + ex.Message);
            }
        }
Пример #22
0
        /// <summary>Creates the plot elements.</summary>
        /// <remarks>Changes to the bounding box and other parameters will not take effect until this method is called.</remarks>
        public void CreateElements()
        {
            Children.Clear();
            Children.Add(new DefaultLights());

            string[] labels = AxisLabels.Split(',');
            if (labels.Length < 3)
            {
                labels = new string[] { "X", "Y", "Z" }
            }
            ;

            double bbSize        = Math.Max(Math.Max(BoundingBox.SizeX, BoundingBox.SizeY), BoundingBox.SizeZ);
            double lineThickness = bbSize / 1000;
            double arrowOffset   = lineThickness * 30;

            labelOffset        = lineThickness * 50;
            minDistanceSquared = MinDistance * MinDistance;

            if (Elements.HasFlag(EElements.Grid))
            {
                var grid = new GridLinesVisual3D();
                grid.Center        = new Point3D(BoundingBox.X + 0.5 * BoundingBox.SizeX, BoundingBox.Y + 0.5 * BoundingBox.SizeY, BoundingBox.Z);
                grid.Length        = BoundingBox.SizeX;
                grid.Width         = BoundingBox.SizeY;
                grid.MinorDistance = TickSize;
                grid.MajorDistance = bbSize;
                grid.Thickness     = lineThickness;
                grid.Fill          = AxisBrush;
                Children.Add(grid);
            }

            if (Elements.HasFlag(EElements.Axes))
            {
                var arrow = new ArrowVisual3D();
                arrow.Point2   = new Point3D((BoundingBox.X + BoundingBox.SizeX) + arrowOffset, 0.0, 0.0);
                arrow.Diameter = lineThickness * 5;
                arrow.Fill     = AxisBrush;
                Children.Add(arrow);

                var label = new BillboardTextVisual3D();
                label.Text       = labels[0];
                label.FontWeight = FontWeights.Bold;
                label.Foreground = AxisBrush;
                label.Position   = new Point3D((BoundingBox.X + BoundingBox.SizeX) + labelOffset, 0.0, 0.0);
                Children.Add(label);

                arrow          = new ArrowVisual3D();
                arrow.Point2   = new Point3D(0.0, (BoundingBox.Y + BoundingBox.SizeY) + arrowOffset, 0.0);
                arrow.Diameter = lineThickness * 5;
                arrow.Fill     = AxisBrush;
                Children.Add(arrow);

                label            = new BillboardTextVisual3D();
                label.Text       = labels[1];
                label.FontWeight = FontWeights.Bold;
                label.Foreground = AxisBrush;
                label.Position   = new Point3D(0.0, (BoundingBox.Y + BoundingBox.SizeY) + labelOffset, 0.0);
                Children.Add(label);

                if (BoundingBox.SizeZ > 0)
                {
                    arrow          = new ArrowVisual3D();
                    arrow.Point2   = new Point3D(0.0, 0.0, (BoundingBox.Z + BoundingBox.SizeZ) + arrowOffset);
                    arrow.Diameter = lineThickness * 5;
                    arrow.Fill     = AxisBrush;
                    Children.Add(arrow);

                    label            = new BillboardTextVisual3D();
                    label.Text       = labels[2];
                    label.FontWeight = FontWeights.Bold;
                    label.Foreground = AxisBrush;
                    label.Position   = new Point3D(0.0, 0.0, (BoundingBox.Z + BoundingBox.SizeZ) + labelOffset);
                    Children.Add(label);
                }
            }

            if (Elements.HasFlag(EElements.BoundingBox) && BoundingBox.SizeZ > 0)
            {
                var box = new BoundingBoxWireFrameVisual3D();
                box.BoundingBox = BoundingBox;
                box.Thickness   = 1;
                box.Color       = AxisBrush.Color;
                Children.Add(box);
            }

            if (Elements.HasFlag(EElements.Marker))
            {
                marker            = new TruncatedConeVisual3D();
                marker.Height     = labelOffset;
                marker.BaseRadius = 0.0;
                marker.TopRadius  = labelOffset / 5;
                marker.TopCap     = true;
                marker.Origin     = new Point3D(0.0, 0.0, 0.0);
                marker.Normal     = new Vector3D(-1.0, -1.0, 1.0);
                marker.Fill       = MarkerBrush;
                Children.Add(marker);

                coords            = new BillboardTextVisual3D();
                coordinateFormat  = string.Format("{{0:F6}}, {{1:F6}}, {{2:F6}}", DecimalPlaces, DecimalPlaces, DecimalPlaces); // "{0:F2}, {1:F2}, {2:F2}"
                coords.Text       = string.Format(coordinateFormat, 0.0, 0.0, 0.0);
                coords.Foreground = MarkerBrush;
                coords.Position   = new Point3D(-labelOffset, -labelOffset, labelOffset);
                Children.Add(coords);
            }
            else
            {
                marker = null;
                coords = null;
            }

            if (trace != null)
            {
                foreach (LinesVisual3D p in trace)
                {
                    Children.Add(p);
                }
                path = trace[trace.Count - 1];
            }
        }
Пример #23
0
        void TimeSeriesView_Loaded(object sender, RoutedEventArgs e)
        {
            TagGroup a = (TagGroup)this.DataContext;
            Chart    TimeSeriesSample = new Chart();

            TimeSeriesSample.Titles.Add(new Title()
            {
                Text = a.Key
            });
            TimeSeriesSample.Height = 400;
            TimeSeriesSample.Width  = 900;
            TimeSeriesSample.Style  = (Style)FindResource("TimeSeriesStyle");



            TimeSeriesSample.AxesX.Add(new Axis()
            {
                IntervalType      = IntervalTypes.Minutes, Interval = 30,
                ValueFormatString = "MM/dd/yyyy hh:mm"
            });

            AxisLabels xaxislabel = new AxisLabels();

            xaxislabel.Angle = -90;
            TimeSeriesSample.AxesX[0].AxisLabels = xaxislabel;
            TimeSeriesSample.AxesY.Add(new Axis()
            {
                AxisMinimum = 0
            });


            TimeSeriesSample.ScrollingEnabled = true;
            TimeSeriesSample.ZoomingEnabled   = false;

            foreach (Tag tg in a)
            {
                DataSeries ds = new DataSeries();
                ds.SelectionEnabled = true;

                ds.MarkerScale = .5;
                ds.XValueType  = ChartValueTypes.DateTime;
                ds.LegendText  = tg.TagName;

                ds.XValueFormatString = "MM/dd/yyyy hh:mm";

                ds.RenderAs = RenderAs.QuickLine;

                if (!TimeSeriesSample.Series.Contains(ds))
                {
                    TimeSeriesSample.Series.Add(ds);
                }


                foreach (KeyValuePair <DateTime, double> kv in tg.Data)
                {
                    DataPoint dp = new DataPoint()
                    {
                        XValue = kv.Key, YValue = kv.Value
                    };
                    if (!TimeSeriesSample.Series[a.IndexOf(tg)].DataPoints.Contains(dp))
                    {
                        TimeSeriesSample.Series[a.IndexOf(tg)].DataPoints.Add(dp);
                    }
                }
            }
            LayoutRoot.Children.Add(TimeSeriesSample);
        }