/// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(Color.Orange, "TSF")); y = new DataSeries(this); Overlay = true; }
protected override void Initialize() { #region Chart Features Add(new Plot(Color.DodgerBlue, PlotStyle.Line, "RSX")); Add(new Plot(Color.Gray, PlotStyle.Hash, "Top Line")); Add(new Plot(Color.Gray, PlotStyle.Hash, "Bot Line")); Add(new Plot(Color.White, PlotStyle.Line, ".panel range min")); // invisible Add(new Plot(Color.White, PlotStyle.Line, ".panel range max")); // invisible Plots[0].Pen.Width = 2; Plots[1].Pen.DashStyle = DashStyle.Dash; Plots[2].Pen.DashStyle = DashStyle.Dash; Add(new Line(Color.Gray, 50, "Mid Line")); Lines[0].Pen.Width = 2; CalculateOnBarClose = false; Overlay = false; PriceTypeSupported = false; #endregion #region Series Initialization PriceSeries = new DataSeries(this); #endregion }
public static void FillWithSampleData(DataSeries series, int numberOfItems, int sum) { int localSum = 0; Random random = new Random((int)(series.GetHashCode() + DateTime.Now.Ticks)); for (int i = 0; i < numberOfItems; i++) { int randomNumber = 0; while (randomNumber <= 0) randomNumber = random.Next(sum / numberOfItems - 3, sum / numberOfItems + 3); if (localSum + randomNumber > sum) randomNumber = sum - localSum; if ((i == numberOfItems - 1) && (localSum + randomNumber < sum)) randomNumber = sum - localSum; localSum += randomNumber; DataPoint dataPoint = new DataPoint(); dataPoint.YValue = randomNumber; series.Add(dataPoint); } }
public DataSeriesEvaluator(DataSeries series_) { m_name = series_.Name; m_dataType = series_.DataType; m_all = series_; Evaluate(series_.Dates[0], series_.Dates[series_.Dates.Length - 1]); }
protected void CalculateIndicators() { // Init indicators momentumSeries = Momentum.Series(Close, momentumPeriod.ValueInt); DataSeries stochDSeries = StochD.Series(Bars, stochDSmooth.ValueInt, stochDPeriod.ValueInt); DataSeries stochKSeries = StochK.Series(Bars, stochKPeriod.ValueInt); }
/// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(new Pen(Color.LightSteelBlue, 2), "Macd")); // plot 0 Add(new Plot(new Pen(Color.RoyalBlue, 2), PlotStyle.Hash, "MacdUp")); // plot 1 Add(new Plot(new Pen(Color.DarkRed, 2), PlotStyle.Hash, "MacdDn")); // plot 2 Add(new Plot(new Pen(Color.Yellow, 2), PlotStyle.Hash, "MacdNeutral")); // plot 3 Add(new Plot(new Pen(Color.DarkViolet, 2), "Avg")); // plot 4 Add(new Plot(new Pen(Color.DimGray, 2), PlotStyle.Bar, "Diff")); // plot 5 Add(new Plot(new Pen(Color.Teal, 2), PlotStyle.Line, "ADX")); // plot 6 Plots[0].Pen.Width = 3; Plots[1].Pen.Width = 6; Plots[2].Pen.Width = 6; Plots[3].Pen.Width = 6; Plots[4].Pen.Width = 1; Plots[5].Pen.Width = 2; Plots[6].Pen.Width = 2; Plots[4].Pen.DashStyle = DashStyle.Dash; fastEma = new DataSeries(this); macdAvg2 = new DataSeries(this); diffArr = new DataSeries(this); signal = new DataSeries(this); Overlay = false; PriceTypeSupported = true; }
/// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(Color.Orange, Name)); cummulative = new DataSeries(this); moneyFlow = new DataSeries(this); }
protected override void Initialize() { #region Chart Features Add(new Plot(Color.White, PlotStyle.Line, ".panel range min")); // invisible Add(new Plot(Color.White, PlotStyle.Line, ".panel range max")); // invisible Add(new Plot(Color.Cyan, PlotStyle.Line, "Stoch")); Plots[2].Pen.Width = 2; Add(new Line(Color.Gray, -60, "Lower Line")); Add(new Line(Color.Gray, 60, "Upper Line")); Add(new Line(Color.Gray, 0, "Zero Line")); Lines[0].Pen.DashStyle = DashStyle.Dash; Lines[1].Pen.DashStyle = DashStyle.Dash; Lines[2].Pen.Width = 2; CalculateOnBarClose = false; Overlay = false; PriceTypeSupported = false; #endregion #region Series Initialization stoch1 = new DataSeries(this); stoch2 = new DataSeries(this); JMAstoch1 = new DataSeries(this); JMAstoch2 = new DataSeries(this); #endregion }
public OverlappingMarkedZones() { InitializeComponent(); DataSeries series1 = new DataSeries() { new DataPoint(145), new DataPoint(132), new DataPoint(164), new DataPoint(187), new DataPoint(186), new DataPoint(131), new DataPoint(173), new DataPoint(172), new DataPoint(140), new DataPoint(129), new DataPoint(158), new DataPoint(149) }; series1.Definition = new LineSeriesDefinition(); series1.Definition.Appearance.Fill = new SolidColorBrush(Colors.Black); series1.Definition.Appearance.Stroke = new SolidColorBrush(Colors.Black); series1.Definition.Appearance.PointMark.Stroke = new SolidColorBrush(Colors.Black); radChart.DefaultView.ChartArea.DataSeries.Add(series1); }
void AggregateByRange() { var keys = new string[] { "<4", "4-8", ">8" }; for (int i = 0; i < 3; i++) { var ds = new DataSeries() { ItemsSource = SampleItem.CreateSampleData(100), ValueBinding = new Binding("Value"), Aggregate = Aggregate.Count, Label = "Sample Group " + (i + 1).ToString(), AggregateGroupSelector = RangeSelector }; chart.Data.Children.Add(ds); } chart.Data.ItemNames = keys; // style chart chart.View.AxisY.MajorTickThickness = 0; chart.View.AxisY.MinorTickThickness = 0; chart.View.AxisY.AxisLine = new Line() { StrokeThickness = 0 }; chart.View.AxisX.MajorGridStrokeThickness = 0; chart.View.AxisX.MinorGridStrokeThickness = 0; chart.View.AxisX.MajorTickThickness = 0; chart.View.AxisX.MinorTickThickness = 0; }
/// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(Color.Blue, "EaseOfMovement")); Add(new Line(Color.DarkGray, 0, "ZeroLine")); emv = new DataSeries(this); }
/// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(Color.Orange, "HMA")); Overlay = true; // Plots the indicator on top of price diffSeries = new DataSeries(this); }
public Chart() { InitializeComponent(); _chartByCountry.ChartType = ChartType.Line; _chartByProduct.ChartType = ChartType.Line; dataServiceClient = new DataServiceRef.NORTHWNDEntities(new Uri("http://localhost:50297/NorthWindDataService.svc/")); nwndQuery = dataServiceClient.Invoices; #region DataForCountry-Sales Chart var cntryslschrtdt = GetSalesByCountry(nwndQuery.ToArray().ToList()); DataSeries amtsers = new DataSeries(); amtsers.ValuesSource = cntryslschrtdt.ConvertAll(e => e.Amount).ToArray(); _chartByCountry.Data.Children.Add(amtsers); var xvals = cntryslschrtdt.ConvertAll(e => e.Item).Distinct().ToArray(); _chartByCountry.Data.ItemNames = xvals; _chartByCountry.View.AxisX.Title = CreateTextBlock("Countries"); _chartByCountry.View.AxisX.AnnoAngle = 45; _chartByCountry.View.AxisY.Title = CreateTextBlock("Sales"); #endregion #region DataForProduct-Sales Chart var pdctslchrtdt = GetSalesByProduct(nwndQuery.ToArray().ToList()); DataSeries amtserspd = new DataSeries(); amtserspd.ValuesSource = pdctslchrtdt.ConvertAll(e => e.Amount).ToArray(); _chartByProduct.Data.Children.Add(amtserspd); var xvalspd = pdctslchrtdt.ConvertAll(e => e.Item).Distinct().ToArray(); _chartByProduct.Data.ItemNames = xvalspd; _chartByProduct.View.AxisX.Title = CreateTextBlock("Product"); _chartByProduct.View.AxisX.AnnoAngle = 45; _chartByProduct.View.AxisY.Title = CreateTextBlock("Sales"); #endregion }
protected override void GomOnStartUp() { dsOpen = new DataSeries(this, MaximumBarsLookBack.Infinite); dsHigh = new DataSeries(this, MaximumBarsLookBack.Infinite); dsLow = new DataSeries(this, MaximumBarsLookBack.Infinite); dsClose = new DataSeries(this, MaximumBarsLookBack.Infinite); }
public void SolveDiffEquation(double T, double b, double sigma, double f, int n) { try { double[] u = new double[n + 1]; u[0] = 0; u[n] = 0; var coefficients = FindCoefficients(T, b, sigma, f, n).Reverse().ToArray(); for (int i = 1; i < n; i++) { double sum = 0; for (int j = 1; j < n; j++) { double x = (double)i / n; sum += coefficients[j - 1]*CourantFun(x, n, j); } u[i] = sum; } DataSeries<double, double> fun = new DataSeries<double, double>("u(x)"); for (int i = 0; i < n + 1; i++) { fun.Add(new DataPoint<double, double>() { X = (double)i / n, Y = u[i] }); } exampleChart.Series[0].DataSeries = fun; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(new Pen(Color.Blue, 2), PlotStyle.Bar, "FisherTransform")); tmpSeries = new DataSeries(this); Overlay = false; }
public void SetNewSpan(int span_) { if (m_span == span_ && m_series != null) return; if ((m_base.Data.Length - span_) <= 0) m_span = m_base.Data.Length; else m_span = span_; DataSeries[] series = new DataSeries[m_base.Data.Length - m_span + 1]; double[] data; DateTime[] dates; for (int i = 0; i < series.Length; ++i) { data = new double[m_span]; dates = new DateTime[m_span]; for (int j = 0; j < m_span; ++j) { data[j] = m_base.Data[j + i]; dates[j] = m_base.Dates[j + i]; } series[i] = new DataSeries(dates, data, m_base.PeriodType, m_base.DataType); } m_series = series; reset(); }
/// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Line(Color.DarkGray, 0, "Zero line")); Add(new Plot(Color.Orange, Name)); smoothEma = new DataSeries(this); }
/// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(new Pen(Color.Blue, 2), PlotStyle.Bar, "BOP")); bop = new DataSeries(this); Overlay = false; }
public Chart() { InitializeComponent(); // Clear previous data C1Chart1.Data.Children.Clear(); //IList<string> ProductNames = new List<string>(); //IList<int> PriceX = new List<int>(); ; //using (var ctx = new FinancasDataContext(conn)) //{ // IQueryable<Cadastro> query = ctx.Cadastros.OrderBy(cadastro => Name); // foreach (var item in query) // { // ProductNames.Add(item.Descricao); // PriceX.Add(Convert.ToInt32(item.Valor)); // } //} // // Add Data string[] ProductNames = { "Café", "Almoço", "Combustivel", "Lazer", "Curso", "Condução", "Material", "Academia" }; int[] PriceX = { 80, 400, 20, 60, 150, 300, 130, 500 }; // create single series for product price DataSeries ds1 = new DataSeries(); ds1.Label = "Price X"; //set price data ds1.ValuesSource = PriceX; // add series to the chart C1Chart1.Data.Children.Add(ds1); // add item names C1Chart1.Data.ItemNames = ProductNames; // Set chart type C1Chart1.ChartType = ChartType.Bar; }
/// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "EV")); Overlay = false; CalculateOnBarClose = false; myDataSeries = new DataSeries(this); }
private double markedBarLow = 0; // keep current bar low // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Dot, "SwingPointHigh")); Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Dot, "SwingPointLow")); Overlay = true; dsSwingPoint = new DataSeries(this); markedBarLow = 1200; }
/// <summary> /// This method is used to configure the indicator and is called once before /// any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(Color.Blue, "KAMA")); diffSeries = new DataSeries(this); Overlay = true; }
/// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Line, "VolBucketPlot")); Overlay = false; deltaPrice = new DataSeries(this, MaximumBarsLookBack.Infinite); deltaPriceOverSigmal = new DataSeries(this, MaximumBarsLookBack.Infinite); vb = new DataSeries(this, MaximumBarsLookBack.Infinite); }
// User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.TriangleUp, "Bull180")); Overlay = true; Range = new DataSeries(this); ElephantBear = new DataSeries(this); }
public static void FillWithSampleBubbleData(DataSeries series) { series.Add(new DataPoint { YValue = 20, BubbleSize = 40 }); series.Add(new DataPoint { YValue = 40, BubbleSize = 80 }); series.Add(new DataPoint { YValue = 80, BubbleSize = 20 }); series.Add(new DataPoint { YValue = 60, BubbleSize = 100 }); series.Add(new DataPoint { YValue = 10, BubbleSize = 20 }); }
public DataSeriesEvaluator(DateTime[] dates_, double[] data_, string name_, DataSeriesType type_) { checkInputs(dates_, data_); m_name = name_; m_dataType = type_; m_all = new DataSeries(dates_, data_,Period.Daily,m_dataType); Evaluate(dates_[0],dates_[dates_.Length-1]); }
/// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(Color.Green, "DMI")); dmMinus = new DataSeries(this); dmPlus = new DataSeries(this); tr = new DataSeries(this); }
/// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(Color.Green, PlotStyle.Line, "RSS")); Add(new Line(Color.LightSlateGray, 20, "Lower")); Add(new Line(Color.LightSlateGray, 80, "Upper")); spread = new DataSeries(this); rs = new DataSeries(this); }
// User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Line, "BuySignal")); //Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Line, "CummRSIPlot")); CummRSI_DS = new DataSeries(this, MaximumBarsLookBack.Infinite); Overlay = false; }
} //does not check allocation! //constructors //Default constructor public DataSeries() { size = 0; //when 0, values is unallocated. values = null; independentVariable = null; }
public void UpdateChart(List <int> values, String titulo) { #region Setear Properties al Charter // Setear ancho y altura al chart Title title = new Title(); title.Text = titulo; title.FontSize = 20; title.FontFamily = new FontFamily("Arial"); title.FontColor = new SolidColorBrush(Color.FromArgb((byte)255, (byte)0, (byte)0, (byte)0)); title.Margin = new Thickness(0, 40, 0, 0); //title.MouseLeftButtonDown += new MouseButtonEventHandler(title_MouseLeftButtonDown); // Agregar el título instanciado a la collección de títulos del chart MyChart.Titles.Clear(); MyChart.Titles.Add(title); // Crear Axis X Axis axisX = new Axis(); // Setear propiedades al axis X axisX.Title = "Tendencias"; //axisX.MouseLeftButtonDown += new MouseButtonEventHandler(axis_MouseLeftButtonDown); axisX.TitleFontColor = new SolidColorBrush(Color.FromArgb((byte)255, (byte)0, (byte)0, (byte)0)); axisX.TitleFontSize = 25; axisX.TitleFontFamily = new FontFamily("Arial"); //axisX.AxisLabels.FontColor = new SolidColorBrush(Color.FromArgb((byte)255, (byte)0, (byte)0, (byte)0)); axisX.AxisLabels.FontColor = new SolidColorBrush(Colors.Red); // Agregar el axis instanciado a la colección de AxesX MyChart.AxesX.Clear(); MyChart.AxesX.Add(axisX); // Crear axisY Axis axisY = new Axis(); // Setear properties al axis Y axisY.Title = "Cantidad de Talentos"; //axisY.MouseLeftButtonDown += new MouseButtonEventHandler(axis_MouseLeftButtonDown); axisY.TitleFontColor = new SolidColorBrush(Color.FromArgb((byte)255, (byte)47, (byte)79, (byte)79)); axisY.TitleFontSize = 25; axisY.TitleFontFamily = new FontFamily("Arial"); axisY.AxisLabels.FontColor = new SolidColorBrush(Color.FromArgb((byte)255, (byte)232, (byte)137, (byte)25)); // Agregar axis a la colección de AxesY MyChart.AxesY.Clear(); MyChart.AxesY.Add(axisY); #region Crear Datapoints para cada tendencia o color y agregarlos a DataSeries MyChart.Series.Clear(); DataSeries dataSeries = new DataSeries(); if (values[0] != 0) { // Crear un DataPoint DataPoint dataPoint1; dataPoint1 = new DataPoint(); dataPoint1.AxisXLabel = "Orientado a la ejecución"; dataPoint1.YValue = values[0]; //// setear un color gradient LinearGradientBrush lgb = new LinearGradientBrush(); GradientStopCollection lista = new GradientStopCollection(); GradientStop stop = new GradientStop(); stop.Color = Color.FromArgb((byte)255, (byte)234, (byte)102, (byte)0); stop.Offset = 1.0; lgb.GradientStops.Add(stop); GradientStop stop3 = new GradientStop(); stop3.Color = Color.FromArgb((byte)255, (byte)255, (byte)102, (byte)0); //**** stop3.Offset = 0.8; lgb.GradientStops.Add(stop3); GradientStop stop4 = new GradientStop(); stop4.Color = Color.FromArgb((byte)255, (byte)255, (byte)122, (byte)0); stop4.Offset = 0.5; lgb.GradientStops.Add(stop4); //stop.Color = Color.FromArgb((byte)255, (byte)255, (byte)102, (byte)0); //stop.Offset = 1; //lgb.GradientStops.Add(stop); dataPoint1.Color = lgb; dataPoint1.Width = 50; //dataPoint1.MouseLeftButtonDown += new MouseButtonEventHandler(DataPoint_MouseEnter); dataSeries.DataPoints.Add(dataPoint1); } if (values[1] != 0) { DataPoint dataPoint2; dataPoint2 = new DataPoint(); dataPoint2.AxisXLabel = "Orientado al pensamiento"; dataPoint2.YValue = values[1]; // set un color gradiente LinearGradientBrush Azul = new LinearGradientBrush(); GradientStop stopAzul1 = new GradientStop(); stopAzul1.Color = Color.FromArgb((byte)255, (byte)62, (byte)105, (byte)179);//Color.FromArgb((byte)255, (byte)0, (byte)0, (byte)255); stopAzul1.Offset = 0; Azul.GradientStops.Add(stopAzul1); //GradientStop stopAzul2 = new GradientStop(); //stopAzul2.Color = Color.FromArgb((byte)255, (byte)0, (byte)0, (byte)205); //stopAzul2.Offset = 0.6; //Azul.GradientStops.Add(stopAzul2); //GradientStop stopAzul3 = new GradientStop(); // stopAzul3.Color =Color.FromArgb((byte)255, (byte)65, (byte)105, (byte)225); //stopAzul3.Offset = 0.9; //Azul.GradientStops.Add(stopAzul3); GradientStop stopAzul4 = new GradientStop(); //stopAzul4.Color = Color.FromArgb((byte)255, (byte)100, (byte)149, (byte)237); stopAzul4.Color = Color.FromArgb((byte)255, (byte)62, (byte)105, (byte)179); stopAzul4.Offset = 1.0; Azul.GradientStops.Add(stopAzul4); dataPoint2.Color = Azul; //dataPoint2.MouseLeftButtonDown += new MouseButtonEventHandler(DataPoint_MouseEnter); dataSeries.DataPoints.Add(dataPoint2); } if (values[2] != 0) { DataPoint dataPoint3; dataPoint3 = new DataPoint(); dataPoint3.AxisXLabel = "Orientado a la innovación"; dataPoint3.YValue = values[2]; // setear un color degradado LinearGradientBrush Amarillo = new LinearGradientBrush(); GradientStop stopAmarillo2 = new GradientStop(); stopAmarillo2.Color = Color.FromArgb((byte)255, (byte)255, (byte)204, (byte)0);//******* stopAmarillo2.Offset = 0.45; Amarillo.GradientStops.Add(stopAmarillo2); GradientStop stopAmarillo3 = new GradientStop(); stopAmarillo3.Color = Color.FromArgb((byte)255, (byte)255, (byte)251, (byte)0); stopAmarillo3.Offset = 0.75; Amarillo.GradientStops.Add(stopAmarillo3); GradientStop stopAmarillo4 = new GradientStop(); stopAmarillo4.Color = Color.FromArgb((byte)255, (byte)255, (byte)230, (byte)0); stopAmarillo4.Offset = 1.0; Amarillo.GradientStops.Add(stopAmarillo4); dataPoint3.Color = Amarillo; //dataPoint3.MouseLeftButtonDown += new MouseButtonEventHandler(DataPoint_MouseEnter); dataSeries.DataPoints.Add(dataPoint3); } if (values[3] != 0) { DataPoint dataPoint4; dataPoint4 = new DataPoint(); dataPoint4.AxisXLabel = "Orientado al liderazgo"; dataPoint4.YValue = values[3]; //setear un color degradado LinearGradientBrush Guinda = new LinearGradientBrush(); GradientStop stopGuinda1 = new GradientStop(); stopGuinda1.Color = Color.FromArgb((byte)255, (byte)125, (byte)0, (byte)54); stopGuinda1.Offset = 0.2; Guinda.GradientStops.Add(stopGuinda1); GradientStop stopGuinda2 = new GradientStop(); stopGuinda2.Color = Color.FromArgb((byte)255, (byte)164, (byte)0, (byte)54); stopGuinda2.Offset = 0.4; Guinda.GradientStops.Add(stopGuinda2); GradientStop stopGuinda3 = new GradientStop(); stopGuinda3.Color = Color.FromArgb((byte)255, (byte)185, (byte)0, (byte)54); stopGuinda3.Offset = 0.6; Guinda.GradientStops.Add(stopGuinda3); GradientStop stopGuinda4 = new GradientStop(); stopGuinda4.Color = Color.FromArgb((byte)255, (byte)125, (byte)15, (byte)54); stopGuinda4.Offset = 0.9; Guinda.GradientStops.Add(stopGuinda4); dataPoint4.Color = Guinda; //dataPoint4.MouseLeftButtonDown += new MouseButtonEventHandler(DataPoint_MouseEnter); dataSeries.DataPoints.Add(dataPoint4); } if (values[4] != 0) { DataPoint dataPoint5; dataPoint5 = new DataPoint(); dataPoint5.AxisXLabel = "Orientado a las personas"; dataPoint5.YValue = values[4]; //setear un color degradado LinearGradientBrush Rojo = new LinearGradientBrush(); GradientStop stopRojo1 = new GradientStop(); stopRojo1.Color = Color.FromArgb((byte)255, (byte)204, (byte)0, (byte)0); stopRojo1.Offset = 0.3; Rojo.GradientStops.Add(stopRojo1); GradientStop stopRojo4 = new GradientStop(); stopRojo4.Color = Color.FromArgb((byte)255, (byte)255, (byte)0, (byte)0); stopRojo4.Offset = 0.65; Rojo.GradientStops.Add(stopRojo4); GradientStop stopRojo5 = new GradientStop(); stopRojo5.Color = Color.FromArgb((byte)255, (byte)204, (byte)0, (byte)0); stopRojo5.Offset = 0.85; Rojo.GradientStops.Add(stopRojo5); dataPoint5.Color = Rojo; //dataPoint5.MouseLeftButtonDown += new MouseButtonEventHandler(DataPoint_MouseEnter); dataSeries.DataPoints.Add(dataPoint5); } if (values[5] != 0) { DataPoint dataPoint6; dataPoint6 = new DataPoint(); dataPoint6.AxisXLabel = "Orientado a la estructura"; dataPoint6.YValue = values[5]; //setear un color degradado LinearGradientBrush Verde = new LinearGradientBrush(); GradientStop stopVerde1 = new GradientStop(); stopVerde1.Color = Color.FromArgb((byte)255, (byte)0, (byte)128, (byte)0); stopVerde1.Offset = 0; Verde.GradientStops.Add(stopVerde1); GradientStop stopVerde2 = new GradientStop(); stopVerde2.Color = Color.FromArgb((byte)255, (byte)0, (byte)160, (byte)0); stopVerde2.Offset = 0.4; Verde.GradientStops.Add(stopVerde2); GradientStop stopVerde3 = new GradientStop(); stopVerde3.Color = Color.FromArgb((byte)255, (byte)0, (byte)228, (byte)0); stopVerde3.Offset = 0.7; Verde.GradientStops.Add(stopVerde3); GradientStop stopVerde4 = new GradientStop(); stopVerde4.Color = Color.FromArgb((byte)255, (byte)0, (byte)180, (byte)0); stopVerde4.Offset = 0.9; Verde.GradientStops.Add(stopVerde4); dataPoint6.Color = Verde; //dataPoint6.MouseLeftButtonDown += new MouseButtonEventHandler(DataPoint_MouseEnter); dataSeries.DataPoints.Add(dataPoint6); } #endregion dataSeries.RenderAs = RenderAs.Pie; dataSeries.Bevel = true; dataSeries.Height = 350; dataSeries.Width = 450; dataSeries.Margin = new Thickness(0, -200, 0, 0); // Agregar dataSeries a la colección de Series MyChart.Series.Add(dataSeries); #endregion // Agregar el chart a LayoutRoot //LayoutRoot.Children.Add(charter); }
public static double resistance(this DataSeries dataseries, int period) { return(dataseries.Maximum(period)); }
private double GetMagnitude(DataSeries rms) { return(rms.DataPoints.Min(dataPoint => dataPoint.Value)); }
/// <summary> /// (dataSeries.RenderAs == RenderAs.Radar || dataSeries.RenderAs == RenderAs.Polar); /// </summary> /// <param name="dataSeries"></param> /// <returns></returns> public static Boolean IsCircularCType(DataSeries dataSeries) { return(dataSeries.RenderAs == RenderAs.Radar || dataSeries.RenderAs == RenderAs.Polar); }
public ActionResult Index(string projectGuid) { //Load project info var projectIds = m_dbAdapter.Authority.GetAuthorizedProjectIds(); var projects = m_dbAdapter.Project.GetProjects(projectIds); //Init view model var viewModel = new PaymentHistoryViewModel(); Project project = null; if (string.IsNullOrEmpty(projectGuid)) { if (projects.Count == 0) { return(View(viewModel)); } project = projects[0]; } else { project = projects.Single(x => x.ProjectGuid == projectGuid); } //Load project Model info if (project.ModelId > 0) { project.Model = m_dbAdapter.Project.GetModel(project.ModelId); } viewModel.CurrentProject = project; viewModel.Datasets = new List <DatasetViewModel>(); viewModel.Projects = projects.ConvertAll(Toolkit.ConvertProject); //Load note info var notes = m_dbAdapter.Dataset.GetNotes(project.ProjectId); var cnabsNotes = new ProjectLogicModel(CurrentUserName, project).Notes; var noteDict = Toolkit.GetNoteDictionary(project, notes, cnabsNotes); notes.ForEach(x => CommUtils.Assert(noteDict.ContainsKey(x.NoteId), "找不到Note信息,noteId={0},noteName={1},ProjectId={2},SecurityCode={3},ShortName={4}", x.NoteId, x.NoteName, x.ProjectId, x.SecurityCode, x.ShortName)); viewModel.NoteInfos = notes.ConvertAll(x => noteDict[x.NoteId]); var logicModel = new ProjectLogicModel(CurrentUserName, project.ProjectGuid); DateTime[] paymentDates; try { paymentDates = logicModel.DealSchedule.DurationPeriods.Select(x => x.PaymentDate).ToArray(); } catch (ApplicationException) { //没有偿付模型 return(View(viewModel)); } var datasetSchedule = logicModel.DealSchedule.GetByPaymentDay(DateTime.Now); //Load dataset info while (datasetSchedule != null) { if (datasetSchedule.Dataset.Instance != null) { if (datasetSchedule.Dataset.ReinvestmentCsv != null) { //不处理循环购买类产品的偿付历史相关 viewModel.HasReinvestmentInfo = true; return(View(viewModel)); } var noteDatas = m_dbAdapter.Dataset.GetNoteDatas(datasetSchedule.Dataset.Instance.DatasetId); var datasetViewModel = Toolkit.GetDatasetViewModel(datasetSchedule.Dataset.Instance, paymentDates, noteDict, noteDatas); viewModel.Datasets.Add(datasetViewModel); } datasetSchedule = datasetSchedule.Previous; } var allPaymentDays = new List <DateTime>(); if (project.CnabsDealId.HasValue) { allPaymentDays = m_dbAdapter.Model.GetPaymentDates(project.CnabsDealId.Value); } else { if (logicModel.DealSchedule.Instanse != null) { allPaymentDays = logicModel.DealSchedule.Instanse.PaymentDates.ToList(); } } //Load asset cashflow data try { viewModel.AssetDatasets = new List <AssetDatasetViewModel>(); viewModel.AssetDatasets = GetAssetCashflow(project.ProjectId, paymentDates, allPaymentDays); } catch (ApplicationException e) { viewModel.ExceptionMessage = e.Message + System.Environment.NewLine + e.StackTrace; } Dictionary <string, List <Vector> > series = new Dictionary <string, List <Vector> >(); series["本金"] = new List <Vector>(); series["利息"] = new List <Vector>(); foreach (var assetDataset in viewModel.AssetDatasets) { var sumInfo = assetDataset.SumAsset; series["本金"].Add(new Vector(assetDataset.PaymentDay, decimal.Parse(sumInfo.Principal.ToString("n2")))); series["利息"].Add(new Vector(assetDataset.PaymentDay, decimal.Parse(sumInfo.Interest.ToString("n2")))); } var dataSeriesList = new List <DataSeries>(); foreach (var key in series.Keys) { var ds = new DataSeries(); ds.name = key; ds.data = series[key]; dataSeriesList.Add(ds); } viewModel.AssetChartData = JsonConvert.SerializeObject(dataSeriesList); return(View(viewModel)); }
/// <summary> /// Get visual for DataSeries /// </summary> /// <param name="chart">Chart</param> /// <param name="width">Width</param> /// <param name="height">Height</param> /// <param name="series">DataSeries</param> /// <param name="circularPlotDetails">CircularPlotDetails</param> /// <returns>Canvas</returns> private static Canvas GetDataSeriesVisual(Chart chart, Double width, Double height, DataSeries series, CircularPlotDetails circularPlotDetails) { Canvas visual = new Canvas(); Canvas radarCanvas = new Canvas(); Canvas labelCanvas = new Canvas(); if ((Boolean)series.Enabled) { PlotGroup plotGroup = series.PlotGroup; List <Point> listOfRadarPoints = new List <Point>(); series.Faces = new Faces(); CalculateRadarPoints(series, ref listOfRadarPoints, plotGroup, circularPlotDetails); DrawMarkers(series, labelCanvas, chart, width, height, circularPlotDetails.Center); DrawDataSeriesPolygon(listOfRadarPoints, series, radarCanvas); } // Apply animation for DataSeries if (chart._internalAnimationEnabled) { if (series.Storyboard == null) { series.Storyboard = new Storyboard(); } // Apply animation to radar visual series.Storyboard = AnimationHelper.ApplyOpacityAnimation(radarCanvas, series, series.Storyboard, 1, 1, 0, 1); // Apply animation to the marker and labels series.Storyboard = AnimationHelper.ApplyOpacityAnimation(labelCanvas, series, series.Storyboard, 1.5, 1, 0, 1); } visual.Children.Add(radarCanvas); visual.Children.Add(labelCanvas); return(visual); }
/// <summary> /// 显示工单跳线领取状况 列表显示 /// </summary> /// <param name="_Order"></param> /// <param name="temds"></param> /// <param name="OrderInfoChart"></param> private void ShowInfo_MaterialControl(Maticsoft.Model.WorkOrder _Order, DataSet temds, DataSeries OrderInfoChart) { MCP_CS.Cls_OrderInfo.Order = _WorkOrder.GetModel(txb_Info_OrderID.Text); string[] temOrd = new string[1] { txb_Info_OrderID.Text }; lsv_ShowOrderMaterialInfo.DataContext = MCP_CS.Cls_OrderInfo.GetOrderInfo(temOrd); dgv_OrderMaterialInfo.ItemsSource = MCP_CS.Cls_OrderInfo.GetOrderMaterialInfo.Tables[0].DefaultView; }
public BasicSARRule(DataBars db, double optInAcc, double optLnMax) { sar = new Indicators.SAR(db, optInAcc, optLnMax, "sar"); close = db.Close; }
public void Parse(string filePath) { Schema schema = m_parser.Schema; Meter meter = new Meter(); meter.MeterLocation = new MeterLocation(); meter.Channels = new List <Channel>(); meter.AssetKey = schema.DeviceID; meter.Name = schema.DeviceID; meter.ShortName = schema.DeviceID.Substring(0, Math.Min(schema.DeviceID.Length, 50)); MeterLocation meterLocation = meter.MeterLocation; meterLocation.Meters = new List <Meter>() { meter }; meterLocation.AssetKey = schema.StationName; meterLocation.Name = schema.StationName; meterLocation.ShortName = schema.StationName.Substring(0, Math.Min(schema.StationName.Length, 50)); meterLocation.Description = schema.StationName; foreach (AnalogChannel analogChannel in schema.AnalogChannels) { Channel channel = ParseSeries(analogChannel); channel.Meter = meter; DataSeries dataSeries = new DataSeries(); dataSeries.SeriesInfo = channel.Series[0]; meter.Channels.Add(channel); while (m_meterDataSet.DataSeries.Count <= analogChannel.Index) { m_meterDataSet.DataSeries.Add(new DataSeries()); } m_meterDataSet.DataSeries[analogChannel.Index] = dataSeries; } foreach (DigitalChannel digitalChannel in schema.DigitalChannels) { Channel channel = ParseSeries(digitalChannel); channel.Meter = meter; DataSeries dataSeries = new DataSeries(); dataSeries.SeriesInfo = channel.Series[0]; meter.Channels.Add(channel); while (m_meterDataSet.Digitals.Count <= digitalChannel.Index) { m_meterDataSet.Digitals.Add(new DataSeries()); } m_meterDataSet.Digitals[digitalChannel.Index] = dataSeries; } try { while (m_parser.ReadNext()) { for (int i = 0; i < schema.AnalogChannels.Length; i++) { int seriesIndex = schema.AnalogChannels[i].Index; string units = schema.AnalogChannels[i].Units.ToUpper(); double multiplier = (units.Contains("KA") || units.Contains("KV")) ? 1000.0D : 1.0D; m_meterDataSet.DataSeries[seriesIndex].DataPoints.Add(new DataPoint() { Time = m_parser.Timestamp, Value = multiplier * m_parser.PrimaryValues[i] }); } for (int i = 0; i < schema.DigitalChannels.Length; i++) { int valuesIndex = schema.TotalAnalogChannels + i; int seriesIndex = schema.DigitalChannels[i].Index; m_meterDataSet.Digitals[seriesIndex].DataPoints.Add(new DataPoint() { Time = m_parser.Timestamp, Value = m_parser.Values[valuesIndex] }); } } } catch (InvalidOperationException ex) { Log.Warn(ex.Message, ex); } m_meterDataSet.Meter = meter; }
/// <summary> /// dataSeries.RenderAs == RenderAs.Area /// || dataSeries.RenderAs == RenderAs.StackedArea /// || dataSeries.RenderAs == RenderAs.StackedArea100 /// </summary> /// <param name="dataSeries"></param> /// <returns></returns> public static Boolean IsAreaCType(DataSeries dataSeries) { return(dataSeries.RenderAs == RenderAs.Area || dataSeries.RenderAs == RenderAs.StackedArea || dataSeries.RenderAs == RenderAs.StackedArea100); }
/// <summary> /// Calculate radar points /// </summary> /// <param name="series"></param> /// <param name="listOfRadarPoints"></param> /// <param name="plotGroup"></param> /// <param name="circularPlotDetails"></param> private static void CalculateRadarPoints(DataSeries series, ref List <Point> listOfRadarPoints, PlotGroup plotGroup, CircularPlotDetails circularPlotDetails) { DataPoint currDataPoint; DataPoint nextDataPoint; DataPoint preDataPoint = null; DataPoint firstDataPoint = series.InternalDataPoints[0]; DataPoint lastDataPoint = series.InternalDataPoints[series.InternalDataPoints.Count - 1]; for (Int32 i = 0; i < series.InternalDataPoints.Count - 1; i++) { currDataPoint = series.InternalDataPoints[i]; Double dataPointIndex = series.InternalDataPoints.IndexOf(currDataPoint); if (!(Boolean)currDataPoint.Enabled) { continue; } nextDataPoint = series.InternalDataPoints[i + 1]; Point dataPointPosition = GetRadarPoint(circularPlotDetails, plotGroup, currDataPoint, dataPointIndex); if (!Double.IsNaN(currDataPoint.InternalYValue) && (currDataPoint.InternalYValue > plotGroup.AxisY.InternalAxisMaximum || currDataPoint.InternalYValue < plotGroup.AxisY.InternalAxisMinimum)) { currDataPoint._visualPosition = new Point(Double.NaN, Double.NaN); listOfRadarPoints.Add(new Point(circularPlotDetails.Center.X, circularPlotDetails.Center.Y)); } else if (currDataPoint == firstDataPoint && (nextDataPoint != null && Double.IsNaN(nextDataPoint.InternalYValue)) && (lastDataPoint != null && !Double.IsNaN(lastDataPoint.InternalYValue))) { listOfRadarPoints.Add(dataPointPosition); currDataPoint._visualPosition = dataPointPosition; } else if (!Double.IsNaN(currDataPoint.InternalYValue) && ((preDataPoint != null && !Double.IsNaN(preDataPoint.InternalYValue)) || (nextDataPoint != null && !Double.IsNaN(nextDataPoint.InternalYValue)))) { listOfRadarPoints.Add(dataPointPosition); currDataPoint._visualPosition = dataPointPosition; } else { currDataPoint._visualPosition = new Point(Double.NaN, Double.NaN); listOfRadarPoints.Add(new Point(circularPlotDetails.Center.X, circularPlotDetails.Center.Y)); } preDataPoint = series.InternalDataPoints[i]; if (i == series.InternalDataPoints.Count - 2) // If next DataPoint is the last DataPoint { dataPointIndex = series.InternalDataPoints.IndexOf(nextDataPoint); dataPointPosition = GetRadarPoint(circularPlotDetails, plotGroup, nextDataPoint, dataPointIndex); if (!Double.IsNaN(nextDataPoint.InternalYValue) && (nextDataPoint.InternalYValue > plotGroup.AxisY.InternalAxisMaximum || nextDataPoint.InternalYValue < plotGroup.AxisY.InternalAxisMinimum)) { nextDataPoint._visualPosition = new Point(Double.NaN, Double.NaN); listOfRadarPoints.Add(new Point(circularPlotDetails.Center.X, circularPlotDetails.Center.Y)); } else if (!Double.IsNaN(nextDataPoint.InternalYValue) && (preDataPoint != null && !Double.IsNaN(preDataPoint.InternalYValue)) || (lastDataPoint != null && !Double.IsNaN(lastDataPoint.InternalYValue))) { listOfRadarPoints.Add(dataPointPosition); nextDataPoint._visualPosition = dataPointPosition; } else { nextDataPoint._visualPosition = new Point(Double.NaN, Double.NaN); listOfRadarPoints.Add(new Point(circularPlotDetails.Center.X, circularPlotDetails.Center.Y)); } if (series.InternalDataPoints.Count < circularPlotDetails.ListOfPoints4CircularAxis.Count) { listOfRadarPoints.Add(new Point(circularPlotDetails.Center.X, circularPlotDetails.Center.Y)); } } } }
//Linear setup constructor for independent variables public DataSeries(float start, float end, uint numberOfPoints) { size = 0; //when 0, values is unallocated. independentVariable = null; setupLinear(start, end, numberOfPoints); }
virtual public bool CopyPeriod(DataSeries Series, double From, double To, int extra) { print("Warning: CopyPeriod is ignorded since data series: " + NodeName + " is read only!"); return(false); }
public bool CopyPeriod(DataSeries Series, double From, double To) { return(CopyPeriod(Series, From, To, 0)); }
internal static List <DataPoint> GetDataPointsUnderViewPort(DataSeries dataSeries, Boolean isUsedForAxisRange) { if (dataSeries.PlotGroup.AxisY.ViewportRangeEnabled) { PlotGroup plotGroup = dataSeries.PlotGroup; Axis axisX = plotGroup.AxisX; List <DataPoint> viewPortDataPoints; Double minXValueRangeOfViewPort = axisX._numericViewMinimum; Double maxXValueRangeOfViewPort = axisX._numericViewMaximum; //Double offset = Math.Abs(minXValueRangeOfViewPort - maxXValueRangeOfViewPort) * .4; //minXValueRangeOfViewPort -= offset; //maxXValueRangeOfViewPort += offset; if (!isUsedForAxisRange) { var leftDataPoints = (from dp in dataSeries.InternalDataPoints where (dp.InternalXValue < minXValueRangeOfViewPort) select dp.InternalXValue); var rightDataPoints = (from dp in dataSeries.InternalDataPoints where (dp.InternalXValue > maxXValueRangeOfViewPort) select dp.InternalXValue); if (leftDataPoints.Count() > 0) { minXValueRangeOfViewPort = leftDataPoints.Max(); } if (rightDataPoints.Count() > 0) { maxXValueRangeOfViewPort = rightDataPoints.Min(); } } viewPortDataPoints = dataSeries.InternalDataPoints .Where(d => d.InternalXValue >= minXValueRangeOfViewPort && d.InternalXValue <= maxXValueRangeOfViewPort).ToList(); if (viewPortDataPoints.Count <= 3) { var leftDataPoints = (from dp in dataSeries.InternalDataPoints where (dp.InternalXValue < minXValueRangeOfViewPort) orderby dp.InternalXValue select dp); List <DataPoint> rightDataPoints = (from dp in dataSeries.InternalDataPoints where (dp.InternalXValue > maxXValueRangeOfViewPort) orderby dp.InternalXValue select dp).ToList(); if (leftDataPoints.Count() > 0) { viewPortDataPoints.Insert(0, leftDataPoints.Last()); } if (rightDataPoints.Count > 0) { viewPortDataPoints.Add(rightDataPoints[0]); } if (rightDataPoints.Count > 1) { viewPortDataPoints.Add(rightDataPoints[1]); } if (rightDataPoints.Count > 2) { viewPortDataPoints.Add(rightDataPoints[2]); } } return(viewPortDataPoints); } else { return(dataSeries.InternalDataPoints); } }
public MainWindow() { InitializeComponent(); telerikChart.DefaultView.ChartArea.AxisY.IsInverse = true; telerikChart.DefaultView.ChartArea.AxisX.IsInverse = true; //Line Chart DataSeries lineSeries = new DataSeries(); lineSeries.LegendLabel = "Turnover"; lineSeries.Definition = new LineSeriesDefinition(); lineSeries.Add(new DataPoint() { YValue = 154, XCategory = "Jan" }); lineSeries.Add(new DataPoint() { YValue = 138, XCategory = "Feb" }); lineSeries.Add(new DataPoint() { YValue = 143, XCategory = "Mar" }); lineSeries.Add(new DataPoint() { YValue = 120, XCategory = "Apr" }); lineSeries.Add(new DataPoint() { YValue = 135, XCategory = "May" }); lineSeries.Add(new DataPoint() { YValue = 125, XCategory = "Jun" }); lineSeries.Add(new DataPoint() { YValue = 179, XCategory = "Jul" }); lineSeries.Add(new DataPoint() { YValue = 170, XCategory = "Aug" }); lineSeries.Add(new DataPoint() { YValue = 198, XCategory = "Sep" }); lineSeries.Add(new DataPoint() { YValue = 187, XCategory = "Oct" }); lineSeries.Add(new DataPoint() { YValue = 193, XCategory = "Nov" }); lineSeries.Add(new DataPoint() { YValue = 176, XCategory = "Dec" }); telerikChart.DefaultView.ChartArea.DataSeries.Add(lineSeries); //Bar Chart DataSeries barSeries = new DataSeries(); barSeries.LegendLabel = "Expenses"; barSeries.Definition = new BarSeriesDefinition(); barSeries.Add(new DataPoint() { YValue = 45, XCategory = "Jan" }); barSeries.Add(new DataPoint() { YValue = 48, XCategory = "Feb" }); barSeries.Add(new DataPoint() { YValue = 53, XCategory = "Mar" }); barSeries.Add(new DataPoint() { YValue = 41, XCategory = "Apr" }); barSeries.Add(new DataPoint() { YValue = 32, XCategory = "May" }); barSeries.Add(new DataPoint() { YValue = 28, XCategory = "Jun" }); barSeries.Add(new DataPoint() { YValue = 63, XCategory = "Jul" }); barSeries.Add(new DataPoint() { YValue = 74, XCategory = "Aug" }); barSeries.Add(new DataPoint() { YValue = 77, XCategory = "Sep" }); barSeries.Add(new DataPoint() { YValue = 85, XCategory = "Oct" }); barSeries.Add(new DataPoint() { YValue = 89, XCategory = "Nov" }); barSeries.Add(new DataPoint() { YValue = 80, XCategory = "Dec" }); telerikChart.DefaultView.ChartArea.DataSeries.Add(barSeries); }
/// <summary> /// (dataSeries.RenderAs == RenderAs.CandleStick || dataSeries.RenderAs == RenderAs.Stock); /// </summary> /// <param name="dataSeries"></param> /// <returns></returns> public static Boolean IsFinancialCType(DataSeries dataSeries) { return(dataSeries.RenderAs == RenderAs.CandleStick || dataSeries.RenderAs == RenderAs.Stock); }
//柱 public void CreateChartColumn(string name, string[] valuex, int[] valuey) { //创建一个图标 Chart chart = new Chart(); //设置图标的宽度和高度 chart.Width = 1130; chart.Height = 480; chart.Margin = new Thickness(350, 250, 10, 5); //是否启用打印和保持图片 chart.ToolBarEnabled = false; //设置图标的属性 chart.ScrollingEnabled = false; //是否启用或禁用滚动 chart.View3D = true; //3D效果显示 //创建一个标题的对象 Title title = new Title(); //设置标题的名称 title.Text = Name; title.Padding = new Thickness(0, 10, 5, 0); //向图标添加标题 chart.Titles.Add(title); Axis yAxis = new Axis(); //设置图标中Y轴的最小值永远为0 yAxis.AxisMinimum = 0; //设置图表中Y轴的后缀 yAxis.Suffix = "次"; chart.AxesY.Add(yAxis); // 创建一个新的数据线。 DataSeries dataSeries = new DataSeries(); // 设置数据线的格式 dataSeries.RenderAs = RenderAs.StackedColumn;//柱状Stacked // 设置数据点 DataPoint dataPoint; for (int i = 0; i < arrayNo.Length; i++) { // 创建一个数据点的实例。 dataPoint = new DataPoint(); // 设置X轴点 dataPoint.AxisXLabel = arrayDate[i]; //设置Y轴点 dataPoint.YValue = double.Parse(arrayNo[i].ToString()); //添加一个点击事件 dataPoint.MouseLeftButtonDown += new MouseButtonEventHandler(dataPoint_MouseLeftButtonDown); //添加数据点 dataSeries.DataPoints.Add(dataPoint); } // 添加数据线到数据序列。 chart.Series.Add(dataSeries); //将生产的图表增加到Grid,然后通过Grid添加到上层Grid. Grid gr = new Grid(); gr.Children.Add(chart); Simon.Children.Add(gr); }
internal static void UpdateVisualObject(Chart chart, VcProperties property, object newValue, Boolean partialUpdate) { if (!chart._internalPartialUpdateEnabled || Double.IsNaN(chart.ActualWidth) || Double.IsNaN(chart.ActualHeight) || chart.ActualWidth == 0 || chart.ActualHeight == 0) { return; } if (partialUpdate && chart._datapoint2UpdatePartially.Count <= 500) { chart.PARTIAL_DP_RENDER_LOCK = false; Boolean isNeed2UpdateAllSeries = false; List <DataSeries> _dataSeries2UpdateAtSeriesWise = (from value in chart._datapoint2UpdatePartially where value.Key.Parent.RenderAs == RenderAs.Spline || value.Key.Parent.RenderAs == RenderAs.QuickLine select value.Key.Parent).Distinct().ToList(); foreach (DataSeries splineDs in _dataSeries2UpdateAtSeriesWise) { splineDs.UpdateVisual(VcProperties.DataPointUpdate, null); } List <KeyValuePair <DataPoint, VcProperties> > remainingDpInfo = (from dpInfo in chart._datapoint2UpdatePartially where !_dataSeries2UpdateAtSeriesWise.Contains(dpInfo.Key.Parent) select dpInfo).ToList(); // If there is nothing to render anymore if (remainingDpInfo.Count == 0) { return; } foreach (KeyValuePair <DataPoint, VcProperties> dpInfo in remainingDpInfo) { DataPoint dp = dpInfo.Key; if (dp.Parent.RenderAs == RenderAs.Spline || dp.Parent.RenderAs == RenderAs.QuickLine) { isNeed2UpdateAllSeries = false; continue; } if (dpInfo.Value == VcProperties.XValue) { isNeed2UpdateAllSeries = true; break; } PropertyInfo pInfo = dp.GetType().GetProperty(dpInfo.Value.ToString()); newValue = pInfo.GetValue(dp, null); isNeed2UpdateAllSeries = dpInfo.Key.UpdateVisual(dpInfo.Value, newValue, true); if (isNeed2UpdateAllSeries) { break; } } if (!isNeed2UpdateAllSeries) { return; } } chart.ChartArea.PrePartialUpdateConfiguration(chart, Visifire.Charts.ElementTypes.Chart, VcProperties.None, null, null, false, true, true, AxisRepresentations.AxisY, true); Int32 renderedSeriesCount = 0; // Contain count of series that have been already rendered // Contains a list of serties as per the drawing order generated in the plotdetails List <DataSeries> dataSeriesListInDrawingOrder = chart.PlotDetails.SeriesDrawingIndex.Keys.ToList(); List <DataSeries> selectedDataSeries4Rendering; // Contains a list of serries to be rendered in a rendering cycle Int32 currentDrawingIndex; // Drawing index of the selected series RenderAs currentRenderAs; // Rendereas type of the selected series // This loop will select series for rendering and it will repeat until all series have been rendered while (renderedSeriesCount < chart.InternalSeries.Count) { selectedDataSeries4Rendering = new List <DataSeries>(); currentRenderAs = dataSeriesListInDrawingOrder[renderedSeriesCount].RenderAs; currentDrawingIndex = chart.PlotDetails.SeriesDrawingIndex[dataSeriesListInDrawingOrder[renderedSeriesCount]]; for (Int32 i = renderedSeriesCount; i < chart.InternalSeries.Count; i++) { DataSeries ds = dataSeriesListInDrawingOrder[i]; if (currentRenderAs == ds.RenderAs && currentDrawingIndex == chart.PlotDetails.SeriesDrawingIndex[ds]) { selectedDataSeries4Rendering.Add(ds); } } if (selectedDataSeries4Rendering.Count == 0) { break; } chart._toolTip.Hide(); if (selectedDataSeries4Rendering.Count > 0) { if (selectedDataSeries4Rendering[0].ToolTipElement != null) { selectedDataSeries4Rendering[0].ToolTipElement.Hide(); } } chart.ChartArea.DisableIndicators(); switch (currentRenderAs) { case RenderAs.Column: case RenderAs.Bar: ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); break; case RenderAs.Spline: case RenderAs.QuickLine: if (property == VcProperties.Enabled) { ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); } else { foreach (DataSeries ds in selectedDataSeries4Rendering) { UpdateVisualObject(ds.RenderAs, ds, property, newValue, false); } } break; case RenderAs.Line: if (property == VcProperties.Enabled) { ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); } else { foreach (DataSeries ds in selectedDataSeries4Rendering) { LineChart.Update(ds, property, newValue, false); } } break; case RenderAs.StepLine: if (property == VcProperties.Enabled) { ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); } else { foreach (DataSeries ds in selectedDataSeries4Rendering) { StepLineChart.Update(ds, property, newValue, false); } } break; case RenderAs.Point: if (property == VcProperties.ViewportRangeEnabled) { ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); } else { foreach (DataSeries ds in selectedDataSeries4Rendering) { PointChart.Update(ds, property, newValue, false); } } break; case RenderAs.Bubble: if (property == VcProperties.ViewportRangeEnabled) { ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); } else { foreach (DataSeries ds in selectedDataSeries4Rendering) { BubbleChart.Update(ds, property, newValue, false); } } break; case RenderAs.Area: ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); break; case RenderAs.StackedColumn: ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); break; case RenderAs.StackedColumn100: ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); break; case RenderAs.StackedBar: ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); break; case RenderAs.StackedBar100: ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); break; case RenderAs.Pie: //renderedCanvas = PieChart.GetVisualObjectForPieChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled); break; case RenderAs.Doughnut: //renderedCanvas = PieChart.GetVisualObjectForDoughnutChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled); break; case RenderAs.StackedArea: ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); chart.ChartArea.AttachEventsToolTipHref2DataSeries(); break; case RenderAs.StackedArea100: ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); chart.ChartArea.AttachEventsToolTipHref2DataSeries(); break; case RenderAs.SectionFunnel: case RenderAs.StreamLineFunnel: case RenderAs.Pyramid: //renderedCanvas = FunnelChart.GetVisualObjectForFunnelChart(width, height, plotDetails, dataSeriesList4Rendering, chart, animationEnabled, true); break; case RenderAs.Stock: ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); break; case RenderAs.CandleStick: ColumnChart.Update(chart, currentRenderAs, selectedDataSeries4Rendering); break; } renderedSeriesCount += selectedDataSeries4Rendering.Count; } chart.ChartArea.AttachScrollBarOffsetChangedEventWithAxes(); chart.ChartArea.AttachOrDetachIntaractivity(chart.InternalSeries); Visifire.Charts.Chart.SelectDataPoints(chart); //AttachEventsToolTipHref2DataSeries(); }
public void Parse(string filePath) { Meter meter = new Meter(); meter.MeterLocation = new MeterLocation(); meter.Channels = new List <Channel>(); meter.AssetKey = "UNKNOWN"; meter.Name = "Unknown"; meter.Description = "Unknown EMCB"; meter.Make = "Eaton"; meter.Model = "EMCB"; MeterLocation meterLocation = meter.MeterLocation; meterLocation.AssetKey = "UNKNOWN"; meterLocation.Latitude = 0.0D; meterLocation.Longitude = 0.0D; meterLocation.Name = "Unknown"; meterLocation.Description = "Unknown"; Dictionary <string, DataSeries> dataSeriesLookup = new Dictionary <string, DataSeries>(); void AddChannel(string channelName, string type, string characteristic, string phase, Dictionary <string, string> seriesMappings) { Channel channel = new Channel(); channel.Series = new List <Series>(); channel.Meter = meter; channel.Name = channelName; channel.MeasurementType = new MeasurementType() { Name = type }; channel.MeasurementCharacteristic = new MeasurementCharacteristic() { Name = characteristic }; channel.Phase = new Phase() { Name = phase }; channel.HarmonicGroup = 0; if (type == "Voltage") { channel.PerUnitValue = 120.0D; } foreach (KeyValuePair <string, string> mapping in seriesMappings) { string path = mapping.Key; string seriesType = mapping.Value; Series series = new Series(); series.Channel = channel; series.SeriesType = new SeriesType() { Name = seriesType }; channel.Series.Add(series); DataSeries dataSeries = new DataSeries(); dataSeries.SeriesInfo = series; dataSeriesLookup.Add(path, dataSeries); } meter.Channels.Add(channel); } AddChannel("VAN", "Voltage", "RMS", "AN", new Dictionary <string, string>() { { "statistics.voltage.LN.AN.avg", "Average" }, { "statistics.voltage.LN.AN.min", "Minimum" }, { "statistics.voltage.LN.AN.max", "Maxmimum" }, { "voltage.LN.AN", "Values" } }); AddChannel("VBN", "Voltage", "RMS", "BN", new Dictionary <string, string>() { { "statistics.voltage.LN.BN.avg", "Average" }, { "statistics.voltage.LN.BN.min", "Minimum" }, { "statistics.voltage.LN.BN.max", "Maxmimum" }, { "voltage.LN.BN", "Values" } }); AddChannel("VCN", "Voltage", "RMS", "CN", new Dictionary <string, string>() { { "statistics.voltage.LN.CN.avg", "Average" }, { "statistics.voltage.LN.CN.min", "Minimum" }, { "statistics.voltage.LN.CN.max", "Maxmimum" }, { "voltage.LN.CN", "Values" } }); AddChannel("VAB", "Voltage", "RMS", "AB", new Dictionary <string, string>() { { "statistics.voltage.LL.AB.avg", "Average" }, { "statistics.voltage.LL.AB.min", "Minimum" }, { "statistics.voltage.LL.AB.max", "Maxmimum" }, { "voltage.LL.AB", "Values" } }); AddChannel("VBC", "Voltage", "RMS", "BC", new Dictionary <string, string>() { { "statistics.voltage.LL.BC.avg", "Average" }, { "statistics.voltage.LL.BC.min", "Minimum" }, { "statistics.voltage.LL.BC.max", "Maxmimum" }, { "voltage.LL.BC", "Values" } }); AddChannel("VCA", "Voltage", "RMS", "CA", new Dictionary <string, string>() { { "statistics.voltage.LL.CA.avg", "Average" }, { "statistics.voltage.LL.CA.min", "Minimum" }, { "statistics.voltage.LL.CA.max", "Maxmimum" }, { "voltage.LL.CA", "Values" } }); AddChannel("IAN", "Current", "RMS", "AN", new Dictionary <string, string>() { { "statistics.current.A.avg", "Average" }, { "statistics.current.A.min", "Minimum" }, { "statistics.current.A.max", "Maxmimum" }, { "current.A", "Values" } }); AddChannel("IBN", "Current", "RMS", "BN", new Dictionary <string, string>() { { "statistics.current.B.avg", "Average" }, { "statistics.current.B.min", "Minimum" }, { "statistics.current.B.max", "Maxmimum" }, { "current.B", "Values" } }); AddChannel("ICN", "Current", "RMS", "CN", new Dictionary <string, string>() { { "statistics.current.C.avg", "Average" }, { "statistics.current.C.min", "Minimum" }, { "statistics.current.C.max", "Maxmimum" }, { "current.C", "Values" } }); AddChannel("FREQ", "Voltage", "Frequency", "AN", new Dictionary <string, string>() { { "statistics.frequency.avg", "Average" }, { "statistics.frequency.min", "Minimum" }, { "statistics.frequency.max", "Maxmimum" }, { "frequency", "Values" } }); AddChannel("Q1 Active Energy AN", "Energy", "PIntgPos", "AN", new Dictionary <string, string>() { { "energy.q1mJpA", "Total" } }); AddChannel("Q2 Active Energy AN", "Energy", "PIntgNeg", "AN", new Dictionary <string, string>() { { "energy.q2mJpA", "Total" } }); AddChannel("Q3 Active Energy AN", "Energy", "PIntgNeg", "AN", new Dictionary <string, string>() { { "energy.q3mJpA", "Total" } }); AddChannel("Q4 Active Energy AN", "Energy", "PIntgPos", "AN", new Dictionary <string, string>() { { "energy.q4mJpA", "Total" } }); AddChannel("Q1 Active Energy BN", "Energy", "PIntgPos", "BN", new Dictionary <string, string>() { { "energy.q1mJpB", "Total" } }); AddChannel("Q2 Active Energy BN", "Energy", "PIntgNeg", "BN", new Dictionary <string, string>() { { "energy.q2mJpB", "Total" } }); AddChannel("Q3 Active Energy BN", "Energy", "PIntgNeg", "BN", new Dictionary <string, string>() { { "energy.q3mJpB", "Total" } }); AddChannel("Q4 Active Energy BN", "Energy", "PIntgPos", "BN", new Dictionary <string, string>() { { "energy.q4mJpB", "Total" } }); AddChannel("Q1 Active Energy CN", "Energy", "PIntgPos", "CN", new Dictionary <string, string>() { { "energy.q1mJpC", "Total" } }); AddChannel("Q2 Active Energy CN", "Energy", "PIntgNeg", "CN", new Dictionary <string, string>() { { "energy.q2mJpC", "Total" } }); AddChannel("Q3 Active Energy CN", "Energy", "PIntgNeg", "CN", new Dictionary <string, string>() { { "energy.q3mJpC", "Total" } }); AddChannel("Q4 Active Energy CN", "Energy", "PIntgPos", "CN", new Dictionary <string, string>() { { "energy.q4mJpC", "Total" } }); AddChannel("Q1 Reactive Energy AN", "Energy", "QIntgPos", "AN", new Dictionary <string, string>() { { "energy.q1mVARspA", "Total" } }); AddChannel("Q2 Reactive Energy AN", "Energy", "QIntgPos", "AN", new Dictionary <string, string>() { { "energy.q2mVARspA", "Total" } }); AddChannel("Q3 Reactive Energy AN", "Energy", "QIntgNeg", "AN", new Dictionary <string, string>() { { "energy.q3mVARspA", "Total" } }); AddChannel("Q4 Reactive Energy AN", "Energy", "QIntgNeg", "AN", new Dictionary <string, string>() { { "energy.q4mVARspA", "Total" } }); AddChannel("Q1 Reactive Energy BN", "Energy", "QIntgPos", "BN", new Dictionary <string, string>() { { "energy.q1mVARspB", "Total" } }); AddChannel("Q2 Reactive Energy BN", "Energy", "QIntgPos", "BN", new Dictionary <string, string>() { { "energy.q2mVARspB", "Total" } }); AddChannel("Q3 Reactive Energy BN", "Energy", "QIntgNeg", "BN", new Dictionary <string, string>() { { "energy.q3mVARspB", "Total" } }); AddChannel("Q4 Reactive Energy BN", "Energy", "QIntgNeg", "BN", new Dictionary <string, string>() { { "energy.q4mVARspB", "Total" } }); AddChannel("Q1 Reactive Energy CN", "Energy", "QIntgPos", "CN", new Dictionary <string, string>() { { "energy.q1mVARspC", "Total" } }); AddChannel("Q2 Reactive Energy CN", "Energy", "QIntgPos", "CN", new Dictionary <string, string>() { { "energy.q2mVARspC", "Total" } }); AddChannel("Q3 Reactive Energy CN", "Energy", "QIntgNeg", "CN", new Dictionary <string, string>() { { "energy.q3mVARspC", "Total" } }); AddChannel("Q4 Reactive Energy CN", "Energy", "QIntgNeg", "CN", new Dictionary <string, string>() { { "energy.q4mVARspC", "Total" } }); JToken Get(JToken obj, string path) => path.Split('.').Aggregate(obj, (token, identifier) => token?[identifier]); foreach (byte[] fileData in FileData) { using (MemoryStream fileStream = new MemoryStream(fileData)) using (GZipStream decompressor = new GZipStream(fileStream, CompressionMode.Decompress)) using (MemoryStream jsonStream = new MemoryStream()) using (TextReader textReader = new StreamReader(jsonStream)) using (JsonReader jsonReader = new JsonTextReader(textReader)) { decompressor.CopyTo(jsonStream); decompressor.Dispose(); jsonStream.Position = 0; JObject obj = JObject.Load(jsonReader); DateTime epoch = new DateTime(1970, 1, 1); double ts = obj["ts"].Value <double>(); DateTime timestamp = epoch.AddSeconds(ts); foreach (KeyValuePair <string, DataSeries> kvp in dataSeriesLookup) { string path = kvp.Key; DataSeries dataSeries = kvp.Value; JToken token = Get(obj, path); if (token != null) { double value = token.Value <double>(); DataPoint dataPoint = new DataPoint() { Time = timestamp, Value = value }; dataSeries.DataPoints.Add(dataPoint); } } } } foreach (KeyValuePair <string, DataSeries> kvp in dataSeriesLookup) { DataSeries dataSeries = kvp.Value; if (dataSeries.DataPoints.Count > 0) { string path = kvp.Key; double adjustment = path.StartsWith("energy") ? (1.0D / 1000.0D / 3600.0D) // mJ -> Watt-hours || mVAR*s -> VAR-hours : (1.0D / 1000.0D); // mV -> Volts || mA -> Amps || mHz -> Hz DataSeries adjustedData = dataSeries.Multiply(adjustment); adjustedData.SeriesInfo = dataSeries.SeriesInfo; MeterDataSet.DataSeries.Add(adjustedData); } } MeterDataSet.Meter = meter; }
/// <summary> /// </summary> /// <param name="graphics"></param> /// <param name="bounds"></param> /// <param name="min"></param> /// <param name="max"></param> public override void Plot(Graphics graphics, Rectangle bounds, double min, double max) { if (Bars == null || ChartControl == null) { return; } // plot error if data not complete if (textBrush.Color != ChartControl.AxisColor || textFont != ChartControl.Font) { textBrush.Color = ChartControl.AxisColor; textFont = ChartControl.Font; SizeF errorSize = graphics.MeasureString(errorData, textFont); errorTextWidth = errorSize.Width + 5; errorTextHeight = errorSize.Height + 5; } if (priorDayHLC == HLCCalculationMode.CalcFromIntradayData) { DateTime lastBarDate = (Bars.Count == 0) ? Cbi.Globals.MaxDate : ChartControl.EquidistantBars ? Bars.GetTime(Math.Min(Bars.Count - 1, ChartControl.LastBarPainted)).Date : Bars.GetTime(Math.Min(Bars.Count - 1, Bars.GetBar(ChartControl.LastBarTimePainted))).Date; if ((lastBarDate == Cbi.Globals.MaxDate) || (Bars.BarsType.BuiltFrom == PeriodType.Minute && ((pivotRangeType == PivotRange.Monthly && Bars.Count > 0 && Bars.GetTime(0).AddSeconds(-1).Date >= new DateTime(lastBarDate.Year, lastBarDate.Month, 1).AddMonths(-1)) || (pivotRangeType == PivotRange.Weekly && Bars.Count > 0 && Bars.GetTime(0).AddSeconds(-1).Date >= lastBarDate.AddDays(-(((int)lastBarDate.DayOfWeek) + 1) % 7).AddDays(-7)) || (pivotRangeType == PivotRange.Daily && Bars.Count > 0 && Bars.GetTime(0).AddSeconds(-1).Date >= lastBarDate.AddDays(-1)))) || (Bars.BarsType.BuiltFrom != PeriodType.Minute && ((pivotRangeType == PivotRange.Monthly && Bars.Count > 0 && Bars.GetTime(0).Date >= new DateTime(lastBarDate.Year, lastBarDate.Month, 1).AddMonths(-1)) || (pivotRangeType == PivotRange.Weekly && Bars.Count > 0 && Bars.GetTime(0).Date >= lastBarDate.AddDays(-(((int)lastBarDate.DayOfWeek) + 1) % 7).AddDays(-7)) || (pivotRangeType == PivotRange.Daily && Bars.Count > 0 && Bars.GetTime(0).Date >= lastBarDate.AddDays(-1))))) { graphics.DrawString(errorData, ChartControl.Font, textBrush, bounds.X + bounds.Width - errorTextWidth, bounds.Y + bounds.Height - errorTextHeight, stringFormatNear); } } else if (priorDayHLC == HLCCalculationMode.DailyBars && existsHistDailyData) { DateTime lastBarDate = (dailyBars.Count == 0) ? Cbi.Globals.MaxDate : ChartControl.EquidistantBars ? dailyBars.GetTime(Math.Min(dailyBars.Count - 1, ChartControl.LastBarPainted)).Date : dailyBars.GetTime(Math.Min(dailyBars.Count - 1, dailyBars.GetBar(ChartControl.LastBarTimePainted))).Date; if ((lastBarDate == Cbi.Globals.MaxDate) || (pivotRangeType == PivotRange.Monthly && dailyBars.GetTime(0).Date >= new DateTime(lastBarDate.Year, lastBarDate.Month, 1).AddMonths(-1)) || (pivotRangeType == PivotRange.Weekly && dailyBars.GetTime(0).Date >= lastBarDate.AddDays(-(((int)lastBarDate.DayOfWeek) + 1) % 7).AddDays(-7)) || (pivotRangeType == PivotRange.Daily && dailyBars.GetTime(0).Date >= lastBarDate.AddDays(-1))) { graphics.DrawString(errorData, ChartControl.Font, textBrush, bounds.X + bounds.Width - errorTextWidth, bounds.Y + bounds.Height - errorTextHeight, stringFormatNear); } } float textHeight = ChartControl.Font.GetHeight(); for (int seriesCount = 0; seriesCount < Values.Length; seriesCount++) { SolidBrush brush = brushes[seriesCount]; int firstBarIdxToPaint = -1; int lastX = -1; int lastY = -1; SmoothingMode oldSmoothingMode = graphics.SmoothingMode; Gui.Chart.Plot plot = Plots[seriesCount]; DataSeries series = (DataSeries)Values[seriesCount]; for (int i = newSessionBarIdxArr.Count - 1; i >= 0; i--) { int prevSessionBreakIdx = (int)newSessionBarIdxArr[i]; if (prevSessionBreakIdx <= this.LastBarIndexPainted) { firstBarIdxToPaint = prevSessionBreakIdx; break; } } using (GraphicsPath path = new GraphicsPath()) { if (brush.Color != plot.Pen.Color) { brush = new SolidBrush(plot.Pen.Color); } for (int idx = this.LastBarIndexPainted; idx >= Math.Max(this.FirstBarIndexPainted, this.LastBarIndexPainted - Width); idx--) { if (idx - Displacement < 0 || idx - Displacement >= Bars.Count || (!ChartControl.ShowBarsRequired && idx - Displacement < BarsRequired)) { continue; } else if (!series.IsValidPlot(idx)) { continue; } if (idx < firstBarIdxToPaint) { break; } double val = series.Get(idx); int x = ChartControl.GetXByBarIdx(BarsArray[0], idx); int y = ChartControl.GetYByValue(this, val); if (lastX >= 0) { if (y != lastY) // Problem here is, that last bar of old day has date of new day { y = lastY; } path.AddLine(lastX - plot.Pen.Width / 2, lastY, x - plot.Pen.Width / 2, y); } lastX = x; lastY = y; } graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.DrawPath(plot.Pen, path); graphics.SmoothingMode = oldSmoothingMode; graphics.DrawString(plot.Name, ChartControl.Font, brush, lastX, lastY - textHeight / 2, stringFormatFar); } } }
private int FindIndexCleared(DataSeries waveform, int cycleIndex) { int samplesPerCycle = Transform.CalculateSamplesPerCycle(waveform, m_systemFrequency); int startIndex = cycleIndex - 1; int endIndex = startIndex + samplesPerCycle - 1; int postfaultIndex = Math.Min(endIndex + samplesPerCycle, waveform.DataPoints.Count - 1); double largestPostfaultPeak; double largestFaultCyclePeak; double previousValue; double value; double nextValue; // If cycleIndex is zero, assume that the breaker // is open at the very start of the waveform if (cycleIndex == 0) { return(0); } largestPostfaultPeak = 0.0D; largestFaultCyclePeak = 0.0D; // Find the largest postfault peak as the absolute // peak of the cycle after the last faulted cycle for (int i = postfaultIndex; i > endIndex; i--) { value = Math.Abs(waveform[i].Value); if (value > largestPostfaultPeak) { largestPostfaultPeak = value; } } // Find the largest peak of the last faulted cycle for (int i = startIndex; i <= endIndex; i++) { value = Math.Abs(waveform[i].Value); if (value > largestFaultCyclePeak) { largestFaultCyclePeak = value; } } // Scanning backwards, find the first point where the value exceeds // a point 25% of the way from the postfault peak to the fault peak for (int i = endIndex; i >= startIndex; i--) { value = Math.Abs(waveform[i].Value); if (value >= (largestPostfaultPeak * 0.75 + largestFaultCyclePeak * 0.25)) { startIndex = i; } } // Starting from the point found in the previous loop, // find either the first zero crossing or the first point // at which the slope changes drastically for (int i = startIndex; i <= endIndex; i++) { if (i - 1 < 0) { continue; } if (i + 1 >= waveform.DataPoints.Count) { continue; } previousValue = waveform.DataPoints[i - 1].Value; value = waveform.DataPoints[i].Value; nextValue = waveform.DataPoints[i + 1].Value; if (value * nextValue < 0.0D) { return(i); } if (Math.Abs(value - previousValue) > 5.0D * Math.Abs(nextValue - value)) { return(i); } } return(startIndex); }
void AddDataPoint(DataSeries ds, DesignerDataPoint dp) { DataPoint newDp = new DataPoint(); newDp.Uid = dp.ID.ToString(); newDp.Name = dp.Name; newDp.SetBinding(DataPoint.AxisXLabelProperty, new Binding("AxisXLabel") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.BorderColorProperty, new Binding("LabelBorder.BorderBrush") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.BorderStyleProperty, new Binding("BorderStyle") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.BorderThicknessProperty, new Binding("LabelBorder.BorderThickness") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.ColorProperty, new Binding("Color") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.EnabledProperty, new Binding("Enabled") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelAngleProperty, new Binding("LabelAngle") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelBackgroundProperty, new Binding("LabelBackground") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelEnabledProperty, new Binding("LabelEnabled") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelFontColorProperty, new Binding("LabelFont.FontColor") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelFontFamilyProperty, new Binding("LabelFont.FontFamily") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelFontSizeProperty, new Binding("LabelFont.FontSize") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelFontStyleProperty, new Binding("LabelFont.FontStyle") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelFontWeightProperty, new Binding("LabelFont.FontWeight") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelLineColorProperty, new Binding("LabelLineColor") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelLineEnabledProperty, new Binding("LabelLineEnabled") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelLineStyleProperty, new Binding("LabelLineStyle") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelLineThicknessProperty, new Binding("LabelLineThickness") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelStyleProperty, new Binding("LabelStyle") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LabelTextProperty, new Binding("LabelText") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LegendMarkerColorProperty, new Binding("LegendMarkerColor") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LegendMarkerTypeProperty, new Binding("LegendMarkerType") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LegendTextProperty, new Binding("LegendText") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.LightingEnabledProperty, new Binding("LightingEnabled") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.MarkerBorderColorProperty, new Binding("MarkerBorderColor") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.MarkerBorderThicknessProperty, new Binding("MarkerBorderThickness") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.MarkerColorProperty, new Binding("MarkerColor") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.MarkerEnabledProperty, new Binding("MarkerEnabled") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.MarkerScaleProperty, new Binding("MarkerScale") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.MarkerSizeProperty, new Binding("MarkerSize") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.MarkerTypeProperty, new Binding("MarkerType") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.OpacityProperty, new Binding("DataPointOpacity") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.RadiusXProperty, new Binding("RadiusX") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.RadiusYProperty, new Binding("RadiusY") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.ShadowEnabledProperty, new Binding("ShadowEnabled") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.ShowInLegendProperty, new Binding("ShowInLegend") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.StickColorProperty, new Binding("StickColor") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.XValueProperty, new Binding("XValue") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.YValueProperty, new Binding("YValue") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.YValuesProperty, new Binding("YValues") { Source = dp, Mode = BindingMode.OneWay }); newDp.SetBinding(DataPoint.ZValueProperty, new Binding("ZValue") { Source = dp, Mode = BindingMode.OneWay }); if (ds.DataPoints == null) { ds.DataPoints = new DataPointCollection(); } ds.DataPoints.Add(newDp); }
public static double support(this DataSeries dataseries, int period) { return(dataseries.Minimum(period)); }
private void AddUndefinedChannels(MeterDataSet meterDataSet) { DataContextLookup <SeriesKey, Series> seriesLookup; DataContextLookup <ChannelKey, Channel> channelLookup; DataContextLookup <string, MeasurementType> measurementTypeLookup; DataContextLookup <string, MeasurementCharacteristic> measurementCharacteristicLookup; DataContextLookup <string, SeriesType> seriesTypeLookup; DataContextLookup <string, Phase> phaseLookup; List <DataSeries> undefinedDataSeries; Line line; undefinedDataSeries = meterDataSet.DataSeries .Where(dataSeries => (object)dataSeries.SeriesInfo.Channel.Line == null) .ToList(); if (undefinedDataSeries.Count <= 0) { return; } line = meterDataSet.Meter.MeterLines .Select(meterLine => meterLine.Line) .Single(); foreach (DataSeries series in undefinedDataSeries) { series.SeriesInfo.Channel.LineID = line.ID; } seriesLookup = new DataContextLookup <SeriesKey, Series>(m_meterInfo, GetSeriesKey) .WithFilterExpression(series => series.Channel.MeterID == meterDataSet.Meter.ID) .WithFilterExpression(series => series.SourceIndexes == ""); channelLookup = new DataContextLookup <ChannelKey, Channel>(m_meterInfo, GetChannelKey) .WithFilterExpression(channel => channel.MeterID == meterDataSet.Meter.ID); measurementTypeLookup = new DataContextLookup <string, MeasurementType>(m_meterInfo, type => type.Name); measurementCharacteristicLookup = new DataContextLookup <string, MeasurementCharacteristic>(m_meterInfo, characteristic => characteristic.Name); seriesTypeLookup = new DataContextLookup <string, SeriesType>(m_meterInfo, type => type.Name); phaseLookup = new DataContextLookup <string, Phase>(m_meterInfo, phase => phase.Name); for (int i = 0; i < undefinedDataSeries.Count; i++) { DataSeries dataSeries = undefinedDataSeries[i]; // Search for an existing series info object dataSeries.SeriesInfo = seriesLookup.GetOrAdd(GetSeriesKey(dataSeries.SeriesInfo), seriesKey => { Series clonedSeries = dataSeries.SeriesInfo.Clone(); // Search for an existing series type object to associate with the new series SeriesType seriesType = seriesTypeLookup.GetOrAdd(dataSeries.SeriesInfo.SeriesType.Name, name => dataSeries.SeriesInfo.SeriesType.Clone()); // Search for an existing channel object to associate with the new series Channel channel = channelLookup.GetOrAdd(GetChannelKey(dataSeries.SeriesInfo.Channel), channelKey => { Channel clonedChannel = dataSeries.SeriesInfo.Channel.Clone(); // Search for an existing measurement type object to associate with the new channel MeasurementType measurementType = measurementTypeLookup.GetOrAdd(dataSeries.SeriesInfo.Channel.MeasurementType.Name, name => dataSeries.SeriesInfo.Channel.MeasurementType.Clone()); // Search for an existing measurement characteristic object to associate with the new channel MeasurementCharacteristic measurementCharacteristic = measurementCharacteristicLookup.GetOrAdd(dataSeries.SeriesInfo.Channel.MeasurementCharacteristic.Name, name => dataSeries.SeriesInfo.Channel.MeasurementCharacteristic.Clone()); // Search for an existing phase object to associate with the new channel Phase phase = phaseLookup.GetOrAdd(dataSeries.SeriesInfo.Channel.Phase.Name, name => dataSeries.SeriesInfo.Channel.Phase.Clone()); // Assign the foreign keys of the channel // to reference the objects from the lookup clonedChannel.Meter = meterDataSet.Meter; clonedChannel.Line = line; clonedChannel.MeasurementType = measurementType; clonedChannel.MeasurementCharacteristic = measurementCharacteristic; clonedChannel.Phase = phase; clonedChannel.Enabled = 1; // If the per-unit value was not specified in the input file, // we can obtain the per-unit value from the line configuration // if the channel happens to be an instantaneous or RMS voltage if (!clonedChannel.PerUnitValue.HasValue) { if (IsVoltage(clonedChannel)) { if (IsLineToNeutral(clonedChannel)) { clonedChannel.PerUnitValue = (line.VoltageKV * 1000.0D) / Sqrt3; } else if (IsLineToLine(clonedChannel)) { clonedChannel.PerUnitValue = line.VoltageKV * 1000.0D; } } } return(clonedChannel); }); // Assign the foreign keys of the series // to reference the objects from the lookup clonedSeries.SeriesType = seriesType; clonedSeries.Channel = channel; return(clonedSeries); }); } }
/// <summary> /// 绘制饼状图 /// </summary> /// <param name="name"></param> /// <param name="valuex"></param> /// <param name="valuey"></param> public void CreateChartPie(string name, List <string> valuex, List <string> valuey) { //创建一个图标 Chart chart = new Chart(); //设置图标的宽度和高度 //chart.Width = 580; //chart.Height = 380; chart.Margin = new Thickness(10, 5, 10, 5); //是否启用打印和保持图片 chart.ToolBarEnabled = false; //设置图标的属性 chart.ScrollingEnabled = false; //是否启用或禁用滚动 chart.View3D = true; //3D效果显示 //创建一个标题的对象 Title title = new Title(); //设置标题的名称 title.Text = name; title.Padding = new Thickness(0, 10, 5, 0); chart.Background = new SolidColorBrush(Colors.Black); chart.Opacity = 1; chart.FontSize = 20; //向图标添加标题 chart.Titles.Add(title); //Axis yAxis = new Axis(); ////设置图标中Y轴的最小值永远为0 //yAxis.AxisMinimum = 0; ////设置图表中Y轴的后缀 //yAxis.Suffix = "个"; //chart.AxesY.Add(yAxis); // 创建一个新的数据线。 DataSeries dataSeries = new DataSeries(); // 设置数据线的格式 dataSeries.RenderAs = RenderAs.Pie;//柱状Stacked // 设置数据点 DataPoint dataPoint; for (int i = 0; i < valuex.Count; i++) { // 创建一个数据点的实例。 dataPoint = new DataPoint(); // 设置X轴点 dataPoint.AxisXLabel = valuex[i]; dataPoint.LegendText = "##" + valuex[i]; //设置Y轴点 dataPoint.YValue = double.Parse(valuey[i]); //添加一个点击事件 dataPoint.MouseLeftButtonDown += new MouseButtonEventHandler(dataPoint_MouseLeftButtonDown); //添加数据点 dataSeries.DataPoints.Add(dataPoint); } // 添加数据线到数据序列。 chart.Series.Add(dataSeries); //将生产的图表增加到Grid,然后通过Grid添加到上层Grid. Grid gr = new Grid(); gr.Children.Add(chart); pieShow.Children.Add(gr); }
public void Parse(string filePath) { Meter meter = new Meter(); meter.MeterLocation = new MeterLocation(); meter.Channels = new List <Channel>(); meter.AssetKey = "UNKNOWN"; meter.Name = "Unknown"; meter.Description = "Unknown"; meter.Make = "Eaton"; meter.Model = "EMCB"; MeterLocation meterLocation = meter.MeterLocation; meterLocation.AssetKey = "UNKNOWN"; meterLocation.Latitude = 0.0D; meterLocation.Longitude = 0.0D; meterLocation.Name = "Unknown"; meterLocation.Description = "Unknown"; DataSeries CreateDataSeries(string channelName, string type, string characteristic, string phase, DateTime[] timeSeries, JArray valueSeries) { if (valueSeries == null) { return(null); } const string SeriesType = "Values"; DataSeries dataSeries = new DataSeries(); dataSeries.DataPoints = timeSeries .Zip(valueSeries, (time, token) => new DataPoint() { Time = time, Value = token.Value <double>() }) .ToList(); // Convert from mV/mA to Volts/Amps dataSeries = dataSeries.Multiply(1.0D / 1000.0D); Series series = dataSeries.SeriesInfo = new Series(); series.Channel = new Channel(); series.SeriesType = new SeriesType() { Name = SeriesType }; Channel channel = series.Channel; channel.Series = new List <Series>() { series }; channel.MeasurementType = new MeasurementType() { Name = type }; channel.MeasurementCharacteristic = new MeasurementCharacteristic() { Name = characteristic }; channel.Phase = new Phase() { Name = phase }; channel.Name = channelName; channel.Description = channelName; channel.HarmonicGroup = 0; if (type == "Voltage") { channel.PerUnitValue = 120.0D; } return(dataSeries); } void Parse(byte[] fileData, string characteristic) { using (MemoryStream fileStream = new MemoryStream(fileData)) using (GZipStream decompressor = new GZipStream(fileStream, CompressionMode.Decompress)) using (MemoryStream jsonStream = new MemoryStream()) using (TextReader textReader = new StreamReader(jsonStream)) using (JsonReader jsonReader = new JsonTextReader(textReader)) { decompressor.CopyTo(jsonStream); decompressor.Dispose(); jsonStream.Position = 0; dynamic obj = JObject.Load(jsonReader); string meterKey = obj.idAgent; meter.AssetKey = meterKey; meter.Name = meterKey; meter.Description = meterKey; meterLocation.AssetKey = meterKey; meterLocation.Name = meterKey; meterLocation.Description = meterKey; double startMilliseconds = obj.startTime; double deltaTime = obj.deltaTime; int samples = obj.numSamples; DateTime epoch = new DateTime(1970, 1, 1); DateTime startTime = epoch.AddMilliseconds(startMilliseconds); DateTime[] timeSeries = Enumerable.Range(0, samples) .Select(i => i * deltaTime) .Select(startTime.AddMilliseconds) .ToArray(); DataSeries[] allSeries = { CreateDataSeries("VAN", "Voltage", characteristic, "AN", timeSeries, obj.mVpA), CreateDataSeries("VBN", "Voltage", characteristic, "BN", timeSeries, obj.mVpB), CreateDataSeries("VCN", "Voltage", characteristic, "CN", timeSeries, obj.mVpC), CreateDataSeries("IAN", "Current", characteristic, "AN", timeSeries, obj.mApA), CreateDataSeries("IBN", "Current", characteristic, "BN", timeSeries, obj.mApB), CreateDataSeries("ICN", "Current", characteristic, "CN", timeSeries, obj.mApC) }; List <DataSeries> allValidSeries = allSeries .Where(dataSeries => dataSeries != null) .ToList(); MeterDataSet.Meter = meter; MeterDataSet.DataSeries.AddRange(allValidSeries); IEnumerable <Channel> allChannels = allValidSeries.Select(dataSeries => dataSeries.SeriesInfo.Channel); meter.Channels.AddRange(allChannels); } } foreach (byte[] waveformData in WaveformData) { Parse(waveformData, "Instantaneous"); } foreach (byte[] waveformData in FastRMSData) { Parse(waveformData, "RMS"); } }
internal XYDataPoint(DataSeries ds, int seriesIndex, int pointIndex, string[] names) : base(ds, seriesIndex, pointIndex, names) { }
protected override void OnBarUpdate() { if (CurrentBar < 200) { return; } if (0 == iNoAlts) { switch (noPlots) { case AdaptiveCciPlots.One: iNoAlts = 1; break; case AdaptiveCciPlots.Two: iNoAlts = 2; break; case AdaptiveCciPlots.Three: iNoAlts = 3; break; case AdaptiveCciPlots.Four: iNoAlts = 4; break; } } smooth.Set((4 * Input[0] + 3 * Input[1] + 2 * Input[2] + Input[3]) * 0.1); detrender.Set((0.0962 * smooth[0] + 0.5769 * smooth[2] - 0.5769 * smooth[4] - 0.0962 * smooth[6]) * (0.075 * period[1] + 0.54)); // Compute InPhase and Quadrature components q1.Set((0.0962 * detrender[0] + 0.5769 * detrender[2] - 0.5769 * detrender[4] - 0.0962 * detrender[6]) * (0.075 * period[1] + 0.54)); i1.Set(detrender[3]); // Advance the phase of i1 and q1 by 90} double jI = (0.0962 * i1[0] + 0.5769 * i1[2] - 0.5769 * i1[4] - 0.0962 * i1[6]) * (0.075 * period[1] + 0.54); double jQ = (0.0962 * q1[0] + 0.5769 * q1[2] - 0.5769 * q1[4] - 0.0962 * q1[6]) * (0.075 * period[1] + 0.54); // Phasor addition for 3 bar averaging} i2.Set(i1[0] - jQ); q2.Set(q1[0] + jI); // Smooth the I and Q components before applying the discriminator i2.Set(0.2 * i2[0] + 0.8 * i2[1]); q2.Set(0.2 * q2[0] + 0.8 * q2[1]); // Homodyne Discriminator re.Set(i2[0] * i2[1] + q2[0] * q2[1]); im.Set(i2[0] * q2[1] - q2[0] * i2[1]); re.Set(0.2 * re[0] + 0.8 * re[1]); im.Set(0.2 * im[0] + 0.8 * im[1]); if (Math.Abs(im[0]) > double.Epsilon && Math.Abs(re[0]) > double.Epsilon) { period.Set(360 / ((180 / Math.PI) * Math.Atan(im[0] / re[0]))); } if (period[0] > 1.5 * period[1]) { period.Set(1.5 * period[1]); } if (period[0] < 0.67 * period[1]) { period.Set(0.67 * period[1]); } if (period[0] < 6) { period.Set(6); } if (period[0] > 200) { period.Set(200); } period.Set(0.2 * period[0] + 0.8 * period[1]); int length = periodMultiplier * (int)(cycPart * period[0]); lengthVars.Set(length); // Print(Length); vMedianPrice.Set((High[0] + Low[0] + Close[0]) / 3); double avg = 0; for (int count = 0; count < length; count++) { avg = avg + vMedianPrice[count]; } avg = avg / length; double md = 0; for (int count = 0; count < length; count++) { md = md + Math.Abs(vMedianPrice[count] - avg); } md = md / length; if (Math.Abs(md) < double.Epsilon) { return; } adaptCci.Set((vMedianPrice[0] - avg) / (0.015 * md)); CciPlot.Set(SMA(adaptCci, smaSmooth)[0]); DataSeries dsAlt1 = AdaptiveAlternativeCci(cycPart, numBars1, periodMultiplier, smaSmooth).CciPlot; DataSeries dsAlt2 = AdaptiveAlternativeCci(cycPart, numBars2, periodMultiplier, smaSmooth).CciPlot; DataSeries dsAlt3 = AdaptiveAlternativeCci(cycPart, numBars3, periodMultiplier, smaSmooth).CciPlot; DataSeries dsAlt4 = AdaptiveAlternativeCci(cycPart, numBars4, periodMultiplier, smaSmooth).CciPlot; if (iNoAlts > 0) { AltCciPlot1.Set(dsAlt1.Get(CurrentBar)); } if (iNoAlts > 1) { AltCciPlot2.Set(dsAlt2.Get(CurrentBar)); } if (iNoAlts > 2) { AltCciPlot3.Set(dsAlt3.Get(CurrentBar)); } if (iNoAlts > 3) { AltCciPlot4.Set(dsAlt4.Get(CurrentBar)); } if (iNoAlts > 3) { if (Rising(dsAlt1) && Rising(dsAlt2) && Rising(dsAlt3) && Rising(dsAlt4)) { dotSeries.Set(1); } else if (Falling(dsAlt1) && Falling(dsAlt2) && Falling(dsAlt3) && Falling(dsAlt4)) { dotSeries.Set(-1); } else { dotSeries.Set(2); } } else if (iNoAlts > 2) { if (Rising(dsAlt1) && Rising(dsAlt2) && Rising(dsAlt3)) { dotSeries.Set(1); } else if (Falling(dsAlt1) && Falling(dsAlt2) && Falling(dsAlt3)) { dotSeries.Set(-1); } else { dotSeries.Set(2); } } else if (iNoAlts > 1) { if (Rising(dsAlt1) && Rising(dsAlt2)) { dotSeries.Set(1); } else if (Falling(dsAlt1) && Falling(dsAlt2)) { dotSeries.Set(-1); } else { dotSeries.Set(2); } } else if (iNoAlts > 0) { if (Rising(dsAlt1)) { dotSeries.Set(1); } else if (Falling(dsAlt1)) { dotSeries.Set(-1); } else { dotSeries.Set(2); } } else if (Rising(CciPlot)) { dotSeries.Set(1); } else if (Falling(CciPlot)) { dotSeries.Set(-1); } else { dotSeries.Set(2); } }