Esempio n. 1
0
 private void CargarFormularioChartPorSexo()
 {
     //conexionBD.Add(dataSource);
     //conexionBD.Add(initialCatalog);
     //conexionBD.Add(user);
     //conexionBD.Add(password);
     rcView.Series.Clear();
     BarSeries barSeries = new BarSeries("Performance", "RepresentativeName");
     barSeries.Name = "Q1";
     BarSeries barSeries2 = new BarSeries("Performance", "RepresentativeName");
     barSeries2.Name = "Q2";
     BarSeries barSeries3 = new BarSeries("Performance", "RepresentativeName");
     barSeries3.Name = "Q2";
     SisOxibariterapiaDataSetTableAdapters.spr_ReporteEnfermedadesPorSexoTableAdapter da = new SisOxibariterapiaDataSetTableAdapters.spr_ReporteEnfermedadesPorSexoTableAdapter();
     SisOxibariterapiaDataSet.spr_ReporteEnfermedadesPorSexoDataTable dt = new WinUI.SisOxibariterapiaDataSet.spr_ReporteEnfermedadesPorSexoDataTable();
     da.Connection.ConnectionString = cadenaConexion;
     da.Fill(dt);
     foreach (DataRow dr in dt.Rows)
     {
         barSeries.DataPoints.Add(new CategoricalDataPoint(Convert.ToDouble(dr["Paciente"].ToString()), dr["nombre"].ToString()));
         barSeries.ShowLabels = true;
         barSeries2.DataPoints.Add(new CategoricalDataPoint(Convert.ToDouble(dr["Femenino"].ToString()), dr["nombre"].ToString()));
         barSeries3.DataPoints.Add(new CategoricalDataPoint(Convert.ToDouble(dr["Masculino"].ToString()), dr["nombre"].ToString()));
         barSeries2.ShowLabels = true;
         barSeries3.ShowLabels = true;
     }
     rcView.View.Palette = KnownPalette.Cold;
     //rcView.ShowToolTip = true;
     this.rcView.Series.Add(barSeries);
     this.rcView.Series.Add(barSeries2);
     this.rcView.Series.Add(barSeries3);
     pbLeyenda.Image = global::SisOxi.WinUI.Properties.Resources.LeyendaSexo1;
 }
Esempio n. 2
0
File: code.cs Progetto: heber/FreeOQ
	public override void OnStrategyStart()
	{
		series = new BarSeries();

		if (VolatilityExitEnabled || VolatilityBarrierEnabled)
		{
			rangeSeries = new TimeSeries();
			
			rangeSMA = new SMA(rangeSeries, VolatilitySMALength);
		}
		
		if (TickBarrierEnabled)
			barrier = TickSize * BarrierSize;
		
		lowestLowSeries   = new TimeSeries();
		highestHighSeries = new TimeSeries();		
		channelLowSeries  = new TimeSeries();
		channelHighSeries = new TimeSeries();
		
		lowestLowSeries  .Color = Color.Blue;
		highestHighSeries.Color = Color.Blue;
		channelLowSeries .Color = Color.Brown;
		channelHighSeries.Color = Color.Brown;
		
		Draw(lowestLowSeries  , 0);
		Draw(highestHighSeries, 0);
		Draw(channelLowSeries , 0);
		Draw(channelHighSeries, 0);
	}
        private RadCartesianChartView createChart()
        {
            //Create the Chart View
            RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

            //Create the bar series and attach axes and value bindings.
            BarSeries barSeries = new BarSeries();

            barSeries.ValueBinding  = new ValueBinding();
            barSeries.CategoryBinding = new CategoryBinding();

            LinearAxis verticalAxis = new LinearAxis();
            //The values in the linear axis will not have values after the decimal point.
            verticalAxis.LabelFormat = "%.0f";
            CategoricalAxis horizontalAxis = new CategoricalAxis();
            barSeries.VerticalAxis = verticalAxis;
            barSeries.HorizontalAxis = horizontalAxis;

            //Bind series to data
            barSeries.Data  = this.getData();

            //Add series to chart
            chart.Series.Add(barSeries);

            CartesianPlotBandAnnotation annotation = new CartesianPlotBandAnnotation(verticalAxis, 6, 8);
            chart.Annotations.Add(annotation);
            annotation.FillColor = Color.Argb(150, 0, 148, 255);
            annotation.StrokeColor = Color.Argb(150, 0, 74, 127);
            annotation.StrokeColor = 4;
            annotation.ZIndex = 1001;

            return chart;
        }
Esempio n. 4
0
        private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            if (Datos == null || Datos.Count() == 0)
            {
                return;
            }

            var plotModel1 = new PlotModel();
            plotModel1.Title = "Idiomas";

            var categoryAxis1 = new CategoryAxis();
            categoryAxis1.Position = AxisPosition.Left;
            plotModel1.Axes.Add(categoryAxis1);

            var linearAxis1 = new LinearAxis();
            linearAxis1.AxislineStyle = LineStyle.Solid;
            linearAxis1.Position = AxisPosition.Bottom;
            plotModel1.Axes.Add(linearAxis1);
            var barSeries1 = new BarSeries();

            foreach (var item in Datos)
            {
                categoryAxis1.ActualLabels.Add(item.Idioma);
                barSeries1.Items.Add(new BarItem(item.Certeza));
            }

            plotModel1.Series.Add(barSeries1);

            Grafica.Model = plotModel1;
        }
        void PerformanceChart_Loaded(object sender, RoutedEventArgs e)
        {
            if (radChart.DataContext != null)
            {
                Employee employee = (Employee)radChart.DataContext;

                if (radChart.Series.Count == 0)
                {
					radChart.HorizontalAxis = new DateTimeCategoricalAxis () { LabelFormat = "dd/MM" };
					radChart.VerticalAxis = new LinearAxis() { LabelFormat = "C0" };


                    IEnumerable<Order> orders = (from o in employee.Orders
                                                  orderby o.OrderDate
                                                  select o).Skip(employee.Orders.Count() - 10);

					BarSeries series = new BarSeries();

                    foreach (Order order in orders)
                    {
                        CategoricalDataPoint dataPoint = new CategoricalDataPoint();
                        dataPoint.Value = (from orderDetail in order.Details
                                                     select orderDetail.Quantity * orderDetail.UnitPrice *
                                                         (1 - orderDetail.Discount)).Sum();
						dataPoint.Category = order.OrderDate;
                        series.DataPoints.Add(dataPoint);
                    }

                    radChart.Series.Add(series);
                }
            }
        }
        public static PlotModel BarSeries()
        {
            var model = new PlotModel
                            {
                                Title = "BarSeries",
                                LegendPlacement = LegendPlacement.Outside,
                                LegendPosition = LegendPosition.BottomCenter,
                                LegendOrientation = LegendOrientation.Horizontal,
                                LegendBorderThickness = 0
                            };

            var s1 = new BarSeries { Title = "Series 1", StrokeColor = OxyColors.Black, StrokeThickness = 1 };
            s1.Items.Add(new BarItem { Value = 25 });
            s1.Items.Add(new BarItem { Value = 137 });
            s1.Items.Add(new BarItem { Value = 18 });
            s1.Items.Add(new BarItem { Value = 40 });

            var s2 = new BarSeries { Title = "Series 2", StrokeColor = OxyColors.Black, StrokeThickness = 1 };
            s2.Items.Add(new BarItem { Value = 12 });
            s2.Items.Add(new BarItem { Value = 14 });
            s2.Items.Add(new BarItem { Value = 120 });
            s2.Items.Add(new BarItem { Value = 26 });

            var categoryAxis = new CategoryAxis { Position = AxisPosition.Left };
            categoryAxis.Labels.Add("Category A");
            categoryAxis.Labels.Add("Category B");
            categoryAxis.Labels.Add("Category C");
            categoryAxis.Labels.Add("Category D");
            var valueAxis = new LinearAxis { Position = AxisPosition.Bottom, MinimumPadding = 0, MaximumPadding = 0.06, AbsoluteMinimum = 0 };
            model.Series.Add(s1);
            model.Series.Add(s2);
            model.Axes.Add(categoryAxis);
            model.Axes.Add(valueAxis);
            return model;
        }
		private RadCartesianChartView createChart() {
			//Create the Chart View
			RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

			LinearAxis verticalAxis = new LinearAxis();
			//The values in the linear axis will not have values after the decimal point.
			verticalAxis.LabelFormat = "%.0f";
			CategoricalAxis horizontalAxis = new CategoricalAxis();
			chart.VerticalAxis = verticalAxis;
			chart.HorizontalAxis = horizontalAxis;


			for (int i = 0; i < 3; i++) {
				//Create the bar series and attach axes and value bindings.
				BarSeries barSeries = new BarSeries();

				//We want to stack the different area series.
				barSeries.CombineMode = ChartSeriesCombineMode.Stack;

				barSeries.ValueBinding = new ValueBinding();
				barSeries.CategoryBinding = new CategoryBinding();

				//Bind series to data
				barSeries.Data = this.getData();

				//Add series to chart
				chart.Series.Add(barSeries);
			}

			return chart;
		}
		private RadCartesianChartView createChart(){
			RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

			CategoricalAxis horizontalAxis = new CategoricalAxis();
			chart.HorizontalAxis = horizontalAxis;

			LinearAxis vertical1 = new LinearAxis();
			vertical1.LabelFormat = "%.0f";

			LinearAxis vertical2 = new LinearAxis();
			vertical2.LabelFormat = "%.0f";

			BarSeries series1 = new BarSeries();

			ArrayList data = this.getData();

			series1.ValueBinding = new ValueBinding1();
			series1.CategoryBinding = new CategoryBinding();
			series1.VerticalAxis = vertical1;
			series1.Data = data;

			chart.Series.Add(series1);

			LineSeries series2 = new LineSeries();

			series2.ValueBinding = new ValueBinding2();
			series2.CategoryBinding = new CategoryBinding();
			series2.VerticalAxis = (vertical2);
			vertical2.HorizontalLocation = AxisHorizontalLocation.Right;
			series2.Data = data;

			chart.Series.Add(series2);

			return chart;
		}
		private RadCartesianChartView createChart(){
			//Create the Chart View
			RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

			//Create the bar series and attach axes and value bindings.
			BarSeries barSeries = new BarSeries();

			barSeries.ValueBinding  = new ValueBinding();
			barSeries.CategoryBinding = new CategoryBinding();

			LinearAxis verticalAxis = new LinearAxis();
			//The values in the linear axis will not have values after the decimal point.
			verticalAxis.LabelFormat = "%.0f";
			CategoricalAxis horizontalAxis = new CategoricalAxis();
			horizontalAxis.LabelFitMode = AxisLabelFitMode.MultiLine;

			barSeries.VerticalAxis = verticalAxis;
			barSeries.HorizontalAxis = horizontalAxis;

			//Bind series to data
			barSeries.Data = this.getData();

			//Add series to chart
			chart.Series.Add(barSeries);

			ChartSelectionBehavior sb = new ChartSelectionBehavior();
			sb.DataPointsSelectionMode = ChartSelectionMode.Single;

			chart.Behaviors.Add(sb);

			return chart;
		}
Esempio n. 10
0
        public void SetDataSumValuesList(Dictionary<string, double> data, ChartBy chartBy)
        {
            // lets clear previous chart
            this.SumValuesCollection.Clear();
            this.MainChart.Series.Clear();

            // copy columns data into our observable collection
            foreach (var column in data)
            {
                this.SumValuesCollection.Add(new DataSumValuesCollection
                    {
                        new DataSumValues
                            {
                                Header = (chartBy == ChartBy.Cols ? "Column " : "Row ") + column.Key,
                                SumValues = column.Value
                            }
                    });
            }

            foreach (var item in this.SumValuesCollection)
            {
                BarSeries columnSeries = new BarSeries { SelectionMode = SelectionMode.Series };

                BindableDataSeries bindableData = new BindableDataSeries
                {
                    Title = item[0].Header,
                    ItemsSource = item,
                    XValueBinding = new Binding("SumValues"),
                    YValueBinding = new Binding("Header"),
                };
                columnSeries.DataSeries = bindableData;

                this.MainChart.Series.Add(columnSeries);
            }
        }
		private RadCartesianChartView createChart(){
			//Create the Chart View
			RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

			//Create the bar series and attach axes and value bindings.
			BarSeries barSeries = new BarSeries();

			barSeries.ValueBinding  = new ValueBinding();
			barSeries.CategoryBinding = new CategoryBinding();

			LinearAxis verticalAxis = new LinearAxis();
			//The values in the linear axis will not have values after the decimal point.
			verticalAxis.LabelFormat = "%.0f";
			CategoricalAxis horizontalAxis = new CategoricalAxis();
			barSeries.VerticalAxis = verticalAxis;
			barSeries.HorizontalAxis = horizontalAxis;

			//Bind series to data
			barSeries.Data  = this.getData();

			//Add series to chart
			chart.Series.Add(barSeries);

			CartesianGridLineAnnotation annotation = new CartesianGridLineAnnotation(verticalAxis, 3);
			chart.Annotations.Add(annotation);
			annotation.LabelHorizontalAlignment = HorizontalAlignment.Left;
			annotation.StrokeColor = Color.Argb(255, 235, 100, 32);
			annotation.StrokeWidth = 4;
			annotation.ZIndex = 1001;
			annotation.Label = "This is Grid Line annotation";

			return chart;
		}
Esempio n. 12
0
        public BarSeries Compress(DataEntryEnumerator enumerator)
        {
            var series = new BarSeries();
            NewCompressedBar += (sender, e) => series.Add(e.Bar);
            while (enumerator.MoveNext())
                Add(enumerator.Current);

            this.method_1();
            return series;
        }
Esempio n. 13
0
 public override View GetSampleContent(Context context)
  {
      var chart = new SfChart(context);;
      chart.SetBackgroundColor(Color.White);
      chart.PrimaryAxis = new CategoryAxis();
      chart.SecondaryAxis = new NumericalAxis {Interval = 20, EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift};
      var series = new BarSeries
      {
          DataSource = MainPage.GetData1(),
      };
      series.DataMarker.ShowLabel = true;
      chart.Series.Add(series);
      return chart;
  }
Esempio n. 14
0
		public BarSeries Compress(DataEntryEnumerator enumerator)
		{
			BarSeries series = new BarSeries();
			this.NewCompressedBar += delegate(object sender, CompressedBarEventArgs args)
			{
				series.Add(args.Bar);
			};
			while (enumerator.MoveNext())
			{
				this.Add(enumerator.Current);
			}
			this.Flush();
			return series;
		}
		private void prepareChart() {
			CategoricalAxis horizontalAxis = new CategoricalAxis();
			this.chartView.HorizontalAxis = horizontalAxis;

			LinearAxis verticalAxis = new LinearAxis();
			verticalAxis.LabelFormat = "%.0f";
			this.chartView.VerticalAxis = verticalAxis;

			for (int i = 0; i < 5; i++){
				BarSeries series = new BarSeries();
				series.LegendTitle = "Series " + (i + 1);
				series.CategoryBinding = new CategoryBinding();
				series.ValueBinding = new ValueBinding();
				series.Data = this.getData();
				this.chartView.Series.Add(series);
			}
		}
        public static PlotModel TornadoDiagram1()
        {
            // http://en.wikipedia.org/wiki/Tornado_diagram
            var model = new PlotModel("Tornado diagram 1") { LegendPlacement = LegendPlacement.Outside };

            var s1 = new BarSeries
                {
                    Title = "High",
                    IsStacked = true,
                    FillColor = OxyColor.FromRgb(216, 82, 85),
                    BaseValue = 7,
                    StrokeColor = OxyColors.Black,
                    StrokeThickness = 1
                };
            s1.Items.Add(new BarItem(1));
            s1.Items.Add(new BarItem(1));
            s1.Items.Add(new BarItem(4));
            s1.Items.Add(new BarItem(5));

            var s2 = new BarSeries
                {
                    Title = "Low",
                    IsStacked = true,
                    FillColor = OxyColor.FromRgb(84, 138, 209),
                    BaseValue = 7,
                    StrokeColor = OxyColors.Black,
                    StrokeThickness = 1
                };
            s2.Items.Add(new BarItem(-1));
            s2.Items.Add(new BarItem(-3));
            s2.Items.Add(new BarItem(-2));
            s2.Items.Add(new BarItem(-3));

            var categoryAxis = new CategoryAxis { Position = AxisPosition.Left };
            categoryAxis.Labels.Add("F/X rate");
            categoryAxis.Labels.Add("Inflation");
            categoryAxis.Labels.Add("Price");
            categoryAxis.Labels.Add("Conversion");
            var valueAxis = new LinearAxis(AxisPosition.Bottom) { ExtraGridlines = new[] { 7.0 } };
            model.Series.Add(s1);
            model.Series.Add(s2);
            model.Axes.Add(categoryAxis);
            model.Axes.Add(valueAxis);
            return model;
        }
Esempio n. 17
0
        private static CategoricalSeries CreateSeries(string catBinding, string valBinding, System.Collections.IEnumerable data, string seriesType)
        {
            CategoricalSeries series;

            if (seriesType == "LineSeries")
            {
                series = new LineSeries();
            }
            else
            {
                series = new BarSeries();
            }

            series.CategoryBinding = new PropertyNameDataPointBinding(catBinding);
            series.ValueBinding = new PropertyNameDataPointBinding(valBinding);
            series.ItemsSource = data;

            return series;
        }
Esempio n. 18
0
        private void loadReligionList()
        {
            List<string> aReligion = new List<string>();           
            int iCntReligionMale = 0;
            int iCntReligionFemale = 0;

            foreach (StudentEnrollment se in stEnrolled)
            {
                if (!aReligion.Contains(se.student.Religion))
                {
                    aReligion.Add(se.student.Religion);
                }
            }

            BarSeries series = new BarSeries();
            BarSeries series2 = new BarSeries();

            foreach (String religion in aReligion)
            {
                iCntReligionMale = stEnrolled.FindAll(x => x.student.Religion == religion && x.student.Gender == "M").Count;
                series.DataPoints.Add(new CategoricalDataPoint(iCntReligionMale, religion));

                iCntReligionFemale = stEnrolled.FindAll(x => x.student.Religion == religion && x.student.Gender == "F").Count;
                series2.DataPoints.Add(new CategoricalDataPoint(iCntReligionFemale, religion));
            }

            this.radChartView1.Series.Add(series);
            this.radChartView1.Series.Add(series2);

            CategoricalAxis categoricalAxis = radChartView1.Axes[0] as CategoricalAxis;
            categoricalAxis.PlotMode = AxisPlotMode.OnTicksPadded;
            categoricalAxis.LabelFitMode = AxisLabelFitMode.Rotate;
            categoricalAxis.LabelRotationAngle = 310;

            this.radChartView1.ShowLegend = true;
            this.radChartView1.LegendTitle = "Legend";
            this.radChartView1.ChartElement.LegendPosition = LegendPosition.Right;

            this.radChartView1.ChartElement.LegendElement.Items[0].Title = "Male";
            this.radChartView1.ChartElement.LegendElement.Items[1].Title = "Female";


        }
Esempio n. 19
0
        private void btnLoadChart_Click(object sender, RoutedEventArgs e)
        {
            data1 = new ObservableCollection<ChartData>();
            Random r = new Random();
            for (int i = 0; i < 15; i++)
            {
                data1.Add(new ChartData() { Title = "Label " + i, Value = r.Next(10, 50) });
            }

            if (RadChart1.Series.Count > 0)
            {
                RadChart1.Series.Clear();
            }
            BarSeries barSeries = new BarSeries();
            RadChart1.VerticalAxis = new LinearAxis();
            RadChart1.HorizontalAxis = new CategoricalAxis();
            barSeries.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "Title" };
            barSeries.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Value" };
            barSeries.ItemsSource = data1;
            barSeries.ShowLabels = true;
            RadChart1.Series.Add(barSeries);
        }
		private RadCartesianChartView createChart(){
			RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

			BarSeries series = new BarSeries();

			DateTimeContinuousAxis axis = new DateTimeContinuousAxis();
			axis.LabelFormat = "MM/dd";
			series.HorizontalAxis = axis;

			LinearAxis verticalAxis = new LinearAxis();
			verticalAxis.LabelFormat = "%.0f";
			series.VerticalAxis = verticalAxis;

			series.ValueBinding = new ValueBinding();
			series.CategoryBinding = new CategoryBinding();

			series.Data = this.getData();

			chart.Series.Add(series);

			return chart;
		}
Esempio n. 21
0
        private RadCartesianChartView createChart()
        {
            //Create the Chart View
            RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

            //Create the bar series and attach axes and value bindings.
            BarSeries barSeries = new BarSeries();

            barSeries.ValueBinding = new ValueBinding();
            barSeries.CategoryBinding = new CategoryBinding();

            LinearAxis verticalAxis = new LinearAxis();
            //The values in the linear axis will not have values after the decimal point.
            CategoricalAxis horizontalAxis = new CategoricalAxis();
            horizontalAxis.LabelFormat = "%.0f";
            barSeries.VerticalAxis = verticalAxis;
            barSeries.HorizontalAxis = horizontalAxis;

            //Bind series to data
            barSeries.Data = this.getData();

            //Add series to chart
            chart.Series.Add(barSeries);

            //Set an instance of the CartesianChartGrid to the chart.

            CartesianChartGrid grid = new CartesianChartGrid();
            grid.MajorYLinesRenderMode = GridLineRenderMode.InnerAndLast;
            grid.LineThickness = 1;
            grid.LineColor = Color.White;
            grid.MajorLinesVisibility = GridLineVisibility.Y;
            grid.StripLinesVisibility = GridLineVisibility.Y;
            ObservableCollection yBrushes = grid.YStripeBrushes;
            yBrushes.Clear();
            chart.Grid = grid;

            return chart;
        }
Esempio n. 22
0
        private void loadGenderList()
        {
            int iCntMale = 0;
            int iCntFemale = 0;
           
            BarSeries series = new BarSeries();


            iCntMale = stEnrolled.FindAll(x => x.student.Gender == "M").Count;
                series.DataPoints.Add(new CategoricalDataPoint(iCntMale, "Male"));

            iCntFemale = stEnrolled.FindAll(x => x.student.Gender == "F").Count;
                series.DataPoints.Add(new CategoricalDataPoint(iCntFemale, "Female"));            

            this.radChartView1.Series.Add(series);

            CategoricalAxis categoricalAxis = radChartView1.Axes[0] as CategoricalAxis;
            categoricalAxis.PlotMode = AxisPlotMode.OnTicksPadded;
            categoricalAxis.LabelFitMode = AxisLabelFitMode.Rotate;
            categoricalAxis.LabelRotationAngle = 310;


        }
		private RadCartesianChartView createChart(){
			//Create the Chart View
			RadCartesianChartView chart = new RadCartesianChartView(this.Activity);

			//Create the bar series and attach axes and value bindings.
			BarSeries barSeries = new BarSeries();

			barSeries.ValueBinding = new ValueBinding();
			barSeries.CategoryBinding = new CategoryBinding();

			LinearAxis horizontalAxis = new LinearAxis();
			//The values in the linear axis will not have values after the decimal point.
			horizontalAxis.LabelFormat = "%.0f";
			CategoricalAxis verticalAxis = new CategoricalAxis();
			barSeries.VerticalAxis = verticalAxis;
			barSeries.HorizontalAxis = horizontalAxis;

			//Bind series to data
			barSeries.Data = this.getData();

			//Add series to chart
			chart.Series.Add(barSeries);
			return chart;
		}
Esempio n. 24
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         var list = db.Value.Housing_Department.OrderBy(o => o.Ordinal).ToList().Select(o => new HousingCount { 单位 = o, 数量 = 0 }).ToList();
         try
         {
             using (IStorageEngine engine = STSdb.FromFile(Server.MapPath("App_Data/Housing__Count.record")))
             {
                 var table = engine.OpenXTablePortable<Guid, int>("Record");
                 list.ForEach(x =>
                 {
                     try
                     {
                         x.数量 = table[x.单位.Id];
                     }
                     catch
                     {
                     }
                 });
             }
         }
         catch
         {
         }
         chart.PlotArea.XAxis.DataLabelsField = "单位.Name";
         foreach (var item in list)
         {
             chart.PlotArea.XAxis.Items.Add(new AxisItem { LabelText = item.单位.Name });
         }
         var series = new BarSeries { Name = "住房信息数量", DataFieldY = "数量" };
         chart.PlotArea.Series.Add(series);
         chart.DataSource = list;
         chart.DataBind();
        }
 }
Esempio n. 25
0
 public MACD(BarSeries series, int length1, int length2, BarData option)
 {
     this.indicator = new SmartQuant.Indicators.MACD(series.series, length1, length2, global::OpenQuant.API.EnumConverter.Convert(option));
 }
Esempio n. 26
0
 public SMD(BarSeries series, int length, BarData option)
 {
     this.indicator = new FreeQuant.Indicators.SMD(series.series, length, EnumConverter.Convert(option));
 }
Esempio n. 27
0
        private PlotModel GetGroupedBarChart()
        {
            PlotModel plotModel = new PlotModel
            {
                Title                 = "Grouped Bar Chart",
                LegendPlacement       = LegendPlacement.Outside,
                LegendPosition        = LegendPosition.BottomCenter,
                LegendOrientation     = LegendOrientation.Vertical,
                LegendBorderThickness = 0
            };

            BarSeries barSeriesOne = new BarSeries
            {
                Title           = "Price",
                StrokeColor     = OxyColors.Black,
                StrokeThickness = 1
            };

            barSeriesOne.Items.Add(new BarItem {
                Value = 25000
            });
            barSeriesOne.Items.Add(new BarItem {
                Value = 7000
            });
            barSeriesOne.Items.Add(new BarItem {
                Value = 12000
            });

            plotModel.Series.Add(barSeriesOne);

            BarSeries barSeriesTwo = new BarSeries
            {
                Title           = "Sale",
                StrokeColor     = OxyColors.Black,
                StrokeThickness = 1
            };

            barSeriesTwo.Items.Add(new BarItem {
                Value = 1500
            });
            barSeriesTwo.Items.Add(new BarItem {
                Value = 3200
            });
            barSeriesTwo.Items.Add(new BarItem {
                Value = 800
            });

            plotModel.Series.Add(barSeriesTwo);

            CategoryAxis categoryAxis = new CategoryAxis
            {
                Position    = AxisPosition.Left,
                ItemsSource = new[] { "Android ", "iOS", "Windows" }
            };

            plotModel.Axes.Add(categoryAxis);

            LinearAxis linearAxis = new LinearAxis
            {
                Position        = AxisPosition.Bottom,
                MinimumPadding  = 0,
                MaximumPadding  = 0.5,
                AbsoluteMinimum = 0
            };

            plotModel.Axes.Add(linearAxis);

            return(plotModel);
        }
Esempio n. 28
0
        protected internal override void Calculate(int index)
        {
            if (this.calculate)
            {
                this.Calculate();
                return;
            }
            BarSeries barSeries = this.input as BarSeries;
            Bar       bar       = barSeries[index];

            this.barsCount++;
            if (this.barsCount > 20)
            {
                this.lastSAR = this.sar;
                if (this.isLong)
                {
                    if (bar.High > this.sip)
                    {
                        this.sip = bar.High;
                        if (this.acc < this.upperBound)
                        {
                            this.acc += this.step;
                        }
                    }
                    if (bar.Low < this.sar)
                    {
                        this.isLong = false;
                    }
                    if (this.isLong)
                    {
                        this.diff = this.sip - this.sar;
                        this.sar += this.diff * this.acc;
                        if (this.sar > bar.Low || this.sar > this.prevLow)
                        {
                            if (bar.Low < this.prevLow)
                            {
                                this.sar = bar.Low;
                            }
                            else
                            {
                                this.sar = this.prevLow;
                            }
                        }
                        if (this.sar < this.lastSAR)
                        {
                            this.sar = this.lastSAR;
                        }
                        if (!double.IsNaN(this.sar))
                        {
                            base.Add(this.input.GetDateTime(index), this.sar);
                        }
                    }
                    else
                    {
                        this.sar = this.sip;
                        this.acc = this.initialAcc;
                        if (!double.IsNaN(this.sar))
                        {
                            base.Add(this.input.GetDateTime(index), this.sar);
                        }
                    }
                }
                else
                {
                    if (this.prevLow < this.sip)
                    {
                        this.sip = this.prevLow;
                        if (this.acc < this.upperBound)
                        {
                            this.acc += this.step;
                        }
                    }
                    if (bar.High > this.sar)
                    {
                        this.isLong = true;
                    }
                    if (!this.isLong)
                    {
                        this.diff = this.sar - this.sip;
                        this.sar -= this.diff * this.acc;
                        if (this.sar < bar.High || this.sar < this.prevHigh)
                        {
                            if (bar.High > this.prevHigh)
                            {
                                this.sar = bar.High;
                            }
                            else
                            {
                                this.sar = this.prevHigh;
                            }
                        }
                        if (this.sar > this.lastSAR)
                        {
                            this.sar = this.lastSAR;
                        }
                        if (!double.IsNaN(this.sar))
                        {
                            base.Add(this.input.GetDateTime(index), this.sar);
                        }
                    }
                    else
                    {
                        this.sar = this.sip;
                        this.acc = this.initialAcc;
                        if (!double.IsNaN(this.sar))
                        {
                            base.Add(this.input.GetDateTime(index), this.sar);
                        }
                    }
                }
            }
            else
            {
                if (this.barsCount == 20)
                {
                    this.isLong = true;
                    this.sip    = this.minClose;
                    this.sar    = this.sip;
                }
                else
                {
                    this.minClose = Math.Min(this.minClose, bar.Close);
                }
            }
            this.prevHigh = bar.High;
            this.prevLow  = bar.Low;
        }
Esempio n. 29
0
        public MainPage()
        {
            InitializeComponent();

            BackgroundColor = Xamarin.Forms.Device.OnPlatform(Xamarin.Forms.Color.White, Xamarin.Forms.Color.White, Xamarin.Forms.Color.Transparent);

            var chart = new RadCartesianChart
            {
                HorizontalAxis = new Telerik.XamarinForms.Chart.CategoricalAxis()
                {
                    LabelFitMode = AxisLabelFitMode.MultiLine,
                },
                VerticalAxis = new Telerik.XamarinForms.Chart.NumericalAxis()
                {
                    LabelFitMode         = AxisLabelFitMode.MultiLine,
                    RangeExtendDirection = NumericalAxisRangeExtendDirection.Both,
                    MajorStep            = 30,
                },
            };

            var series = new BarSeries();

            chart.Series.Add(series);

            this.Content = chart;

            series.ValueBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding
            {
                PropertyName = "Value"
            };

            series.CategoryBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding
            {
                PropertyName = "Category"
            };

            series.ItemsSource = MainViewModel.GetCategoricalData();

            var grid = new CartesianChartGrid();

            grid.MajorLinesVisibility = GridLineVisibility.Y;
            grid.MajorYLineDashArray  = Device.OnPlatform(null, new double[] { 4, 2 }, new double[] { 4, 2 });
            grid.StripLinesVisibility = GridLineVisibility.Y;

            grid.YStripeColor            = Color.FromRgba(99, 99, 99, 100);
            grid.YStripeAlternativeColor = Color.FromRgba(169, 169, 169, 31);
            grid.MajorLineColor          = Color.FromRgb(211, 211, 211);
            grid.MajorLineThickness      = Device.OnPlatform(0.5, 2, 2);

            chart.Grid = grid;

            var treshold      = MainViewModel.GetCategoricalData().Average(c => c.Value);
            var startTreshold = treshold * 0.95;
            var endTreshold   = treshold * 1.05;

            var lineAnnotation = new CartesianGridLineAnnotation()
            {
                Axis            = chart.VerticalAxis,
                Value           = treshold,
                Stroke          = Color.FromRgb(255, 0, 0),
                StrokeThickness = Device.OnPlatform(0.5, 2, 2),
                DashArray       = new double[] { 4, 2 },
            };

            var bandAnnotation = new CartesianPlotBandAnnotation()
            {
                Axis            = chart.VerticalAxis,
                From            = startTreshold,
                To              = endTreshold,
                Fill            = Color.FromRgba(255, 0, 0, 50),
                StrokeThickness = 2,
                Stroke          = Color.Transparent,
            };

            chart.Annotations.Add(bandAnnotation);
            chart.Annotations.Add(lineAnnotation);
        }
Esempio n. 30
0
 public ENVL(BarSeries series, int length, int shift, BarData option, Color color)
 {
     this.indicator = new FreeQuant.Indicators.ENVL(series.series, length, shift, EnumConverter.Convert(option), color);
 }
        private void BindRouteData()
        {
            bool foundAnything = false;
            Dictionary<Guid, BarSeries> seriesList = (!_isReturn) ? departureRouteSeries : returnRouteSeries;
            List<Series> removeSeries = new List<Series>();

            foreach (BarSeries series in departureChart.Series)
            {
                bool found = false;

                foreach (BarSeries newSeries in seriesList.Values)
                {
                    if (string.Equals(Convert.ToString(newSeries.Title), Convert.ToString(series.Title), StringComparison.InvariantCultureIgnoreCase))
                    {
                        ObservableCollection<KeyValuePair<string, int>> seriesData = (ObservableCollection<KeyValuePair<string, int>>)series.ItemsSource;
                        ObservableCollection<KeyValuePair<string, int>> newSeriesData = (ObservableCollection<KeyValuePair<string, int>>)newSeries.ItemsSource;
                        seriesData.Clear();

                        foreach (KeyValuePair<string, int> dataPoint in newSeriesData)
                        {
                            foundAnything = true;
                            seriesData.Add(dataPoint);
                        }

                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    removeSeries.Add(series);
                }
            }

            foreach (BarSeries newSeries in seriesList.Values)
            {
                bool found = false;
                foreach (BarSeries series in departureChart.Series)
                {
                    if (string.Equals(Convert.ToString(newSeries.Title), Convert.ToString(series.Title), StringComparison.InvariantCultureIgnoreCase))
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    ObservableCollection<KeyValuePair<string, int>> addSource = new ObservableCollection<KeyValuePair<string, int>>();
                    BarSeries addSeries = new BarSeries();
                    addSeries.Title = newSeries.Title;
                    addSeries.ItemsSource = addSource;
                    addSeries.IndependentValueBinding = newSeries.IndependentValueBinding;
                    addSeries.DependentValueBinding = newSeries.DependentValueBinding;

                    foreach (KeyValuePair<string, int> dataPoint in newSeries.ItemsSource)
                    {
                        foundAnything = true;
                        addSource.Add(dataPoint);
                    }
                    departureChart.Series.Add(addSeries);
                }

            }

            if (foundAnything)
            {
                loadingText.Visibility = System.Windows.Visibility.Collapsed;
                departureChart.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                loadingText.Text = "No Historical Data Available";
                loadingText.Visibility = System.Windows.Visibility.Visible;
                departureChart.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
        private void OnChartTypeSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox comboBox = sender as ComboBox;

            if (Basic_Chart5 == null)
            {
                return;
            }

            if (comboBox.SelectedIndex == 0 && viewModelColumn != null && viewModelColumn1 != null)
            {
                (Basic_Chart5.Legend as ChartLegend).Visibility = Visibility.Visible;
                Basic_Chart51.Visibility = Visibility.Visible;
                Basic_Chart5.SetValue(Grid.RowSpanProperty, 1);
                Basic_Chart5.Axes.Clear();
                Basic_Chart51.Axes.Clear();
                Basic_Chart5.AreaBorderThickness = new Thickness(1, 0, 0, 1);
                Basic_Chart5.AreaBorderThickness = new Thickness(1, 0, 0, 1);
                Basic_Chart5.Height  = 257;
                Basic_Chart5.Width   = 894;
                Basic_Chart51.Height = 257;
                Basic_Chart51.Width  = 894;
                Basic_Chart5.Header  = new TextBlock()
                {
                    Text = "Literacy rate in Nation", FontWeight = FontWeights.SemiBold
                };
                Basic_Chart51.Header = new TextBlock()
                {
                    Text                = "Economic Growth - Year 2014",
                    FontSize            = 20,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Margin              = new Thickness(50, 20, 0, 0),
                    FontWeight          = FontWeights.Medium,
                    FontFamily          = new FontFamily("Segoe UI")
                };
                ColumnSeries series1   = new ColumnSeries();
                ColumnSeries series2   = new ColumnSeries();
                ColumnSeries series3   = new ColumnSeries();
                DataTemplate template1 = MainGrid3.Resources["labelTemplate"] as DataTemplate;
                DataTemplate template2 = MainGrid3.Resources["headerTemplate"] as DataTemplate;
                DataTemplate template3 = MainGrid3.Resources["columnnewtemp1"] as DataTemplate;
                DataTemplate template7 = MainGrid3.Resources["columnnewtemp2"] as DataTemplate;
                Style        template5 = MainGrid3.Resources["axisLineStyle"] as Style;
                Style        template6 = MainGrid3.Resources["minorTickLineStyle"] as Style;
                DataTemplate template8 = MainGrid3.Resources["columnnewtemp3"] as DataTemplate;
                DataTemplate template4 = MainGrid3.Resources["postfixTemplatecc"] as DataTemplate;
                CategoryAxis axis1     = new CategoryAxis()
                {
                    ShowGridLines      = false,
                    LabelPlacement     = Syncfusion.UI.Xaml.Charts.LabelPlacement.BetweenTicks,
                    AxisLineStyle      = template5,
                    MajorTickLineStyle = template6
                };
                NumericalAxis axis2 = new NumericalAxis()
                {
                    ShowGridLines        = false,
                    AxisLineStyle        = template5,
                    MajorTickLineStyle   = template6,
                    PostfixLabelTemplate = template4,
                    Minimum    = "0",
                    Maximum    = "100",
                    Interval   = "20",
                    PlotOffset = 20
                };
                CategoryAxis axis3 = new CategoryAxis()
                {
                    ShowGridLines      = false,
                    LabelPlacement     = Syncfusion.UI.Xaml.Charts.LabelPlacement.BetweenTicks,
                    AxisLineStyle      = template5,
                    MajorTickLineStyle = template6
                };
                NumericalAxis axis4 = new NumericalAxis()
                {
                    ShowGridLines        = false,
                    AxisLineStyle        = template5,
                    MajorTickLineStyle   = template6,
                    PostfixLabelTemplate = template4,
                    Minimum    = "0",
                    Maximum    = "30",
                    Interval   = "10",
                    PlotOffset = 20
                };
                series3.XAxis              = axis3;
                series3.YAxis              = axis4;
                Basic_Chart5.PrimaryAxis   = axis1;
                Basic_Chart5.SecondaryAxis = axis2;
                series3.XBindingPath       = "Gadget";
                series3.YBindingPath       = "Value2";
                series3.ItemsSource        = viewModelColumn1;
                series3.LegendIcon         = ChartLegendIcon.Rectangle;
                series3.SegmentSpacing     = 0.5;
                series3.Interior           = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xC1, 0x07));
                series3.CustomTemplate     = template8;
                series1.XBindingPath       = "Gadget";
                series1.YBindingPath       = "Value1";
                series1.Label              = "Educated";
                series3.Label              = "Year 2014";
                series2.Label              = "Uneducated";
                series1.ItemsSource        = viewModelColumn;
                series1.LegendIcon         = ChartLegendIcon.Rectangle;
                series1.Interior           = new SolidColorBrush(Color.FromArgb(0xFF, 0x8B, 0xC3, 0x4A));
                series2.Interior           = new SolidColorBrush(Color.FromArgb(0xFF, 0xD1, 0xD3, 0xD4));
                series1.CustomTemplate     = template3;
                series2.LegendIcon         = ChartLegendIcon.Rectangle;
                series2.XBindingPath       = "Gadget";
                series2.YBindingPath       = "Value1";
                series2.ItemsSource        = viewModelColumn;
                series2.CustomTemplate     = template7;
                Basic_Chart5.Series.Clear();
                Basic_Chart51.Series.Clear();
                Basic_Chart5.Series.Add(series1);
                Basic_Chart5.Series.Add(series2);
                Basic_Chart51.Series.Add(series3);
            }
            else if (comboBox.SelectedIndex == 2 && viewModelScatter != null)
            {
                Basic_Chart51.Visibility = Visibility.Collapsed;
                (Basic_Chart5.Legend as ChartLegend).Visibility = Visibility.Collapsed;
                Basic_Chart5.SetValue(Grid.RowSpanProperty, 2);
                Basic_Chart5.Axes.Clear();
                Basic_Chart51.Axes.Clear();
                Basic_Chart51.Series.Clear();
                Basic_Chart5.Header = new TextBlock()
                {
                    Text     = "Global Stock Trend Comparison (2013 - 2014)", Margin = new Thickness(50, 10, 0, 10),
                    FontSize = 20, FontWeight = FontWeights.SemiBold
                };
                Basic_Chart5.AreaBorderThickness = new Thickness(0, 0.5, 0.5, 0);
                Basic_Chart5.Height          = 515;
                Basic_Chart5.AreaBorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xD1, 0xD3, 0xD4));
                DataTemplate       template1      = MainGrid3.Resources["scattertemplate"] as DataTemplate;
                DataTemplate       template2      = MainGrid3.Resources["scatterAdornmentTemplate"] as DataTemplate;
                ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo();
                DataTemplate       template3      = MainGrid3.Resources["labelTemplate"] as DataTemplate;
                DataTemplate       template4      = MainGrid3.Resources["headerTemplate"] as DataTemplate;
                Style        axisstyle            = MainGrid3.Resources["axisLineStyle"] as Style;
                Style        ticklinestyle        = MainGrid3.Resources["minorTickLineStyle"] as Style;
                DateTimeAxis axis1 = new DateTimeAxis()
                {
                    PlotOffset         = 30,
                    Interval           = 1,
                    IntervalType       = DateTimeIntervalType.Months,
                    LabelFormat        = "MMM",
                    Header             = "Year 2014",
                    LabelTemplate      = template3,
                    HeaderTemplate     = template4,
                    AxisLineStyle      = axisstyle,
                    MajorTickLineStyle = ticklinestyle,
                    ShowGridLines      = false
                };
                NumericalAxis axis2 = new NumericalAxis()
                {
                    Minimum            = 10,
                    Maximum            = 80,
                    Interval           = 10,
                    Header             = "Stock Price",
                    LabelFormat        = "$0",
                    LabelTemplate      = template3,
                    HeaderTemplate     = template4,
                    AxisLineStyle      = axisstyle,
                    MajorTickLineStyle = ticklinestyle,
                };
                ScatterSeries series = new ScatterSeries();
                adornmentInfo1.ShowLabel           = true;
                adornmentInfo1.SegmentLabelContent = LabelContent.LabelContentPath;
                adornmentInfo1.LabelTemplate       = template2;
                series.XBindingPath   = "Year";
                series.YBindingPath   = "Count";
                series.CustomTemplate = template1;
                series.YAxis          = axis2;
                series.XAxis          = axis1;
                series.ItemsSource    = viewModelScatter;
                series.ScatterWidth   = 64;
                series.ScatterHeight  = 64;
                series.AdornmentsInfo = adornmentInfo1;
                Basic_Chart5.Series.Clear();
                Basic_Chart5.Series.Add(series);
            }
            else if (comboBox.SelectedIndex == 3 && viewModelSpline != null)
            {
                Basic_Chart51.Visibility = Visibility.Collapsed;
                (Basic_Chart5.Legend as ChartLegend).Visibility = Visibility.Collapsed;
                Basic_Chart5.SetValue(Grid.RowSpanProperty, 2);
                Basic_Chart5.Axes.Clear();
                Basic_Chart51.Axes.Clear();
                Basic_Chart51.Series.Clear();
                Basic_Chart5.Height = 515;
                Basic_Chart5.Header = new TextBlock()
                {
                    Text = "Climate Graph", Margin = new Thickness(50, 10, 0, 10), FontSize = 20, FontWeight = FontWeights.SemiBold
                };
                Basic_Chart5.AreaBorderThickness = new Thickness(1, 1, 1, 1);
                Basic_Chart5.AreaBorderBrush     = new SolidColorBrush(Color.FromArgb(0xFF, 0xD1, 0xD3, 0xD4));
                Basic_Chart5.AreaBorderThickness = new Thickness(0, 0.5, 0.5, 0);
                SplineSeries series        = new SplineSeries();
                DataTemplate template1     = MainGrid3.Resources["splinetemplate"] as DataTemplate;
                DataTemplate template3     = MainGrid3.Resources["labelTemplate"] as DataTemplate;
                DataTemplate template4     = MainGrid3.Resources["headerTemplate"] as DataTemplate;
                DataTemplate template5     = MainGrid3.Resources["postfixTemplateSpline"] as DataTemplate;
                Style        axisstyle     = MainGrid3.Resources["axisLineStyle"] as Style;
                Style        ticklinestyle = MainGrid3.Resources["minorTickLineStyle"] as Style;
                DateTimeAxis axis1         = new DateTimeAxis()
                {
                    PlotOffset         = 20,
                    Interval           = 1,
                    IntervalType       = DateTimeIntervalType.Months,
                    LabelFormat        = "MMM",
                    Header             = "Year 2014",
                    LabelTemplate      = template3,
                    ShowGridLines      = false,
                    AxisLineStyle      = axisstyle,
                    MajorTickLineStyle = ticklinestyle,
                    HeaderTemplate     = template4
                };
                NumericalAxis axis2 = new NumericalAxis()
                {
                    Minimum            = -10,
                    Maximum            = 30,
                    Interval           = 5,
                    Header             = "Temperature(in Celsius)",
                    HeaderTemplate     = template4,
                    LabelTemplate      = template3,
                    AxisLineStyle      = axisstyle,
                    MajorTickLineStyle = ticklinestyle
                };
                series.XBindingPath   = "Month";
                series.YBindingPath   = "Value2";
                series.YAxis          = axis2;
                series.XAxis          = axis1;
                series.ItemsSource    = viewModelSpline;
                series.CustomTemplate = template1;
                Basic_Chart5.Series.Clear();
                Basic_Chart5.Series.Add(series);
            }
            else if (comboBox.SelectedIndex == 1 && viewModelBar != null)
            {
                (Basic_Chart5.Legend as ChartLegend).Visibility = Visibility.Collapsed;
                Basic_Chart51.Visibility = Visibility.Collapsed;
                Basic_Chart5.SetValue(Grid.RowSpanProperty, 2);
                Basic_Chart5.Axes.Clear();
                Basic_Chart51.Axes.Clear();
                Basic_Chart51.Series.Clear();
                Basic_Chart5.Height = 515;
                Basic_Chart5.Header = new TextBlock()
                {
                    Text = "Car Speed Comparison", Margin = new Thickness(50, 10, 0, 10), FontSize = 20, FontWeight = FontWeights.SemiBold
                };
                Basic_Chart5.AreaBorderThickness = new Thickness(0, 0, 0, 0);
                BarSeries    series1   = new BarSeries();
                DataTemplate template3 = MainGrid3.Resources["labelTemplate"] as DataTemplate;
                DataTemplate template7 = MainGrid3.Resources["labelTemplate1"] as DataTemplate;
                DataTemplate template4 = MainGrid3.Resources["headerTemplate"] as DataTemplate;
                DataTemplate template1 = MainGrid3.Resources["newBarTemplate"] as DataTemplate;
                Style        template5 = MainGrid3.Resources["axisLineStyle"] as Style;
                Style        template6 = MainGrid3.Resources["minorTickLineStyle"] as Style;
                CategoryAxis axis1     = new CategoryAxis()
                {
                    LabelTemplate      = template3,
                    AxisLineStyle      = template5,
                    MajorTickLineStyle = template6,
                    ShowGridLines      = false
                };
                NumericalAxis axis2 = new NumericalAxis()
                {
                    Header = "Acceleration rate",
                    EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift,
                    LabelTemplate         = template7,
                    AxisLineStyle         = template5,
                    MajorTickLineStyle    = template6,
                    HeaderTemplate        = template4,
                    Minimum       = "0",
                    Maximum       = "300",
                    Interval      = "75",
                    ShowGridLines = false
                };
                series1.XBindingPath   = "Month";
                series1.YBindingPath   = "Value1";
                series1.CustomTemplate = template1;
                series1.SegmentSpacing = 0.9;
                series1.ItemsSource    = viewModelBar;
                series1.XAxis          = axis1;
                series1.YAxis          = axis2;
                Basic_Chart5.Series.Clear();
                Basic_Chart5.Series.Add(series1);
            }
        }
Esempio n. 33
0
 public DPO(BarSeries series, int length, BarData option, Color color)
 {
     this.indicator = new SmartQuant.Indicators.DPO(series.series, length, global::OpenQuant.API.EnumConverter.Convert(option), color);
 }
Esempio n. 34
0
 public MDM(BarSeries series)
 {
     this.indicator = new FreeQuant.Indicators.MDM(series.series);
 }
 private void btnCategoricalLogarithmicAxis_Click(object sender, RoutedEventArgs e)
 {
     RadChart1.Series.Clear();
     RadChart1.Visibility = System.Windows.Visibility.Visible;
     BarSeries barSeries = new BarSeries();
     barSeries.ItemsSource = data1;
     RadChart1.VerticalAxis = new CategoricalAxis() { Title = "Vertical Categorical Axis" };
     RadChart1.HorizontalAxis = new LogarithmicAxis() { Title = "Horizontal Logarithmic Axis" };
     barSeries.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "Title" };
     barSeries.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Value" };
     barSeries.ShowLabels = true;
     RadChart1.Series.Add(barSeries);
     UpdateAxisTypesInfo();
 }
Esempio n. 36
0
        static void _Main(string[] args)
        {
            CsvDataImport cdi        = new CsvDataImport();
            string        symbol     = "AAPL2";
            Framework     framework  = Framework.Current;
            Instrument    instrument = framework.InstrumentManager.Get(symbol);

            if (instrument == null)
            {
                instrument = new Instrument(SmartQuant.InstrumentType.Stock, symbol, "", CurrencyId.CNY);
                framework.InstrumentManager.Add(instrument);
            }

            TickSeries trades = new TickSeries();
            TickSeries bids   = new TickSeries();
            TickSeries asks   = new TickSeries();
            BarSeries  bars   = new BarSeries();

            //using (StreamReader file = File.OpenText(@"‪d:\wukan\Desktop\AAPL.Bar Time 86400.csv"))
            FileInfo fi = new FileInfo(@"D:\AAPL.BarTime86400.csv");

            using (StreamReader file = new StreamReader(fi.OpenRead()))
            {
                int    i   = 0;
                string str = file.ReadLine();
                do
                {
                    ++i;
                    str = file.ReadLine();
                    if (str == null)
                    {
                        break;
                    }

                    string[] arr = str.Split(',');

                    Trade trade = null;
                    Bid   bid   = null;
                    Ask   ask   = null;
                    Bar   bar   = null;

                    //cdi.ReadLine(arr, instrument.Id, out trade, out bid, out ask);
                    cdi.ReadLine(arr, instrument.Id, SmartQuant.BarType.Time, 86400, out bar);

                    if (trade != null)
                    {
                        trades.Add(trade);
                    }

                    if (bid != null)
                    {
                        bids.Add(bid);
                    }

                    if (ask != null)
                    {
                        asks.Add(ask);
                    }

                    if (bar != null)
                    {
                        bars.Add(bar);
                    }
                } while (str != null);
                file.Close();
            }

            if (trades.Count > 0)
            {
                framework.DataManager.Save(trades);
            }

            if (bids.Count > 0)
            {
                framework.DataManager.Save(bids);
            }

            if (asks.Count > 0)
            {
                framework.DataManager.Save(asks);
            }

            if (bars.Count > 0)
            {
                framework.DataManager.Save(bars);
            }

            framework.Dispose();
        }
Esempio n. 37
0
 public BBU(BarSeries series, int length, double k, BarData option)
 {
     this.indicator = new SmartQuant.Indicators.BBU(series.series, length, k, global::OpenQuant.API.EnumConverter.Convert(option));
 }
Esempio n. 38
0
        private void SaveFuture(string strDstDir, DateTime month)
        {
            if (month == default(DateTime))
            {
                return;
            }

            foreach (string futureid in _bufferFuture.Keys)
            {
                //如果K线根数为0,表示没有K线信息,则直接跳过
                if (_bufferFuture[futureid].Count == 0)
                {
                    continue;
                }
                string fullname = strDstDir + "\\" + month.ToString("yyyyMM");
                if (!Directory.Exists(fullname))
                {
                    Directory.CreateDirectory(fullname);
                }


                fullname = fullname + "\\" + futureid + ".day";

                if (Market == EnumMarket.期货)
                {
                    FutureDayFile dayfile = new FutureDayFile();
                    dayfile.Init(fullname);
                    BarSeries daybarlist = new BarSeries();
                    if (_prgMq.Contains(futureid))
                    {
                        var starttime   = _prgMq.BeginTime(futureid);
                        var endtime     = _prgMq.EndTime(futureid);
                        var tradingdate = _bufferFuture[futureid][0].TradingDate;
                        //如果换月,则需要从当月的1号开始
                        if (starttime.Month < tradingdate.Month)
                        {
                            starttime = new DateTime(tradingdate.Year, tradingdate.Month, 1);
                        }
                        //如果换月,则不需要读取
                        if (endtime.Month == tradingdate.Month)
                        {
                            if (_prgMq.EndTime(futureid).Date == _bufferFuture[futureid][0].TradingDate)
                            {
                                endtime = endtime.AddDays(-1);
                                if (endtime >= starttime)
                                {
                                    dayfile.Read(daybarlist, starttime, endtime);
                                }
                                else
                                {
                                    _logger.Error(starttime + "没有读取到日线数据" + endtime + fullname);
                                }
                            }
                            else
                            {
                                dayfile.Read(daybarlist, _prgMq.BeginTime(futureid),
                                             _prgMq.EndTime(futureid));
                            }
                        }

                        daybarlist.AddRange(_bufferFuture[futureid]);
                    }
                    else
                    {
                        daybarlist = _bufferFuture[futureid];
                    }

                    if (File.Exists(fullname))
                    {
                        File.Delete(fullname);
                    }
                    if (daybarlist.Count > 0)
                    {
                        dayfile.Write(daybarlist);
                    }
                    else
                    {
                        _logger.Error("品种" + futureid + "在" + month + "没有对应的分钟线数据,请查询对应的数据是否有错!");
                    }
                }
            }

            _bufferFuture.Clear();
        }
Esempio n. 39
0
 public MACD(BarSeries series, int length1, int length2, Color color)
 {
     this.indicator = new SmartQuant.Indicators.MACD(series.series, length1, length2, color);
 }
Esempio n. 40
0
        private void rBut_ok_Click(object sender, EventArgs e)
        {
            DataSet   set            = new DataSet();
            DataTable windowsXPTable = new DataTable("WindowsXP"); //新建一个柱型来显示数据
            DataTable windows7Table  = new DataTable("Windows7");  //新建一个柱型来显示数据

            set.Tables.Clear();                                    //清除一个柱型的数据
            windowsXPTable.Rows.Clear();                           //清除柱型数据
            windows7Table.Rows.Clear();                            //清除柱型数据
            radChartView1.Series.Clear();                          //清除数据柱型图数据
            set.Tables.Add(windowsXPTable);                        //给柱型添加数据
            set.Tables.Add(windows7Table);                         //给柱型添加数据
            foreach (DataTable table in set.Tables)                //循环给每条柱型添加数据
            {
                table.Columns.Add("Month");                        //表示柱型下面的数据
                table.Columns.Add("Usage", typeof(double));        //给每条柱型添加数值
                // table.Columns.Add("Usage1", typeof(double));
            }

            CnasRemotCall reCnasRemotCall = new CnasRemotCall();
            int           yearInt         = int.Parse(cb_year.Text);                            //讲年份转化成int类型

            SortedList bb = new SortedList();                                                   // 给存储过程传值的集合

            bb.Add("firstTime", new DateTime(yearInt - 1, 1, 1));                               //时间
            DataSet result = reCnasRemotCall.RemotInterface.ExecuteProcedure("secondsend", bb); //根据时间,类型查询返回所需要的数据

            if (result != null && result.Tables != null && result.Tables.Count > 0)
            {
                int       selectYearTotal = 0;
                int       beforeYearTotal = 0;
                DataTable table           = result.Tables[0];
                for (int i = 0; i < 2; i++)//用于判断是哪一年的
                {
                    int calYear = i == 0 ? yearInt : yearInt - 1;
                    //j表示哪一月
                    for (int j = 1; j < 13; j++)
                    {
                        string  calMonth = calYear.ToString() + j.ToString().PadLeft(2, '0');
                        DataRow rowData  = null;
                        if (table.Rows != null)
                        {
                            foreach (DataRow row in table.Rows)
                            {
                                if (row["calMonth"] != null && row["calMonth"].ToString() == calMonth)
                                {
                                    rowData = row;
                                    break;
                                }
                            }
                        }


                        if (rowData == null)
                        {
                            if (calYear.ToString() == cb_year.Text && j.ToString() == cb_month.Text)
                            {
                                c1RG7.Value = 0;
                            }
                            if (i == 0)
                            {
                                windowsXPTable.Rows.Add(GetMonthLbl(j.ToString()), 0);
                            }
                            else
                            {
                                windows7Table.Rows.Add(GetMonthLbl(j.ToString()), 0);
                            }
                        }
                        else
                        {
                            double calResult = rowData["result"] is DBNull ? 0 : Convert.ToDouble(rowData["result"]);
                            if (calYear.ToString() == cb_year.Text && j.ToString() == cb_month.Text)
                            {
                                c1RG7.Value = calResult;
                            }
                            if (i == 0)
                            {
                                windowsXPTable.Rows.Add(GetMonthLbl(j.ToString()), calResult);
                                selectYearTotal += rowData["ccount"] is DBNull ? 0 : int.Parse(rowData["ccount"].ToString());
                            }
                            else
                            {
                                beforeYearTotal += rowData["ccount"] is DBNull ? 0 : int.Parse(rowData["ccount"].ToString());
                                windows7Table.Rows.Add(GetMonthLbl(j.ToString()), calResult);
                            }
                        }
                    }
                    RefreshDataGrid(table);
                }


                currentYearTxt.Text = selectYearTotal.ToString();
                lastyeartet.Text    = beforeYearTotal.ToString();
                radLabel3.Text      = beforeYearTotal == selectYearTotal ? "平稳" : (beforeYearTotal > selectYearTotal) ? "下降" : "上升";
            }

            this.radChartView1.DataSource = set;
            BarSeries windowsXPSeries = new BarSeries("Usage", "Month");

            windowsXPSeries.DataMember  = "WindowsXP";
            windowsXPSeries.LegendTitle = "Windows XP";
            BarSeries windows7Series = new BarSeries("Usage", "Month");

            windows7Series.DataMember  = "Windows7";
            windows7Series.LegendTitle = "Windows 7";
            windowsXPSeries.ShowLabels = true;
            windows7Series.ShowLabels  = true;
            this.radChartView1.Series.AddRange(windowsXPSeries, windows7Series);
        }
Esempio n. 41
0
 public VCH(BarSeries series, int length1, int length2, Color color)
 {
     this.indicator = new FreeQuant.Indicators.VCH(series.series, length1, length2, color);
 }
Esempio n. 42
0
 public ENVL(BarSeries series, int length, int shift, Color color)
 {
     this.indicator = new FreeQuant.Indicators.ENVL(series.series, length, shift, color);
 }
Esempio n. 43
0
 public DPO(BarSeries series, int length, Color color)
 {
     this.indicator = new SmartQuant.Indicators.DPO(series.series, length, color);
 }
        public PlotModel CreateBarPlotModel(Models.AudienceAnalytics audienceAnalytics)
        {
            var model = new PlotModel
            {
                LegendPlacement       = LegendPlacement.Outside,
                LegendPosition        = LegendPosition.BottomCenter,
                LegendOrientation     = LegendOrientation.Horizontal,
                LegendBorderThickness = 0
            };

            model.DefaultColors = new List <OxyColor>
            {
                OxyColor.Parse("#97A69D"),
                OxyColor.Parse("#A65B69"),
                OxyColor.Parse("#DABFAF")
            };

            var dailySeries = new BarSeries {
                Title = "Daily", StrokeColor = OxyColor.Parse("#006594")
            };

            foreach (var user in audienceAnalytics.ActiveUsers)
            {
                dailySeries.Items.Add(new BarItem(user.Daily));
            }

            var weeklySeries = new BarSeries {
                Title = "Weekly", StrokeColor = OxyColor.Parse("#c262af")
            };

            foreach (var user in audienceAnalytics.ActiveUsers)
            {
                weeklySeries.Items.Add(new BarItem(user.Weekly));
            }

            var monthlySeries = new BarSeries {
                Title = "Monthly", StrokeColor = OxyColor.Parse("#ffa600")
            };

            foreach (var user in audienceAnalytics.ActiveUsers)
            {
                monthlySeries.Items.Add(new BarItem(user.Monthly));
            }

            model.Series.Add(dailySeries);
            model.Series.Add(weeklySeries);
            model.Series.Add(monthlySeries);

            var categoryAxis = new CategoryAxis {
                Position = AxisPosition.Left
            };

            categoryAxis.IsZoomEnabled = false;
            categoryAxis.IsPanEnabled  = false;

            foreach (var user in audienceAnalytics.ActiveUsers)
            {
                var time = "01:00:00";
                var date = user.Date.Substring(0, user.Date.IndexOf(time, StringComparison.InvariantCultureIgnoreCase));
                categoryAxis.Labels.Add(date);
            }

            model.Axes.Add(categoryAxis);

            return(model);
        }
Esempio n. 45
0
		public virtual Cross Crosses(BarSeries series, Bar bar, BarData barData)
		{
			return EnumConverter.Convert(this.series.Crosses((FreeQuant.Series.TimeSeries)series.series, bar.bar, (int)barData));
		}
Esempio n. 46
0
 public BBU(BarSeries series, int length, double k, Color color)
 {
     this.indicator = new SmartQuant.Indicators.BBU(series.series, length, k, color);
 }
 private void btnCategoricalCategorical_Click(object sender, RoutedEventArgs e)
 {
     RadChart1.Series.Clear();
     RadChart1.Visibility = System.Windows.Visibility.Visible;
     BarSeries barSeries = new BarSeries();
     barSeries.ItemsSource = data1;
     RadChart1.VerticalAxis = new CategoricalAxis()
     {
         LabelRotationAngle = 30,
         LabelFormat = "MMM dd yyy",
         Title = "Vertical Categorical Axis"
     };
     RadChart1.HorizontalAxis = new CategoricalAxis()
     {
         LabelFitMode = Telerik.Charting.AxisLabelFitMode.Rotate,
         LabelRotationAngle = 30,
         Title = "Horizontal Categorical Axis"
     };
     barSeries.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "Title" };
     barSeries.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Value" };
     barSeries.ItemsSource = data1;
     barSeries.ShowLabels = true;
     RadChart1.Series.Add(barSeries);
     UpdateAxisTypesInfo();
 }
Esempio n. 48
0
        public static PlotModel TornadoDiagram1()
        {
            // http://en.wikipedia.org/wiki/Tornado_diagram
            var model = new PlotModel {
                Title = "Tornado diagram 1"
            };
            var l = new Legend
            {
                LegendPlacement = LegendPlacement.Outside
            };

            model.Legends.Add(l);

            var s1 = new BarSeries
            {
                Title           = "High",
                IsStacked       = true,
                FillColor       = OxyColor.FromRgb(216, 82, 85),
                BaseValue       = 7,
                StrokeColor     = OxyColors.Black,
                StrokeThickness = 1
            };

            s1.Items.Add(new BarItem(1));
            s1.Items.Add(new BarItem(1));
            s1.Items.Add(new BarItem(4));
            s1.Items.Add(new BarItem(5));

            var s2 = new BarSeries
            {
                Title           = "Low",
                IsStacked       = true,
                FillColor       = OxyColor.FromRgb(84, 138, 209),
                BaseValue       = 7,
                StrokeColor     = OxyColors.Black,
                StrokeThickness = 1
            };

            s2.Items.Add(new BarItem(-1));
            s2.Items.Add(new BarItem(-3));
            s2.Items.Add(new BarItem(-2));
            s2.Items.Add(new BarItem(-3));

            var categoryAxis = new CategoryAxis {
                Position = AxisPosition.Left
            };

            categoryAxis.Labels.Add("F/X rate");
            categoryAxis.Labels.Add("Inflation");
            categoryAxis.Labels.Add("Price");
            categoryAxis.Labels.Add("Conversion");
            var valueAxis = new LinearAxis {
                Position = AxisPosition.Bottom, ExtraGridlines = new[] { 7.0 }
            };

            model.Series.Add(s1);
            model.Series.Add(s2);
            model.Axes.Add(categoryAxis);
            model.Axes.Add(valueAxis);
            return(model);
        }
Esempio n. 49
0
 public BarSeriesEventArgs(BarSeries barSeries, Instrument instrument) : base()
 {
     this.BarSeries  = barSeries;
     this.Instrument = instrument;
 }
Esempio n. 50
0
        public Form1()
        {
            InitializeComponent();

            // Create chart.
            var chart = new LightningChartUltimate();

            // Disable rendering before updating chart properties to improve performance
            // and to prevent unnecessary chart redrawing while changing multiple properties.
            chart.BeginUpdate();

            // Set chart control into parent container.
            chart.Parent = this;           // Set form as parent.
            chart.Dock   = DockStyle.Fill; // Maximize to parent client area.

            // Define variables for X- and Y-axis.
            var axisX = chart.ViewXY.XAxes[0];
            var axisY = chart.ViewXY.YAxes[0];

            // Set title options for X- and Y-axis.
            axisX.Title.Visible = false;
            axisY.Title.Text    = "Temperature °C";

            // Set label angle for X-axis.
            axisX.LabelsAngle = 90;

            // LegendBox layout.
            chart.ViewXY.LegendBoxes[0].Position = LegendBoxPositionXY.SegmentTopRight;

            // Disable autoformating of labels.
            axisX.AutoFormatLabels = false;

            // Enable CustomAxisTicks.
            axisX.CustomTicksEnabled = true;

            // 1. Create a new BarSeries.
            var barSeries1 = new BarSeries(chart.ViewXY, axisX, axisY);

            // Add styling to created series.
            barSeries1.Fill.Color        = Color.Orange;
            barSeries1.Fill.GradientFill = GradientFill.Solid;
            barSeries1.Title.Text        = "2017";
            barSeries1.BarThickness      = 10;

            // 2. Generate data as BarSeriesValues to represent average monthly temperatures.
            BarSeriesValue[] bars1 = new BarSeriesValue[]
            {
                new BarSeriesValue(0, -5, null),
                new BarSeriesValue(1, -6, null),
                new BarSeriesValue(2, -2, null),
                new BarSeriesValue(3, 4, null),
                new BarSeriesValue(4, 10, null),
                new BarSeriesValue(5, 14, null),
                new BarSeriesValue(6, 17, null),
                new BarSeriesValue(7, 15, null),
                new BarSeriesValue(8, 10, null),
                new BarSeriesValue(9, 6, null),
                new BarSeriesValue(10, -2, null),
                new BarSeriesValue(11, -4, null)
            };

            // Add BarSeriesValues to BarSeries.
            barSeries1.Values = bars1;

            // 3. Add BarSeries to chart.
            chart.ViewXY.BarSeries.Add(barSeries1);

            // 4. Create second BarSeries.
            var barSeries2 = new BarSeries();

            // Add styling to created series.
            barSeries2.Fill.Color        = Color.LightGray;
            barSeries2.Fill.GradientFill = GradientFill.Solid;
            barSeries2.Title.Text        = "2018";
            barSeries2.BarThickness      = 10;

            // 5. Generate an other set of data as BarSeriesValues to represent average monthly temperatures.
            BarSeriesValue[] bars2 = new BarSeriesValue[]
            {
                new BarSeriesValue(0, -1, null),
                new BarSeriesValue(1, -1, null),
                new BarSeriesValue(2, 2, null),
                new BarSeriesValue(3, 8, null),
                new BarSeriesValue(4, 15, null),
                new BarSeriesValue(5, 19, null),
                new BarSeriesValue(6, 21, null),
                new BarSeriesValue(7, 19, null),
                new BarSeriesValue(8, 14, null),
                new BarSeriesValue(9, 8, null),
                new BarSeriesValue(10, 2, null),
                new BarSeriesValue(11, -7, null)
            };

            // Add BarSeriesValues to BarSeries.
            barSeries2.Values = bars2;

            // 6. Add BarSeries to chart.
            chart.ViewXY.BarSeries.Add(barSeries2);

            // 7. Configure bar view layout.
            chart.ViewXY.BarViewOptions.Grouping = BarsGrouping.ByLocation;

            // 8. Create list of months.
            string[] months = new string[]
            {
                "January",
                "February",
                "March",
                "April",
                "May",
                "June",
                "July",
                "August",
                "September",
                "October",
                "November",
                "December"
            };

            // 9. Create CustomAxisTicks to display months as X-axis values.
            for (int i = 0; i < months.Length; i++)
            {
                CustomAxisTick tick = new CustomAxisTick(axisX);
                tick.AxisValue = i;
                tick.LabelText = months[i];
                tick.Color     = Color.FromArgb(35, 255, 255, 255);

                axisX.CustomTicks.Add(tick);
            }

            // Notify chart about set custom axis ticks.
            axisX.InvalidateCustomTicks();

            // Auto-scale X- and Y-axes.
            chart.ViewXY.ZoomToFit();

            #region Hidden polishing
            // Customize chart.
            CustomizeChart(chart);
            #endregion

            // Call EndUpdate to enable rendering again.
            chart.EndUpdate();
        }
Esempio n. 51
0
		public virtual bool CrossesAbove(BarSeries series, Bar bar, BarData barData)
		{
			return this.series.CrossesAbove((FreeQuant.Series.TimeSeries)series.series, bar.bar, (int)barData);
		}
Esempio n. 52
0
        private void rBut_ok_Click(object sender, EventArgs e)
        {
            //c1RG6.Value = 0;
            DataSet   set            = new DataSet();
            DataTable windowsXPTable = new DataTable("WindowsXP");
            DataTable windows7Table  = new DataTable("Windows7");

            set.Tables.Clear();
            windowsXPTable.Rows.Clear();
            windows7Table.Rows.Clear();
            radChartView1.Series.Clear();
            set.Tables.Add(windowsXPTable);
            set.Tables.Add(windows7Table);
            foreach (DataTable table in set.Tables)
            {
                table.Columns.Add("Month");
                table.Columns.Add("Usage", typeof(double));
                // table.Columns.Add("Usage1", typeof(double));
            }

            CnasRemotCall reCnasRemotCall = new CnasRemotCall();
            int           yearInt         = int.Parse(cb_year.Text);

            SortedList bb     = new SortedList();
            DataSet    result = null;

            bb.Add("time", new DateTime(yearInt - 1, 1, 1));
            if (N_type == "207")//湿包项
            {
                bb.Add("norm1", "208");
                bb.Add("norm", N_type);
                result = reCnasRemotCall.RemotInterface.ExecuteProcedure("total_average1", bb);
            }
            else if (N_type == "301")//灭菌失败项
            {
                bb.Add("norm1", "302");
                bb.Add("norm2", "303");
                bb.Add("norm", N_type);
                result = reCnasRemotCall.RemotInterface.ExecuteProcedure("total_average2", bb);
            }
            else
            {
                bb.Add("norm", N_type);
                result = reCnasRemotCall.RemotInterface.ExecuteProcedure("total_average", bb);
            }


            if (result != null && result.Tables != null && result.Tables.Count > 0)
            {
                int       selectYearTotal = 0;
                int       beforeYearTotal = 0;
                DataTable table           = result.Tables[0];
                for (int i = 0; i < 2; i++)
                {
                    int calYear = i == 0 ? yearInt : yearInt - 1;
                    for (int j = 1; j < 13; j++)
                    {
                        string  calMonth = calYear.ToString() + j.ToString().PadLeft(2, '0');
                        DataRow rowData  = null;
                        if (table.Rows != null)
                        {
                            foreach (DataRow row in table.Rows)
                            {
                                if (row["calMonth"] != null && row["calMonth"].ToString() == calMonth)
                                {
                                    rowData = row;
                                    break;
                                }
                            }
                        }


                        if (rowData == null)
                        {
                            if (calYear.ToString() == cb_year.Text && j.ToString() == DateTime.Now.Month.ToString())
                            {
                                c1RG.Value = 0;
                            }
                            if (i == 0)
                            {
                                windowsXPTable.Rows.Add(GetMonthLbl(j.ToString()), 0);
                            }
                            else
                            {
                                windows7Table.Rows.Add(GetMonthLbl(j.ToString()), 0);
                            }
                        }
                        else
                        {
                            double calResult = rowData["total"] is DBNull ? 0 : Convert.ToDouble(rowData["total"]);
                            if (calYear.ToString() == cb_year.Text && j.ToString() == DateTime.Now.Month.ToString())
                            {
                                c1RG.Value = calResult;
                            }
                            if (i == 0)
                            {
                                windowsXPTable.Rows.Add(GetMonthLbl(j.ToString()), calResult);
                                selectYearTotal += rowData["total"] is DBNull ? 0 : int.Parse(rowData["total"].ToString());
                            }
                            else
                            {
                                beforeYearTotal += rowData["total"] is DBNull ? 0 : int.Parse(rowData["total"].ToString());
                                windows7Table.Rows.Add(GetMonthLbl(j.ToString()), calResult);
                            }
                        }
                    }
                }
                RefreshDataGrid(table);
                if (cb_year.Text == DateTime.Now.Year.ToString())//只显示今年和去年的数据
                {
                    currentYearTxt.Text = selectYearTotal.ToString();
                    lastyeartet.Text    = beforeYearTotal.ToString();
                    radLabel3.Text      = beforeYearTotal == selectYearTotal ? "平稳" : (beforeYearTotal > selectYearTotal) ? "下降" : "上升";
                }
            }


            this.radChartView1.DataSource = set;
            BarSeries windowsXPSeries = new BarSeries("Usage", "Month");

            windowsXPSeries.DataMember  = "WindowsXP";
            windowsXPSeries.LegendTitle = "Windows XP";
            BarSeries windows7Series = new BarSeries("Usage", "Month");

            windows7Series.DataMember  = "Windows7";
            windows7Series.LegendTitle = "Windows 7";
            windowsXPSeries.ShowLabels = true;
            windows7Series.ShowLabels  = true;
            this.radChartView1.Series.AddRange(windowsXPSeries, windows7Series);
        }
        void ProcessHistory(MobileSrc.Commuter.Shared.CommuteHistory commuteHistory)
        {
            departureRouteSeries.Clear();
            returnRouteSeries.Clear();

            foreach (MobileSrc.Commuter.Shared.RouteDefinition route in DataContextManager.SelectedCommute.Routes)
            {
                ObservableCollection<KeyValuePair<string, int>> depSeriesData = new ObservableCollection<KeyValuePair<string, int>>();
                ObservableCollection<KeyValuePair<string, int>> retSeriesData = new ObservableCollection<KeyValuePair<string, int>>();

                BarSeries retSeries = new BarSeries();
                retSeries.Title = route.Name;
                retSeries.ItemsSource = retSeriesData;
                retSeries.IndependentValueBinding = new System.Windows.Data.Binding("Key");
                retSeries.DependentValueBinding = new System.Windows.Data.Binding("Value");

                BarSeries depSeries = new BarSeries();
                depSeries.Title = route.Name;
                depSeries.ItemsSource = depSeriesData;
                depSeries.IndependentValueBinding = new System.Windows.Data.Binding("Key");
                depSeries.DependentValueBinding = new System.Windows.Data.Binding("Value");

                departureRouteSeries.Add(route.Id, depSeries);
                returnRouteSeries.Add(route.Id, retSeries);
            }

            foreach (MobileSrc.Commuter.Shared.RouteHistory history in commuteHistory.Routes)
            {
                if (departureRouteSeries.ContainsKey(history.RouteId))
                {
                    ObservableCollection<KeyValuePair<string, int>> depSeriesData = (ObservableCollection<KeyValuePair<string, int>>)departureRouteSeries[history.RouteId].ItemsSource;
                    ObservableCollection<KeyValuePair<string, int>> retSeriesData = (ObservableCollection<KeyValuePair<string, int>>)returnRouteSeries[history.RouteId].ItemsSource;

                    Dictionary<DayOfWeek, double> depDayValues = new Dictionary<DayOfWeek, double>();
                    Dictionary<DayOfWeek, double> retDayValues = new Dictionary<DayOfWeek, double>();

                    foreach (MobileSrc.Commuter.Shared.RouteHistory.RouteHistoryDay historyDay in history.DepartureAverages)
                    {
                        if (!depDayValues.ContainsKey((DayOfWeek)historyDay.Day))
                        {
                            depDayValues.Add((DayOfWeek)historyDay.Day, historyDay.Minutes);
                        }
                    }
                    foreach (MobileSrc.Commuter.Shared.RouteHistory.RouteHistoryDay historyDay in history.ReturnAverages)
                    {
                        if (!retDayValues.ContainsKey((DayOfWeek)historyDay.Day))
                        {
                            retDayValues.Add((DayOfWeek)historyDay.Day, historyDay.Minutes);
                        }
                    }
                    Dictionary<DayOfWeek, double> dayValues = new Dictionary<DayOfWeek, double>();

                    for (int i = 0; i <= (int)DayOfWeek.Saturday; ++i)
                    {
                        int value = (int)Math.Pow(2, i);

                        if (0 != ((int)DataContextManager.SelectedCommute.DaysOfWeek & value))
                        {
                            double depTimeValue = 0;
                            double retTimeValue = 0;

                            if (depDayValues.ContainsKey((DayOfWeek)i))
                            {
                                depTimeValue = depDayValues[(DayOfWeek)i];
                            }
                            if (retDayValues.ContainsKey((DayOfWeek)i))
                            {
                                retTimeValue = retDayValues[(DayOfWeek)i];
                            }

                            string dayName = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames[i].Substring(0, 3);
                            depSeriesData.Add(new KeyValuePair<string, int>(dayName, (int)depTimeValue));
                            retSeriesData.Add(new KeyValuePair<string, int>(dayName, (int)retTimeValue));
                        }
                    }
                }
            }
            BindRouteData();
        }
Esempio n. 54
0
 public FO(BarSeries series, int length, Color color)
 {
     this.indicator = new FreeQuant.Indicators.FO(series.series, length, color);
 }
Esempio n. 55
0
        public HomeViewModel()
        {
            this.MyModel = new PlotModel {
                Title = "Estate sold"
            };
            listEstate = new List <Estate>(EstateDbContext.Current.Estates.Include(e => e.Photos)
                                           .Include(e => e.Contracts)
                                           .Include(e => e.MainPhoto)
                                           .Include(e => e.Owner));

            int House           = 0;
            int CommercialLocal = 0;
            int Garage          = 0;
            int Flat            = 0;
            int Field           = 0;
            int Other           = 0;

            for (int i = 0; i < listEstate.Count; i++)
            {
                if (listEstate[i].Type == EstateType.House)
                {
                    House++;
                }
                else if (listEstate[i].Type == EstateType.CommercialLocal)
                {
                    CommercialLocal++;
                }
                else if (listEstate[i].Type == EstateType.Garage)
                {
                    Garage++;
                }
                else if (listEstate[i].Type == EstateType.Flat)
                {
                    Flat++;
                }
                else if (listEstate[i].Type == EstateType.Field)
                {
                    Field++;
                }
                else if (listEstate[i].Type == EstateType.Other)
                {
                    Other++;
                }
            }
            var sum = listEstate.Count;

            var barSeries = new BarSeries
            {
                ItemsSource = new List <BarItem>(new[]
                {
                    new BarItem {
                        Value = (House * 1.0 / sum * 100)
                    },
                    new BarItem {
                        Value = (CommercialLocal * 1.0 / sum * 100)
                    },
                    new BarItem {
                        Value = (Garage * 1.0 / sum * 100)
                    },
                    new BarItem {
                        Value = (Flat * 1.0 / sum * 100)
                    },
                    new BarItem {
                        Value = (Field * 1.0 / sum * 100)
                    },
                    new BarItem {
                        Value = (Other * 1.0 / sum * 100)
                    }
                }),
                LabelPlacement    = LabelPlacement.Inside,
                LabelFormatString = "{0:.00}%"
            };

            MyModel.Series.Add(barSeries);

            MyModel.Axes.Add(new CategoryAxis
            {
                Position    = AxisPosition.Left,
                Key         = "CakeAxis",
                ItemsSource = new[]
                {
                    EstateType.House.ToString(),
                    EstateType.CommercialLocal.ToString(),
                    EstateType.Garage.ToString(),
                    EstateType.Flat.ToString(),
                    EstateType.Field.ToString(),
                    EstateType.Other.ToString()
                }
            });
        }
Esempio n. 56
0
 public FO(BarSeries series, int length, BarData option, Color color)
 {
     this.indicator = new FreeQuant.Indicators.FO(series.series, length, EnumConverter.Convert(option), color);
 }
Esempio n. 57
0
 public R(BarSeries series, int length)
 {
     this.indicator = new SmartQuant.Indicators.R(series.series, length);
 }
Esempio n. 58
0
 public BarSeriesItem(BarSeries series, Instrument instrument)
 {
     this.series     = series;
     this.instrument = instrument;
     this.RefreshName();
 }
Esempio n. 59
0
 public MDM(BarSeries series, Color color)
 {
     this.indicator = new FreeQuant.Indicators.MDM(series.series, color);
 }
Esempio n. 60
0
        private void OnChartTypeSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox comboBox = sender as ComboBox;

            if (Basic_Chart5 == null)
            {
                return;
            }

            if (comboBox.SelectedIndex == 0 && viewModelBar != null)
            {
                Basic_Chart5.SetValue(Grid.RowSpanProperty, 2);
                Basic_Chart5.Axes.Clear();
                Basic_Chart5.Height = 515;
                Basic_Chart5.Header = "Car Speed Comparison";
                Basic_Chart5.AreaBorderThickness = new Thickness(0, 0, 0, 0);
                BarSeries    series1   = new BarSeries();
                DataTemplate template1 = MainGrid3.Resources["newBarTemplate"] as DataTemplate;

                CategoryAxis axis1 = new CategoryAxis()
                {
                    ShowGridLines = false
                };

                NumericalAxis axis2 = new NumericalAxis()
                {
                    Header = "Acceleration rate",
                    EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift,
                    LabelFormat           = "0Kmph",
                    Minimum       = "0",
                    Maximum       = "300",
                    Interval      = "75",
                    ShowGridLines = false
                };

                series1.XBindingPath   = "Month";
                series1.YBindingPath   = "Value1";
                series1.CustomTemplate = template1;
                series1.SegmentSpacing = 0.9;
                series1.ItemsSource    = viewModelBar;
                series1.XAxis          = axis1;
                series1.YAxis          = axis2;
                Basic_Chart5.Series.Clear();
                Basic_Chart5.Series.Add(series1);
            }

            else if (comboBox.SelectedIndex == 1 && viewModelScatter != null)
            {
                Basic_Chart5.SetValue(Grid.RowSpanProperty, 2);
                Basic_Chart5.Axes.Clear();
                Basic_Chart5.Header = "Global Stock Trend Comparison (2013 - 2014)";
                Basic_Chart5.AreaBorderThickness = new Thickness(0, 0.5, 0.5, 0);
                Basic_Chart5.Height          = 515;
                Basic_Chart5.AreaBorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xD1, 0xD3, 0xD4));
                DataTemplate       template1      = MainGrid3.Resources["scattertemplate"] as DataTemplate;
                DataTemplate       template2      = MainGrid3.Resources["scatterAdornmentTemplate"] as DataTemplate;
                ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo();
                DateTimeAxis       axis1          = new DateTimeAxis()
                {
                    PlotOffset    = 30,
                    Interval      = 1,
                    IntervalType  = DateTimeIntervalType.Months,
                    LabelFormat   = "MMM",
                    Header        = "Year 2014",
                    ShowGridLines = false
                };

                NumericalAxis axis2 = new NumericalAxis()
                {
                    Minimum     = 10,
                    Maximum     = 80,
                    Interval    = 10,
                    Header      = "Stock Price",
                    LabelFormat = "$0",
                };

                ScatterSeries series = new ScatterSeries();
                adornmentInfo1.ShowLabel           = true;
                adornmentInfo1.SegmentLabelContent = LabelContent.LabelContentPath;
                adornmentInfo1.LabelTemplate       = template2;
                series.XBindingPath   = "Year";
                series.YBindingPath   = "Count";
                series.CustomTemplate = template1;
                series.YAxis          = axis2;
                series.XAxis          = axis1;
                series.ItemsSource    = viewModelScatter;
                series.ScatterWidth   = 64;
                series.ScatterHeight  = 64;
                series.AdornmentsInfo = adornmentInfo1;
                Basic_Chart5.Series.Clear();
                Basic_Chart5.Series.Add(series);
            }
            else if (comboBox.SelectedIndex == 2 && viewModelSpline != null)
            {
                Basic_Chart5.SetValue(Grid.RowSpanProperty, 2);
                Basic_Chart5.Axes.Clear();
                Basic_Chart5.Height = 515;
                Basic_Chart5.Header = "Climate Graph";

                Basic_Chart5.AreaBorderThickness = new Thickness(1, 1, 1, 1);
                Basic_Chart5.AreaBorderBrush     = new SolidColorBrush(Color.FromArgb(0xFF, 0xD1, 0xD3, 0xD4));
                Basic_Chart5.AreaBorderThickness = new Thickness(0, 0.5, 0.5, 0);
                SplineSeries series    = new SplineSeries();
                DataTemplate template1 = MainGrid3.Resources["splinetemplate"] as DataTemplate;
                DateTimeAxis axis1     = new DateTimeAxis()
                {
                    PlotOffset    = 20,
                    Interval      = 1,
                    IntervalType  = DateTimeIntervalType.Months,
                    LabelFormat   = "MMM",
                    Header        = "Year 2014",
                    ShowGridLines = false,
                };

                NumericalAxis axis2 = new NumericalAxis()
                {
                    Minimum  = -10,
                    Maximum  = 30,
                    Interval = 5,
                    Header   = "Temperature(in Celsius)",
                };

                ChartStripLine stripline = new ChartStripLine()
                {
                    Start      = -0.2,
                    Width      = 0.2,
                    Background = new SolidColorBrush(Colors.Red)
                };
                axis2.StripLines.Add(stripline);

                series.XBindingPath   = "Month";
                series.YBindingPath   = "Value2";
                series.YAxis          = axis2;
                series.XAxis          = axis1;
                series.ItemsSource    = viewModelSpline;
                series.CustomTemplate = template1;
                Basic_Chart5.Series.Clear();
                Basic_Chart5.Series.Add(series);
            }
        }