public DisplayMetricChart AddDataSet(string name, int datasetID, string legend, string type) { using (var _gorillaCtx = new MSGorillaEntities()) { MetricChart chart = _gorillaCtx.MetricCharts.Find(name); if (chart == null) { throw new MetricChartNotFoundException(); } MetricDataSet data = _gorillaCtx.MetricDataSets.Find(datasetID); if (data == null) { throw new MetricDataSetNotFoundException(); } if (!chart.GroupID.Equals(data.GroupID, StringComparison.InvariantCultureIgnoreCase)) { throw new MetricGroupDismatchException(); } Chart_DataSet dataset = new Chart_DataSet(); dataset.MetricChartName = name; dataset.MetricDataSetID = datasetID; dataset.Legend = legend; dataset.Type = type; _gorillaCtx.Chart_DataSet.Add(dataset); _gorillaCtx.SaveChanges(); return(dataset.MetricChart); } }
public DisplayMetricChart CreateChart(string name, string group, string title, string subtitle = null) { using (var _gorillaCtx = new MSGorillaEntities()) { MetricChart chart = new MetricChart(); chart.Name = name; chart.GroupID = group; chart.Title = title; chart.SubTitle = subtitle; _gorillaCtx.MetricCharts.Add(chart); _gorillaCtx.SaveChanges(); return(chart); } }
/// <summary> /// Create a new instance of the <see cref="CreateMetricChartAlertProperty"/> class based on the given values. /// </summary> /// <param name="chartPropertyName">The chart's property name.</param> /// <param name="chartDisplayName">The chart's display name.</param> /// <param name="order">The order to use.</param> /// <param name="metricChart">The chart's details.</param> /// <returns>The newly created <see cref="MetricChartAlertProperty"/> instance.</returns> private static MetricChartAlertProperty CreateMetricChartAlertProperty( string chartPropertyName, string chartDisplayName, Order order, MetricChart metricChart) { ContractsStaticThreshold staticThreshold = metricChart.StaticThreshold == null ? null : new ContractsStaticThreshold { LowerThreshold = metricChart.StaticThreshold.LowerThreshold, UpperThreshold = metricChart.StaticThreshold.UpperThreshold }; ContractsDynamicThreshold dynamicThreshold = metricChart.DynamicThreshold == null ? null : new ContractsDynamicThreshold(new ContractsDynamicThresholdFailingPeriodsSettings(metricChart.DynamicThreshold.FailingPeriodsSettings.ConsecutivePeriods, metricChart.DynamicThreshold.FailingPeriodsSettings.ConsecutiveViolations), metricChart.DynamicThreshold.Sensitivity) { IgnoreDataBefore = metricChart.DynamicThreshold.IgnoreDataBefore }; return(new MetricChartAlertProperty( chartPropertyName, chartDisplayName, order.Next(), metricChart.MetricName, metricChart.TimeGrain, ConvertAggregationTypeToContractsAggregationType(metricChart.AggregationType)) { ResourceId = metricChart.ResourceId, MetricNamespace = metricChart.MetricNamespace, MetricDimensions = new Dictionary <string, string>(metricChart.MetricDimensions), StartTimeUtc = metricChart.StartTimeUtc, EndTimeUtc = metricChart.EndTimeUtc, ThresholdType = ConvertThresholdTypeToContractsThresholdType(metricChart.ThresholdType), StaticThreshold = staticThreshold, DynamicThreshold = dynamicThreshold }); }
private void Populate() { ltMetric.Text = GetDisplayNameForMetric(); DataSet ds = GetData(); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { ltProvider.Text = (ds.Tables[0].Rows[0]["Provider"] != null) ? ds.Tables[0].Rows[0]["Provider"].ToString() : string.Empty; MetricChart.Series["Series1"].XValueMember = "Current_MonthName"; MetricChart.Series["Series1"].YValueMembers = GetColumnNameForMetric(); if (ds.Tables[0].Columns.Contains(ChartType + "SL_avg")) { MetricChart.Series["Series2"].XValueMember = "Current_MonthName"; MetricChart.Series["Series2"].YValueMembers = ChartType + "SL_avg"; } if (ds.Tables[0].Columns.Contains(ChartType + "USL")) { MetricChart.Series["Series3"].XValueMember = "Current_MonthName"; MetricChart.Series["Series3"].YValueMembers = ChartType + "USL"; } if (ds.Tables[0].Columns.Contains(ChartType + "LSL")) { MetricChart.Series["Series4"].XValueMember = "Current_MonthName"; MetricChart.Series["Series4"].YValueMembers = ChartType + "LSL"; } MetricChart.DataSource = ds; MetricChart.DataBind(); /* Begin fake data points for right side label extension */ int max = 2; for (int i = 0; i < max; i++) { if (MetricChart.Series["Series2"].Points.Count > 0) { int ct = MetricChart.Series["Series2"].Points.Count; string val = MetricChart.Series["Series2"].Points[ct - 1].YValues[0].ToString("0.00"); MetricChart.Series["Series2"].Points.Insert(ct, new DataPoint(0.00, val)); MetricChart.Series["Series2"].Points[ct].Color = System.Drawing.Color.White; if (i == max - 1) { if (i == 1) { MetricChart.Series["Series2"].Points[ct].Label = "Center line = " + val; MetricChart.Series["Series2"].Points[ct].LabelBackColor = System.Drawing.Color.White; MetricChart.Series["Series2"].Points[ct].LabelForeColor = System.Drawing.Color.Black; } } } if (MetricChart.Series["Series3"].Points.Count > 0) { int ct = MetricChart.Series["Series3"].Points.Count; string val = MetricChart.Series["Series3"].Points[ct - 1].YValues[0].ToString("0.00"); MetricChart.Series["Series3"].Points.Insert(ct, new DataPoint(0.00, val)); MetricChart.Series["Series3"].Points[ct].Color = System.Drawing.Color.White; if (i == 1) { MetricChart.Series["Series3"].Points[ct].Label = "UCL = " + val; MetricChart.Series["Series3"].Points[ct].LabelBackColor = System.Drawing.Color.White; MetricChart.Series["Series3"].Points[ct].LabelForeColor = System.Drawing.Color.Black; MetricChart.ChartAreas["MainChartArea"].AxisX.MajorGrid.Enabled = false; MetricChart.ChartAreas["MainChartArea"].AxisY.MajorGrid.Enabled = false; } } if (MetricChart.Series["Series4"].Points.Count > 0) { int ct = MetricChart.Series["Series4"].Points.Count; string val = MetricChart.Series["Series4"].Points[ct - 1].YValues[0].ToString("0.00"); MetricChart.Series["Series4"].Points.Insert(ct, new DataPoint(0.00, val)); MetricChart.Series["Series4"].Points[ct].Color = System.Drawing.Color.White; if (i == 1) { MetricChart.Series["Series4"].Points[ct].Label = "LCL = " + val; MetricChart.Series["Series4"].Points[ct].LabelBackColor = System.Drawing.Color.White; MetricChart.Series["Series4"].Points[ct].LabelForeColor = System.Drawing.Color.Black; } } } /* End fake data points for label extension */ } else { Response.Write("No Chart Data found"); //Response.Redirect("GoogleMap.aspx"); } }