public void AnomalyGraphButton(int indexOfCosenAnomaly)
 {
     ButtonChosenAnomalyGraphPressed = true;
     Anomaly = model.GetSpecificAnomaly(indexOfCosenAnomaly);
     //for display we need the names of the features
     if (Anomaly == null)
     {
         PlotAnomaliesGraph.Axes[1].Title = "null";
         PlotAnomaliesGraph.Axes[0].Title = "null";
         LineSerieAnomalyLine.Points.Clear();
         LineSerieAnomalyGraphAllPoints.Points.Clear();
         LineSerieAnomalyPoints.Points.Clear();
         PlotAnomaliesGraph.InvalidatePlot(true);
         ButtonChosenAnomalyGraphPressed = false;
         return;
     }
     else
     {
         PlotAnomaliesGraph.Axes[0].Title = Anomaly.Feature1;
         PlotAnomaliesGraph.Axes[1].Title = Anomaly.Feature2;
         UpdateModelAnomaliesGraph();
     }
 }
        public void UpdateModelAnomaliesGraph()
        {
            LineSerieAnomalyLine.Points.Clear();
            LineSerieAnomalyGraphAllPoints.Points.Clear();
            LineSerieAnomalyPoints.Points.Clear();
            LineSerieAnomalyCircle.Points.Clear();
            if (Anomaly == null)
            {
                return;
            }
            // 0 - regerssion algorithem , 1 - circle algorhitem.
            int dllType = model.GetDllType();

            if (dllType == -1)
            {
                return;
            }
            if (dllType == 0)
            {
                //{ startX, startY, endX, endY}
                float[] linePoints = model.GetRegressionLine(Anomaly.Feature1);
                if (linePoints == null || linePoints.Length < 4)
                {
                    return;
                }
                LineSerieAnomalyLine.Points.Add(new DataPoint(linePoints[0], linePoints[1]));
                LineSerieAnomalyLine.Points.Add(new DataPoint(linePoints[2], linePoints[3]));
            }
            else if (dllType == 1)
            {
                //{centerX, centerY, radius}
                float[] circleData = model.GetRegressionCircle(Anomaly.Feature1);
                if (circleData == null || circleData.Length < 3)
                {
                    return;
                }
                LineSerieAnomalyCircle.Points.Add(new DataPoint(circleData[0], circleData[1]));
                LineSerieAnomalyCircle.MarkerSize = circleData[2];
            }
            List <List <float> > allData = model.GetData();
            int sizeAllData = allData.Count;

            if (sizeAllData <= 0)
            {
                return;
            }
            int         indexFeature1     = GetIndexAcorrdingToFeature(Anomaly.Feature1);
            int         indexFeature2     = GetIndexAcorrdingToFeature(Anomaly.Feature2);
            List <long> allAnomaliesIndex = model.GetAnomaliesSameFeatures(Anomaly);

            if (indexFeature2 == -1 || indexFeature1 == -1 || allAnomaliesIndex == null)
            {
                return;
            }
            for (int i = 0; i < sizeAllData; i++)
            {
                if (allAnomaliesIndex.Contains(i))
                {
                    LineSerieAnomalyPoints.Points.Add(new DataPoint(allData[i][indexFeature1], allData[i][indexFeature2]));
                }
                else
                {
                    LineSerieAnomalyGraphAllPoints.Points.Add(new DataPoint(allData[i][indexFeature1], allData[i][indexFeature2]));
                }
            }
            PlotAnomaliesGraph.InvalidatePlot(true);
        }