//, Type dateType)
        /// <summary>
        /// Creates a Table by a given "Sorted Measure List" with one date time column and one column for each inverter.
        /// </summary>
        /// <param name="kwhTable">Creates google data table compatible conent</param>
        /// <param name="yMode">Use Euro or kwh as y-axis</param>
        /// <param name="xMode">type of x-axis</param>
        /// <returns>Google DataTable content</returns>
        public string BuildGoogleDataTable(SortedKwhTable kwhTable, E_EurKwh yMode, E_TimeMode xMode)
        {
            //create datatable and add time column
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("Zeit", typeof(string)).Caption = "Zeit";

            //add one column for each inverter ID
            foreach (var inverterInfo in kwhTable.KnownInverters)
            {
                string caption = GetRowName(inverterInfo.Value);
                dt.Columns.Add(caption, typeof(System.Double)).Caption = caption;
            }

            //Add the data
            foreach (var row in kwhTable.Rows.Values)
            {
                //create a new row and add the time first (key)
                var rowToAdd = dt.NewRow();
                rowToAdd[0] = GetTimeCaption(row.Index, xMode);

                //add the values foreach inverter
                foreach (var measure in row.kwhValues)
                {
                    rowToAdd[GetRowName(measure.PublicInverterId)] = measure.Value * GetPerEuroFactor(yMode, measure.PublicInverterId);
                }

                //add the new row to the datatable
                dt.Rows.Add(rowToAdd);
            }

            GoogleDataTable gdt = new Bortosky.Google.Visualization.GoogleDataTable(dt);
            return gdt.GetJson();
        }
Exemple #2
0
        public void GoogleDataTableJSonTest()
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("STYLE", typeof(System.String)).Caption = "Programming Style";
            dt.Columns.Add("FUN", typeof(System.Int32)).Caption = "Fun";
            dt.Columns.Add("WORK", typeof(System.Int32)).Caption = "Work";
            dt.Rows.Add(new object[] { "Hand Coding", 30, 200 });
            dt.Rows.Add(new object[] { "Using the .NET Library", 300, 10 });
            dt.Rows.Add(new object[] { "Skipping Visualization", -50, 0 });

            GoogleDataTable gdt = new GoogleDataTable(dt);
            Console.Write(gdt.GetJson());
        }