public DesafioCursoViewModel(Desafio desafio, Curso curso) { CursoId = curso.Id; Desafio = desafio; var query = desafio.Calificaciones .Where(cal => cal.CursoId == CursoId) .ToList(); var total = curso.Estudiantes.Count(); var numT = query.Count(cal => cal.Terminada); DistActividad = new List <SingleValueSeriesViewModel>() { new SingleValueSeriesViewModel() { Data = numT, Label = $"{ChartUtil.Percentage(numT, total)}%", Name = "Terminaron" }, new SingleValueSeriesViewModel() { Data = total - numT, Label = $"{ChartUtil.Percentage(total - numT, total)}%", Name = "Sin Terminar" }, }; }
public PieChartViewModel GetDistActividad(string clss, string labelPosition, int labelOffset, bool showLabel = true) { return(ChartUtil.GetPieChartViewModel(DistActividad, "chart-activity", clss, labelPosition, labelOffset, showLabel)); }
private void SetupYAxis() { double axisMin, axisMax; if (automaticYAxisCheckBox.Checked) { double min = double.MaxValue, max = double.MinValue; foreach (var chart in VisiblePartialDependencePlots) { if (chart.YMin < min) { min = chart.YMin; } if (chart.YMax > max) { max = chart.YMax; } } double axisInterval; ChartUtil.CalculateAxisInterval(min, max, 5, out axisMin, out axisMax, out axisInterval); } else { axisMin = limitView.Content.Lower; axisMax = limitView.Content.Upper; } foreach (var chart in VisiblePartialDependencePlots) { chart.FixedYAxisMin = axisMin; chart.FixedYAxisMax = axisMax; } }
/// <summary> /// Returns an array of Highlight objects for the given index. The Highlight /// objects give information about the value at the selected index and the /// DataSet it belongs to. INFORMATION: This method does calculations at <paramref name="index"/> /// runtime. Do not over-use in performance critical situations. /// <returns></returns> protected List <Highlight> GetHighlightsAtIndex(int index) { highlightBuffer.Clear(); float phaseX = Chart.Animator.PhaseX; float phaseY = Chart.Animator.PhaseY; float sliceangle = Chart.SliceAngle; float factor = Chart.Factor; var data = Chart.Data; for (int i = 0; i < data.DataSetCount; i++) { IDataSet <RadarEntry> dataSet = data[i]; Entry entry = dataSet[index]; float y = entry.Y - Chart.YChartMin; var pOut = ChartUtil.GetPosition( Chart.CenterOffsets, y * factor * phaseY, sliceangle * index * phaseX + Chart.RotationAngle); highlightBuffer.Add(new Highlight(index, entry.Y, pOut.X, pOut.Y, i, dataSet.AxisDependency)); } return(highlightBuffer); }
private void control_Paint(object sender, PaintEventArgs e) { Matrix transform = new Matrix(); if (m_transformAdapter != null) { transform = m_transformAdapter.Transform; } RectangleF clientRect = AdaptedControl.ClientRectangle; if (m_canvasAdapter != null) { clientRect = m_canvasAdapter.WindowBounds; } RectangleF canvasRect = GdiUtil.InverseTransform(transform, clientRect); if (m_horizontalVisible) { ChartUtil.DrawHorizontalScale( transform, canvasRect, false, m_verticalTickSpacing, 0, m_theme.OutlinePen, m_theme.Font, m_theme.TextBrush, e.Graphics); } if (m_verticalVisible) { ChartUtil.DrawVerticalScale( transform, canvasRect, true, m_horizontalTickSpacing, 0, m_theme.OutlinePen, m_theme.Font, m_theme.TextBrush, e.Graphics); } }
private IList <DensityTrackbar> CreateConfiguration() { var ranges = new List <DoubleLimit>(); foreach (string variableName in variableNames) { var values = Content.ProblemData.Dataset.GetDoubleValues(variableName, Content.ProblemData.AllIndices); double min, max, interval; ChartUtil.CalculateAxisInterval(values.Min(), values.Max(), 10, out min, out max, out interval); ranges.Add(new DoubleLimit(min, max)); } var newTrackbars = new List <DensityTrackbar>(); for (int i = 0; i < variableNames.Count; i++) { var name = variableNames[i]; var trainingData = Content.ProblemData.Dataset.GetDoubleValues(name, Content.ProblemData.TrainingIndices).ToList(); var dimensionTrackbar = new DensityTrackbar(name, ranges[i], trainingData) { Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right }; newTrackbars.Add(dimensionTrackbar); } return(newTrackbars); }
public static double GetDensity(double massConcentraiton, double temperature, MilkType milkType) { temperature = temperature - 273.15; //MaterialComponent dryMatComponent = materialComponents[0] as MaterialComponent; //double dryMatFraction = dryMatComponent.GetMassFractionValue(); double a = 0; double b = 0; double c = 0; if (milkType == MilkType.SkimMilk) { a = ChartUtil.GetInterpolateValue(skimMilkA, temperature); b = ChartUtil.GetInterpolateValue(skimMilkB, temperature); c = ChartUtil.GetInterpolateValue(skimMilkC, temperature); } else if (milkType == MilkType.WholeMilk) { a = ChartUtil.GetInterpolateValue(skimMilkA, temperature); b = ChartUtil.GetInterpolateValue(skimMilkB, temperature); } double density = a + b * massConcentraiton + c * massConcentraiton * massConcentraiton; return(1000 * density); }
public override void RenderAxisLabels(SKCanvas c) { if (!YAxis.IsEnabled || !YAxis.IsDrawLabelsEnabled) { return; } AxisLabelPaint.Typeface = YAxis.Typeface; AxisLabelPaint.TextSize = YAxis.TextSize; AxisLabelPaint.Color = YAxis.TextColor; // calculate the factor that is needed for transforming the value to // pixels float factor = Chart.Factor; var center = Chart.CenterOffsets; int from = YAxis.DrawBottomYLabelEntry ? 0 : 1; int to = YAxis.DrawTopYLabelEntry ? YAxis.EntryCount : (YAxis.EntryCount - 1); float xOffset = YAxis.XLabelOffset; for (int j = from; j < to; j++) { float r = (YAxis.entries[j] - YAxis.axisMinimum) * factor; var pOut = ChartUtil.GetPosition(center, r, Chart.RotationAngle); var label = YAxis.GetFormattedLabel(j); c.DrawText(label, pOut.X + xOffset, pOut.Y, AxisLabelPaint); } }
private void control_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { if (m_visible) { bool disposeOfTransform = false; Matrix transform; if (m_transformAdapter != null) { transform = m_transformAdapter.Transform; } else { transform = new Matrix(); disposeOfTransform = true; } RectangleF clientRect = AdaptedControl.ClientRectangle; RectangleF canvasRect = GdiUtil.InverseTransform(transform, clientRect); // draw horizontal lines ChartUtil.DrawHorizontalGrid(transform, canvasRect, m_verticalGridSpacing, m_gridColor, e.Graphics); // draw vertical lines ChartUtil.DrawVerticalGrid(transform, canvasRect, m_horizontalGridSpacing, m_gridColor, e.Graphics); if (disposeOfTransform) { transform.Dispose(); } } }
TestGetLogAxisGridlineValues2() { Single [] afGridlineValues = ChartUtil.GetLogAxisGridlineValues(1.0F, 1.0F); Assert.AreEqual(2, afGridlineValues.Length); Assert.AreEqual(1.0F, afGridlineValues[0]); Assert.AreEqual(10.0F, afGridlineValues[1]); }
TestGetLogAxisGridlineValues4() { Double [] adGridlineValues = ChartUtil.GetLogAxisGridlineValues(0.3, 0.3); Assert.AreEqual(2, adGridlineValues.Length); Assert.AreEqual(0.1, adGridlineValues[0]); Assert.AreEqual(1.0, adGridlineValues[1]); }
TestGetLogAxisGridlineValues2() { Double [] adGridlineValues = ChartUtil.GetLogAxisGridlineValues(1.0, 1.0); Assert.AreEqual(2, adGridlineValues.Length); Assert.AreEqual(1.0, adGridlineValues[0]); Assert.AreEqual(10.0, adGridlineValues[1]); }
/// <summary> /// <see cref="ChartElementBase"/> 형식의 Element 객체들을 XML Element Node로 생성합니다. /// </summary> /// <param name="writer">Element를 쓸 Writer</param> protected override void GenerateXmlElements(System.Xml.XmlWriter writer) { base.GenerateXmlElements(writer); if (Value.HasValue) { ChartUtil.WriteElementText(writer, "value", Value.ToString()); } }
TestGetLogAxisGridlineValues4() { Single [] afGridlineValues = ChartUtil.GetLogAxisGridlineValues(0.3F, 0.3F); Assert.AreEqual(2, afGridlineValues.Length); Assert.AreEqual(0.1F, afGridlineValues[0]); Assert.AreEqual(1.0F, afGridlineValues[1]); }
public override void RenderLimitLines(SKCanvas c) { var limitLines = YAxis.LimitLines; if (limitLines == null) { return; } float sliceangle = Chart.SliceAngle; // calculate the factor that is needed for transforming the value to // pixels float factor = Chart.Factor; var center = Chart.CenterOffsets; for (int i = 0; i < limitLines.Count; i++) { LimitLine l = limitLines[i]; if (!l.IsEnabled) { continue; } LimitLinePaint.Color = l.LineColor; LimitLinePaint.PathEffect = l.DashPathEffect; LimitLinePaint.StrokeWidth = l.LineWidth; float r = (l.Limit - Chart.YChartMin) * factor; var limitPath = RenderLimitLinesPathBuffer; limitPath.Reset(); int entryCount = Chart.Data.GetMaxEntryCountSet().EntryCount; for (int j = 0; j < entryCount; j++) { var pOut = ChartUtil.GetPosition(center, r, sliceangle * j + Chart.RotationAngle); if (j == 0) { limitPath.MoveTo(pOut.X, pOut.Y); } else { limitPath.LineTo(pOut.X, pOut.Y); } } limitPath.Close(); c.DrawPath(limitPath, LimitLinePaint); } }
internal static double CalculateCollectionEfficiency(double dpiDpth, CycloneInletConfiguration inletConfiguration) { if (inletConfiguration == CycloneInletConfiguration.Tangential) { return(ChartUtil.GetInterpolateValue(ceDiamCorrectionCurve1, Math.Log10(dpiDpth))); } else { return(ChartUtil.GetInterpolateValue(ceDiamCorrectionCurve2, Math.Log10(dpiDpth))); } }
internal static double CorrectedCollectionEfficiency(double e0, ParticleTypeGroup particleType, double loading) { if (particleType == ParticleTypeGroup.A || particleType == ParticleTypeGroup.C) { return(ChartUtil.GetInterpolatedValue(ceLoadingCorrectionCurvesAC, e0, Math.Log10(loading))); } else { return(ChartUtil.GetInterpolatedValue(ceLoadingCorrectionCurvesBD, e0, Math.Log10(loading))); } }
//Section 7-26 of Handbook of Chemical Engineering Calculations //This correlation is very similar to Perry's Equation 5-101 //massFlowRate is the condensate flow rate public static double CalculateInTubeHorizontalHTC_StratifiedFlow(double massFlowRate, double diameter, double length, double liqDensity, double liqViscosity, double liqThermalCond) { double tempValue = liqDensity * liqDensity * 9.8065 * length / (liqViscosity * massFlowRate); double h = 0.767 * liqThermalCond * Math.Pow(tempValue, 1.0 / 3.0); //need to do correction according to W/(rho * Math.Pow(Di, 2.56)) //W is in Ibm/hr, rho is in Ibm/ft3, Di is in ft tempValue = (massFlowRate / 1.25997881e-4) / (liqDensity / 16.0184634 * Math.Pow(diameter / 0.3048, 2.56)); double correctionFactor = ChartUtil.GetInterpolateValue(stratifiedFlowCorrectionCurve, tempValue); return(h * correctionFactor); }
TestGetLogAxisGridlineValues() { Single [] afGridlineValues = ChartUtil.GetLogAxisGridlineValues(0.3F, 103.0F); Assert.AreEqual(5, afGridlineValues.Length); Assert.AreEqual(0.1F, afGridlineValues[0]); Assert.AreEqual(1.0F, afGridlineValues[1]); Assert.AreEqual(10.0F, afGridlineValues[2]); Assert.AreEqual(100.0F, afGridlineValues[3]); Assert.AreEqual(1000.0F, afGridlineValues[4]); }
TestGetLogAxisGridlineValues() { Double [] adGridlineValues = ChartUtil.GetLogAxisGridlineValues(0.3, 103.0); Assert.AreEqual(5, adGridlineValues.Length); Assert.AreEqual(0.1, adGridlineValues[0]); Assert.AreEqual(1.0, adGridlineValues[1]); Assert.AreEqual(10.0, adGridlineValues[2]); Assert.AreEqual(100.0, adGridlineValues[3]); Assert.AreEqual(1000.0, adGridlineValues[4]); }
/// <summary> /// Fusion Chart 에 대한 HTML 을 Response에 씁니다. /// </summary> /// <param name="output">Rendering 대상 HtmlTextWriter</param> protected override void RenderContents(HtmlTextWriter output) { if (IsDebugEnabled) { log.Debug(@"FusionChart Control을 HTML로 Rending을 시작합니다... ChartId={0}, FileName={1}", ChartId, FileName); } output.WriteLine(FusionCharts_Javascript); output.WriteLine(FusionChartsExportComponent_Javascript); var filename = FileName; if (filename.StartsWith("~") || filename.Contains("/") || filename.Contains(@"\")) { filename = WebTool.GetScriptPath(filename); } else { filename = HandlerSettings.ResourceFileHandler + "?File=" + filename; } if (IsDebugEnabled) { log.Debug(@"Render FusionChart WebControl. " + @"Chart Filename={0}, DataUrl={1}, DataXml={2}, ChartId={3}, Width={4}, Height={5}, DebugMode={6}, RegisterWithJS={7}, Transparent={8}", filename, DataUrl, DataXml, ChartId, Width, Height, DebugMode, RegisterWithJS, Transparent); } var html = ChartUtil.RenderChartHtml(filename, DataUrl, DataXml, ChartId, Width.ToString(), Height.ToString(), DebugMode, RegisterWithJS, Transparent); if (IsDebugEnabled) { log.Debug("Rendering Html= " + html); } output.WriteLine(); output.WriteLine(html); output.WriteLine(); if (IsDebugEnabled) { log.Debug(@"FusionChart Control을 HTML로 Rending을 완료했습니다!!! ChartId={0}, FileName={1}", ChartId, FileName); } }
private void RecalculateTrainingLimits(bool initializeAxisRanges) { trainingMin = solutions.Select(s => s.ProblemData.Dataset.GetDoubleValues(freeVariable, s.ProblemData.TrainingIndices).Min()).Max(); trainingMax = solutions.Select(s => s.ProblemData.Dataset.GetDoubleValues(freeVariable, s.ProblemData.TrainingIndices).Max()).Min(); if (initializeAxisRanges) { double xmin, xmax, xinterval; ChartUtil.CalculateAxisInterval(trainingMin, trainingMax, XAxisTicks, out xmin, out xmax, out xinterval); FixedXAxisMin = xmin; FixedXAxisMax = xmax; } }
/// <summary> /// <see cref="ChartElementBase"/> 형식의 Element 객체들을 XML Element Node로 생성합니다. /// </summary> /// <param name="writer">Element를 쓸 Writer</param> protected override void GenerateXmlElements(XmlWriter writer) { base.GenerateXmlElements(writer); if (Value.HasValue) { ChartUtil.WriteElementText(writer, "value", Value.ToString()); } if (Target.HasValue) { ChartUtil.WriteElementText(writer, "target", Target.ToString()); } }
private void UpdateSeries() { if (InvokeRequired) { Invoke((Action)UpdateSeries); } else { string targetVariableName = Content.ProblemData.TargetVariable; var dataset = Content.ProblemData.Dataset; if (this.chart.Series[ALL_SERIES].Points.Count > 0) { this.chart.Series[ALL_SERIES].Points.DataBindXY(dataset.GetDoubleValues(targetVariableName).ToArray(), "", Content.EstimatedValues.ToArray(), ""); } if (this.chart.Series[TRAINING_SERIES].Points.Count > 0) { this.chart.Series[TRAINING_SERIES].Points.DataBindXY(dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TrainingIndices).ToArray(), "", Content.EstimatedTrainingValues.ToArray(), ""); } if (this.chart.Series[TEST_SERIES].Points.Count > 0) { this.chart.Series[TEST_SERIES].Points.DataBindXY(dataset.GetDoubleValues(targetVariableName, Content.ProblemData.TestIndices).ToArray(), "", Content.EstimatedTestValues.ToArray(), ""); } double max = Content.EstimatedTrainingValues .Concat(Content.EstimatedTestValues .Concat(Content.EstimatedValues .Concat(dataset.GetDoubleValues(targetVariableName)))) .Where(v => !double.IsNaN(v) && !double.IsInfinity(v)).Max(); double min = Content.EstimatedTrainingValues .Concat(Content.EstimatedTestValues .Concat(Content.EstimatedValues .Concat(dataset.GetDoubleValues(targetVariableName)))) .Where(v => !double.IsNaN(v) && !double.IsInfinity(v)).Min(); double axisMin, axisMax, axisInterval; ChartUtil.CalculateOptimalAxisInterval(min, max, out axisMin, out axisMax, out axisInterval); this.chart.ChartAreas[0].AxisY.Title = "Estimated " + targetVariableName; this.chart.ChartAreas[0].AxisY.Maximum = axisMax; this.chart.ChartAreas[0].AxisY.Minimum = axisMin; this.chart.ChartAreas[0].AxisY.Interval = axisInterval; this.chart.ChartAreas[0].AxisX.Title = targetVariableName; this.chart.ChartAreas[0].AxisX.Maximum = axisMax; this.chart.ChartAreas[0].AxisX.Minimum = axisMin; this.chart.ChartAreas[0].AxisX.Interval = axisInterval; UpdateCursorInterval(); } }
TestGetLogAxisGridlineValues6() { // Backward values. Double [] adGridlineValues = ChartUtil.GetLogAxisGridlineValues(103.0, 0.3); Assert.AreEqual(5, adGridlineValues.Length); Assert.AreEqual(0.1, adGridlineValues[0]); Assert.AreEqual(1.0, adGridlineValues[1]); Assert.AreEqual(10.0, adGridlineValues[2]); Assert.AreEqual(100.0, adGridlineValues[3]); Assert.AreEqual(1000.0, adGridlineValues[4]); }
TestGetLogAxisGridlineValues5() { Single [] afGridlineValues = ChartUtil.GetLogAxisGridlineValues(0.119F, 138495.24F); Assert.AreEqual(8, afGridlineValues.Length); Assert.AreEqual(0.1F, afGridlineValues[0]); Assert.AreEqual(1.0F, afGridlineValues[1]); Assert.AreEqual(10.0F, afGridlineValues[2]); Assert.AreEqual(100.0F, afGridlineValues[3]); Assert.AreEqual(1000.0F, afGridlineValues[4]); Assert.AreEqual(10000.0F, afGridlineValues[5]); Assert.AreEqual(100000.0F, afGridlineValues[6]); Assert.AreEqual(1000000.0F, afGridlineValues[7]); }
//Perry's Figure 5-10, also see section 7-25 of Handbook of Chemical Engineering Calculations //Fist correlation to use to calculate condensing heat transfer coefficient in vertical tubes //This correlation can also be used for falling film heat transfer coeeficient. But the result //should be multiplied by 0.75 public static double CalculateVerticalTubeHTC_Dukler(double massFlowRate, double diameter, double liqDensity, double vapDensity, double liqViscosity, double vapViscosity, double liqThermalCond, double liqSpecificHeat) { double gamma = massFlowRate / (Math.PI * diameter); double Re = 4 * gamma / liqViscosity; double Pr = liqSpecificHeat * liqViscosity / liqThermalCond; double temp = Math.Pow(liqViscosity * liqViscosity / (liqDensity * liqDensity * liqThermalCond * liqThermalCond * liqThermalCond * 9.8065), 1 / 3); double h = ChartUtil.GetInterpolatedValue(duklerCurves, Re, Pr); h = h / temp; //Handbook of Chemical Engineering Calculations--page 7-50 table (the only table on this page) double Ad = 0.25 * Math.Pow(liqViscosity, 1.173) * Math.Pow(vapViscosity, 0.16) / (Math.Pow(9.8065, 2.0 / 3.0) * diameter * diameter * Math.Pow(liqDensity, 0.553) * Math.Pow(vapDensity, 0.78)); double correctionCoeff = ChartUtil.GetInterpolatedValue(duklerCorrectionCurves, Re, Ad); return(correctionCoeff * h); }
TestGetLogAxisGridlineValues5() { Double [] adGridlineValues = ChartUtil.GetLogAxisGridlineValues(0.119, 138495.24); Assert.AreEqual(8, adGridlineValues.Length); Assert.AreEqual(0.1, adGridlineValues[0]); Assert.AreEqual(1.0, adGridlineValues[1]); Assert.AreEqual(10.0, adGridlineValues[2]); Assert.AreEqual(100.0, adGridlineValues[3]); Assert.AreEqual(1000.0, adGridlineValues[4]); Assert.AreEqual(10000.0, adGridlineValues[5]); Assert.AreEqual(100000.0, adGridlineValues[6]); Assert.AreEqual(1000000.0, adGridlineValues[7]); }
private static void SetupAxis(EnhancedChart chart, Axis axis, double minValue, double maxValue, int ticks, double?fixedAxisMin, double?fixedAxisMax) { //guard if only one distinct value is present if (minValue.IsAlmost(maxValue)) { minValue = minValue - 0.5; maxValue = minValue + 0.5; } double axisMin, axisMax, axisInterval; ChartUtil.CalculateAxisInterval(minValue, maxValue, ticks, out axisMin, out axisMax, out axisInterval); axis.Minimum = fixedAxisMin ?? axisMin; axis.Maximum = fixedAxisMax ?? axisMax; axis.Interval = (axis.Maximum - axis.Minimum) / ticks; chart.ChartAreas[0].RecalculateAxesScale(); }
private void SetupAxis(Axis axis, double minValue, double maxValue, int ticks, double?fixedAxisMin, double?fixedAxisMax) { if (minValue < maxValue) { double axisMin, axisMax, axisInterval; ChartUtil.CalculateAxisInterval(minValue, maxValue, ticks, out axisMin, out axisMax, out axisInterval); axis.Minimum = fixedAxisMin ?? axisMin; axis.Maximum = fixedAxisMax ?? axisMax; axis.Interval = (axis.Maximum - axis.Minimum) / ticks; } try { chart.ChartAreas[0].RecalculateAxesScale(); } catch (InvalidOperationException) { // Can occur if eg. axis min == axis max } }