示例#1
0
 public PieChart(Drawing.Rectangle rect)
 {
     var center = rect.Center;
     var radius = System.Math.Min(rect.Width,rect.Height)/2.0;
     this.DataPoints = new DataPointList();
     this.Center = center;
     this.Radius = radius;
 }
示例#2
0
 public Line()
 {
     mVisible = true;
     mLabel = "";
     mPoints = new DataPointList();
     mColor = Color.Black;
     mWidth = 1;
     mSymbolType = SymbolType.None;
 }
示例#3
0
 public Line(string label, DataPointList points)
 {
     mVisible = true;
     mLabel = label;
     mPoints = points;
     mColor = Color.Black;
     mWidth = 1;
     mSymbolType = SymbolType.None;
 }
示例#4
0
 public PieChart(Drawing.Point center, double radius)
 {
     this.DataPoints = new DataPointList();
     this.Center = center;
     this.Radius = radius;
 }
        private ParsingReturnStructure ReadData(ParsedTable pt, string fileId)
        {
            int             firstDateRow = 0;
            PeriodTypes2017 frequency    = PeriodTypes2017.Monthly;
            string          seriesName   = "";
            var             increment    = 1;

            //get high level info from the first few rows
            for (int row = 0; row <= pt.Vals.GetUpperBound(0); row++)
            {
                var cell = pt.Vals[row, 0].ToString();

                if (cell.Contains(fileId))
                {
                    seriesName = pt.Vals[row, 1].ToString().Replace(",", " ");  //TODO - probably need to shorten this
                }
                if (cell.Contains("Frequency"))
                {
                    if (cell.Contains("Monthly"))
                    {
                        frequency = PeriodTypes2017.Monthly;
                    }
                    else if (cell.Contains("Quarterly"))
                    {
                        frequency = PeriodTypes2017.Quarterly;
                    }
                    else if (cell.Contains("Weekly"))
                    {
                        frequency = GetDailyFrequency(pt.Vals[row + 2, 0]);  //actual dates start two rows down  ;
                    }
                    else if (cell.Contains("Daily"))
                    {
                        frequency = GetDailyFrequency(pt.Vals[row + 2, 0]);  //actual dates start two rows down
                        increment = 5;
                    }
                    else
                    {
                        //TODO - handle more cases
                        Debug.Assert(false, "unknown frequency");
                    }
                }
                DateTime dateResult;
                if (DateTime.TryParse(pt.Vals[row, 0], out dateResult))
                {
                    firstDateRow = row;
                    break;
                }
            }
            var neumonic = SeriesToNeumonic(seriesName);

            seriesName = neumonic;
            Guid seriesId = _nk.GetValue(neumonic);

            _nk.AddSeriesName(seriesId, seriesName);
            var dataPointList = new DataPointList();

            for (int row = firstDateRow; row <= pt.Vals.GetUpperBound(0); row += increment)
            {
                var dp = new DataPoint2017(DateTime.Parse(pt.Vals[row, 0]), frequency, decimal.Parse(pt.Vals[row, 1]));
                dp.Neum           = neumonic;
                dp.ParentSeriesId = seriesId;
                dataPointList.AddPoint(dp);
            }
            var prs = new ParsingReturnStructure();

            prs.DataPoints = dataPointList;


            BGTableInfo bgTableInfo = new BGTableInfo();  ///

            bgTableInfo.TableName = seriesName;
            prs.TableInfos.Add(bgTableInfo);
            BGTableLineInformation tableLineInfo = new BGTableLineInformation();

            tableLineInfo.linelabel        = seriesName;
            tableLineInfo.tablelineindents = 0;
            tableLineInfo.tablelinenum     = 1;
            tableLineInfo.objectID         = seriesId;
            bgTableInfo.Add(tableLineInfo);

            return(prs);
        }
示例#6
0
        private ParsingReturnStructure ProcessData2(List <List <String> > table)
        {
            NeumKey         _nk           = new NeumKey();
            DataPointList   dataPointList = new DataPointList();
            List <String>   footnotes     = new List <string>();
            List <String>   columnHeaders = new List <string>();
            List <DateTime> dates         = new List <DateTime>();
            List <String>   values        = new List <String>();
            List <Tuple <String, String, DateTime, String, String> > dataPoint = new List <Tuple <string, string, DateTime, string, string> >();
            List <Tuple <String, String> > nuemWithValue = new List <Tuple <string, string> >();
            List <String> neums = new List <String>();


            var rawNeum       = table[0][0].ToString();
            var formattedNeum = CreateNeum(rawNeum);

            //var usedRange = ws.UsedRange;
            foreach (List <String> Row in table)
            {
                int Rownum = table.IndexOf(Row);
                foreach (String Item in Row)
                {
                    int Colnum = Row.IndexOf(Item);
                    //Console.WriteLine(Item);
                    if ((Rownum == 0) && (Colnum >= 1))
                    {
                        columnHeaders.Add(Item.ToString());
                    }
                    else if ((Rownum > 0) && (Colnum == 0))
                    {
                        dates.Add(FormattedDate(Item.ToString()));
                    }
                    else if ((Rownum > 0) && (Colnum > 0))
                    {
                        try
                        {
                            Convert.ToDecimal(Item);
                            values.Add(Item);
                        }
                        catch
                        {
                            try
                            {
                                Convert.ToDecimal(Item.Split(')')[1].ToString().Trim());
                                //Console.WriteLine(Item.Split(')')[1].ToString().Trim());
                                values.Add(Item.Split(')')[1].ToString().Trim());
                            }
                            catch
                            {
                                values.Add("-999,999");
                            }
                        }
                        ;
                    }
                }
            }
            foreach (var col in columnHeaders)
            {
                nuemWithValue.Add(new Tuple <string, string>((formattedNeum + "_" + col), (rawNeum + "_" + col)));
            }
            var i = 0;

            foreach (var date in dates)
            //foreach (Tuple<string, string> nuemWithVal in nuemWithValue)
            {
                //foreach(var date in dates)
                foreach (Tuple <string, string> nuemWithVal in nuemWithValue)
                {
                    String[] neumAndCatsubstrings = nuemWithVal.Item1.Split('_');
                    var      dp = new DataPoint2017(date, PeriodTypes2017.Annual, Convert.ToDecimal(values[i]));
                    dp.Neum = nuemWithVal.Item1;
                    Guid   seriesId   = _nk.GetValue(dp.Neum);
                    String seriesName = nuemWithVal.Item1;
                    _nk.AddSeriesName(seriesId, seriesName);
                    dp.ParentSeriesId = seriesId;
                    //dataPoint.Add(new Tuple<string, string, DateTime, string, string>(nuemWithVal.Item1, neumAndCatsubstrings[1], date, "Fiscal Year", values[i]));
                    dataPointList.AddPoint(dp);
                    i++;
                }
            }
            ParsingReturnStructure toReturn  = new ParsingReturnStructure();
            BGTableInfo            tableHere = new BGTableInfo();

            tableHere.TableName = rawNeum;
            int tableLineNum = 0;

            toReturn.DataPoints.AddList(dataPointList);
            for (int rowOn = 1; rowOn < columnHeaders.Count; rowOn++)
            {
                //      int colOn = 1;

                if (columnHeaders[rowOn] != null && columnHeaders[rowOn].Length > 0)  //sometimes there are blank cells that don't need to be processed
                {
                    tableLineNum++;



                    String seriesName = rawNeum + "_" + columnHeaders[rowOn];


                    String neum = "arlweb~" + seriesName;
                    neum = _nk.PrettifyNeum(neum);
                    Guid seriesID = _nk.GetValue(neum);

                    BGTableLineInformation tableLineInfo = new BGTableLineInformation();
                    tableLineInfo.linelabel        = columnHeaders[rowOn];
                    tableLineInfo.tablelineindents = 0;
                    tableLineInfo.tablelinenum     = tableLineNum;
                    tableLineInfo.objectID         = seriesID;
                    tableHere.Add(tableLineInfo);
                }
            }
            toReturn.NeumKey = _nk;
            toReturn.TableInfos.Add(tableHere);
            return(toReturn);
        }
 public BarChart(Drawing.Rectangle rect)
 {
     this.Rectangle = rect;
     this.DataPoints = new DataPointList();
 }
示例#8
0
        public void TestDataPointListConstructor01()
        {
            DataPointList dataPointList = new DataPointList();

            #region Record State
            ValueRecorder recorder = new ValueRecorder();
            recorder.Record((string)dataPointList.AccessibleDefaultActionDescription);
            recorder.Record((string)dataPointList.AccessibleDescription);
            recorder.Record((string)dataPointList.AccessibleName);
            recorder.Record((AccessibleRole)dataPointList.AccessibleRole);
            recorder.Record((bool)dataPointList.AllowDrop);
            recorder.Record((bool)dataPointList.AllowTransparency);
            recorder.Record((AnchorStyles)dataPointList.Anchor);
            recorder.Record((AutoScaleMode)dataPointList.AutoScaleMode);
            recorder.Record((bool)dataPointList.AutoScroll);
            recorder.Record((bool)dataPointList.AutoSize);
            recorder.Record((AutoSizeMode)dataPointList.AutoSizeMode);
            recorder.Record((AutoValidate)dataPointList.AutoValidate);
            recorder.Record((ImageLayout)dataPointList.BackgroundImageLayout);
            recorder.Record((int)dataPointList.Bottom);
            recorder.Record((bool)dataPointList.CanFocus);
            recorder.Record((bool)dataPointList.CanSelect);
            recorder.Record((bool)dataPointList.Capture);
            recorder.Record((bool)dataPointList.CausesValidation);
            recorder.Record((string)dataPointList.CompanyName);
            recorder.Record((bool)dataPointList.ContainsFocus);
            recorder.Record((bool)dataPointList.ControlBox);
            recorder.Record((bool)dataPointList.Created);
            recorder.Record((DialogResult)dataPointList.DialogResult);
            recorder.Record((bool)dataPointList.Disposing);
            recorder.Record((DockStyle)dataPointList.Dock);
            recorder.Record((bool)dataPointList.Enabled);
            recorder.Record((bool)dataPointList.Focused);
            recorder.Record((FormBorderStyle)dataPointList.FormBorderStyle);
            recorder.Record((bool)dataPointList.HasChildren);
            recorder.Record((int)dataPointList.Height);
            recorder.Record((bool)dataPointList.HelpButton);
            recorder.Record((ImeMode)dataPointList.ImeMode);
            recorder.Record((bool)dataPointList.InvokeRequired);
            recorder.Record((bool)dataPointList.IsAccessible);
            recorder.Record((bool)dataPointList.IsDisposed);
            recorder.Record((bool)dataPointList.IsHandleCreated);
            recorder.Record((bool)dataPointList.IsMdiChild);
            recorder.Record((bool)dataPointList.IsMdiContainer);
            recorder.Record((bool)dataPointList.IsMirrored);
            recorder.Record((bool)dataPointList.IsRestrictedWindow);
            recorder.Record((bool)dataPointList.KeyPreview);
            recorder.Record((int)dataPointList.Left);
            recorder.Record((bool)dataPointList.MaximizeBox);
            recorder.Record((bool)dataPointList.MinimizeBox);
            recorder.Record((bool)dataPointList.Modal);
            recorder.Record((string)dataPointList.Name);
            recorder.Record((double)dataPointList.Opacity);
            recorder.Record((string)dataPointList.ProductName);
            recorder.Record((string)dataPointList.ProductVersion);
            recorder.Record((bool)dataPointList.RecreatingHandle);
            recorder.Record((int)dataPointList.Right);
            recorder.Record((RightToLeft)dataPointList.RightToLeft);
            recorder.Record((bool)dataPointList.RightToLeftLayout);
            recorder.Record((bool)dataPointList.ShowIcon);
            recorder.Record((bool)dataPointList.ShowInTaskbar);
            recorder.Record((SizeGripStyle)dataPointList.SizeGripStyle);
            recorder.Record((FormStartPosition)dataPointList.StartPosition);
            recorder.Record((bool)ReflectionAccessor.Wrap(dataPointList).GetProperty("System.Windows.Forms.Layout.IArrangedElement.ParticipatesInLayout"));
            recorder.Record((int)dataPointList.TabIndex);
            recorder.Record((bool)dataPointList.TabStop);
            recorder.Record((string)dataPointList.Text);
            recorder.Record((int)dataPointList.Top);
            recorder.Record((bool)dataPointList.TopLevel);
            recorder.Record((bool)dataPointList.TopMost);
            recorder.Record((bool)dataPointList.UseWaitCursor);
            recorder.Record((string)dataPointList.ViewID);
            recorder.Record((string)dataPointList.ViewType);
            recorder.Record((bool)dataPointList.Visible);
            recorder.Record((int)dataPointList.Width);
            recorder.Record((FormWindowState)dataPointList.WindowState);
            recorder.FinishRecording();
            #endregion
            #region Assertions
            Assert.IsNull((string)dataPointList.AccessibleDefaultActionDescription);
            Assert.IsFalse((bool)dataPointList.AllowDrop);
            Assert.AreEqual(global::System.Windows.Forms.AutoScaleMode.Font, (AutoScaleMode)dataPointList.AutoScaleMode);
            Assert.AreEqual(global::System.Windows.Forms.AutoValidate.EnablePreventFocusChange, (AutoValidate)dataPointList.AutoValidate);
            Assert.IsFalse((bool)dataPointList.CanFocus);
            Assert.AreEqual("ST Electronics Ltd", (string)dataPointList.CompanyName);
            Assert.IsFalse((bool)dataPointList.Created);
            Assert.IsTrue((bool)dataPointList.Enabled);
            Assert.IsTrue((bool)dataPointList.HasChildren);
            Assert.IsFalse((bool)dataPointList.InvokeRequired);
            Assert.IsFalse((bool)dataPointList.IsHandleCreated);
            Assert.IsFalse((bool)dataPointList.IsRestrictedWindow);
            Assert.IsFalse((bool)dataPointList.MaximizeBox);
            Assert.AreEqual(1.0, (double)dataPointList.Opacity, 1E-7);
            Assert.IsFalse((bool)dataPointList.RecreatingHandle);
            Assert.IsTrue((bool)dataPointList.ShowIcon);
            Assert.AreEqual(global::System.Windows.Forms.FormStartPosition.CenterParent, (FormStartPosition)dataPointList.StartPosition);
            Assert.AreEqual("Datapoint Viewer", (string)dataPointList.Text);
            Assert.IsFalse((bool)dataPointList.TopMost);
            Assert.IsFalse((bool)dataPointList.Visible);
            #endregion
        }
示例#9
0
 public void FixtureSetUp()
 {
     dataPointList = new DataPointList();
     //  Accessor dataPointListAccessor = ReflectionAccessor.Wrap(dataPointList);
     // dataPointListAccessor.Call("InitializeDataPointListDataGridView", null);
 }
示例#10
0
 public AreaChart(VA.Drawing.Rectangle rect)
 {
     this.Rectangle = rect;
     this.DataPoints = new DataPointList();
 }
示例#11
0
        private List <ParsingReturnStructure> ReadData(ParsedTable pt, string fileId)
        {
            PeriodTypes2017  frequency = PeriodTypes2017.Annual;
            List <Regions>   regions   = new List <Regions>();
            List <Crimes>    crimes    = new List <Crimes>();
            List <Footnotes> footnotes = new List <Footnotes>();
            List <string>    metaData  = new List <string>();

            List <ParsingReturnStructure> prsList = new List <ParsingReturnStructure>();  //Since there is a table made per region, instead of retruning one parsing return structure we are returning a list of them
            bool underArea   = false;
            int  categoryRow = 0;

            for (int row = 0; row <= 213; row++)    //Loop through the all the rows on sheet
            {
                int num;
                if (row <= 202 && pt.Vals[row, 0] != null && underArea == true) //If excel cell is not null and the range of rows occurs before footnotes
                {
                    regions.Add(new Regions(pt.Vals[row, 0].ToString(), row));
                }
                if (pt.Vals[row, 0] != null && pt.Vals[row, 0].ToString() == "Area") //If row is under the Area topic, underArea is true and indicates the starting row where regions start
                {
                    underArea   = true;
                    categoryRow = row;
                }

                if (pt.Vals[row, 0] != null && Int32.TryParse(pt.Vals[row, 0].ToString().Substring(0, 1), out num))  //Puts footnote id value and footnote into footnote object
                {
                    footnotes.Add(new Footnotes(num, pt.Vals[row, 0].ToString().Substring(1, pt.Vals[row, 0].ToString().Length - 1)));
                }
                if (pt.Vals[row, 0] != null && pt.Vals[row, 0].ToString().Substring(0, 4) == "NOTE")
                {
                    metaData.Add(pt.Vals[row, 0].ToString());
                }
            }
            for (int col = 2; col < 22; col++)  //iterates through all of crime columns and if it is not an empty cell adds to the crime object
            {
                if (pt.Vals[categoryRow, col] != null)
                {
                    crimes.Add(new Crimes(pt.Vals[categoryRow, col].ToString(), col));
                }
            }

            foreach (var region in regions)                                            //Iterates through all of the regions, with a nested loop going through all of the crimes for each region
            {
                var dataPointList                      = new DataPointList();          //The Datapoint List stores a list of datapoints
                ParsingReturnStructure prs             = new ParsingReturnStructure(); //A parsing return structure's datapoint value adds datapoint list
                List <int>             regionFootnotes = new List <int>();
                if (region.RegionName.Any(c => char.IsDigit(c)))                       //Determines if region name contains a footnote, if so adds footnote id number
                {
                    regionFootnotes = FormatFootnoteNumbers(region.RegionName);
                }

                foreach (var crime in crimes)
                {
                    List <int> crimeFootnotes = new List <int>();
                    if (crime.CrimeName.Any(c => char.IsDigit(c)))  //Determines if crime name contains a footnote, if so adds footnote id number
                    {
                        crimeFootnotes = FormatFootnoteNumbers(crime.CrimeName);
                    }
                    var  neumonic = SeriesToNeumonic(FormatString(region.RegionName) + " - " + FormatString(crime.CrimeName));  //Formats the neumonic name for the datapoint appends the region name to the crime name
                    Guid seriesId = _nk.GetValue(neumonic);
                    _nk.AddSeriesName(seriesId, region.RegionName);

                    /* foreach (var regionNote in regionFootnotes)    //this commented out section will add the footnotes into the into the prslist once other code that manipulates footnotes is changed
                     * {
                     *    foreach (var note in footnotes)
                     *    {
                     *        if (regionNote == note.FootnoteId)
                     *        {
                     *            _nk.AddFootnote(note.Value, seriesId);
                     *        }
                     *    }
                     * }
                     * foreach (var crimeNote in crimeFootnotes)
                     * {
                     *    foreach (var note in footnotes)
                     *    {
                     *        if (crimeNote == note.FootnoteId)
                     *        {
                     *            _nk.AddFootnote(note.Value, seriesId);
                     *        }
                     *    }
                     * }*/
                    int numLoops = 1;
                    if (crime.CrimeName.Contains("Population")) //Population category doesnt contain extra column pertaining to the rate of population committing a crime by 100k
                    {
                        numLoops = 0;
                    }
                    for (int col = crime.StartingCol; col <= crime.StartingCol + numLoops; col++)
                    {
                        string tempDate = "";

                        for (int row = region.StartingRow; row <= region.StartingRow + 1; row++)
                        {
                            if (row == region.StartingRow)  //Dates only have year values must be modified to into a DateTime format
                            {
                                tempDate = "12/31/2015";
                            }
                            else if (row == region.StartingRow + 1)
                            {
                                tempDate = "12/31/2016";
                            }

                            var dp = new DataPoint2017(DateTime.Parse(tempDate), frequency, decimal.Parse(pt.Vals[row, col])); //Datapoint value takes to values a Datetime value and decimal number value
                            dp.Neum           = neumonic;                                                                      //Data point takes a neumonic value as well as the parent series id, same as neumonic value unless datapoint has a parent
                            dp.ParentSeriesId = seriesId;
                            dataPointList.AddPoint(dp);                                                                        //Data point is added to the datapoint list
                        }
                        if (numLoops == 1)                                                                                     //if on second colummn of crime there is a given rate of crime per a 100k people
                        {
                            neumonic = SeriesToNeumonic(neumonic + "(RatePer100k)");
                            seriesId = _nk.GetValue(neumonic);
                            _nk.AddSeriesName(seriesId, region.RegionName);
                        }
                    }

                    BGTableInfo tableHere = new BGTableInfo();  //BGTableInfo contains relevant information for adding prs into the database at a later date
                    tableHere.TableName = region.RegionName;
                    prs.TableInfos.Add(tableHere);
                    BGTableLineInformation tableLineInfo = new BGTableLineInformation();
                    tableLineInfo.linelabel        = region.RegionName;
                    tableLineInfo.tablelineindents = 0;
                    tableLineInfo.tablelinenum     = 1;
                    tableLineInfo.objectID         = seriesId;
                    tableHere.Add(tableLineInfo);
                }

                prs.DataPoints.AddList(dataPointList); //prs adds the data point list that has accumulated all of the data points for the per one region
                prsList.Add(prs);                      // prs for one region is added prsList, prsList is what is returned
            }
            return(prsList);
        }
示例#12
0
 public Line AddLine(string label, DataPointList points)
 {
     Line line = new Line(label, points);
     mLines.Add(line);
     mUpdateLayout = true;
     return line;
 }