private void DrawHeatMap() { int GridSize = m_Model.ResultSize; m_ComparisonHeatmap.Clear(); m_ComparisonHeatmap.Add((scpl.IDrawable) new scpl.Grid() { HorizontalGridType = scpl.Grid.GridType.Fine, VerticalGridType = scpl.Grid.GridType.Fine }); double[,] data = new double[GridSize, GridSize]; string[,] cellLabels = new string[GridSize, GridSize]; for (int GeIndex1 = 0; GeIndex1 < GridSize; ++GeIndex1) { for (int GeIndex2 = 0; GeIndex2 < GridSize; ++GeIndex2) { data[GeIndex1, GeIndex2] = Convert.ToDouble(this.CalculateDifferences(m_Model.BestSoFar.Items[GeIndex1], m_Model.BestSoFar.Items[GeIndex2])); cellLabels[GeIndex1, GeIndex2] = m_Model.BestSoFar.Items[GeIndex1].Alias + " vs " + m_Model.BestSoFar.Items[GeIndex2].Alias + " " + Convert.ToInt32(data[GeIndex1, GeIndex2]).ToString() + " differences"; } } m_ComparisonHeatmap.Add((scpl.IDrawable) new scpl.ImagePlot(data, cellLabels, 1.0, 1.0, 1.0, 1.0) { Gradient = (scpl.IGradient) new scpl.LinearGradient(Color.Yellow, Color.Blue) }); m_ComparisonHeatmap.Refresh(); }
/// <summary> /// Draws a graph for the current set of values. /// </summary> private void DrawGraph() { // clear existing plot. plotCtrl_.Clear(); // update title. if (mItem_ != null && mItem_.ItemName != null && mItem_.ItemName != "") { plotCtrl_.Title = mItem_.ItemName; } // get current set of values. TsCHdaItemValueCollection values = GetValues(); if (values == null || (values.Count == 0 && (values.StartTime == DateTime.MinValue || values.EndTime == DateTime.MinValue))) { plotCtrl_.Add(new PointPlot(new ArrayAdapter(new double[] { 0, 100 }, new double[] { 0, 100 }))); plotCtrl_.XAxis1.Label = "No Data Available"; plotCtrl_.Refresh(); return; } // determine the best set of units. double units = CalculateUnits(values); // the first timestamp is the reference point for the plot. DateTime startTime = (values.Count > 0)?values[0].Timestamp:values.StartTime; // display empty set by plotting the time axis. if (values.Count == 0) { // create array. double[] xs = new double[2]; double[] ys = new double[2]; xs[0] = 0; ys[0] = 0; xs[1] = ((double)(((TimeSpan)(values.EndTime - startTime)).Ticks)) / units; ys[1] = 100; plotCtrl_.Add(new PointPlot(new ArrayAdapter(xs, ys))); plotCtrl_.XAxis1.Label = CreateLabel(startTime, units); plotCtrl_.Refresh(); return; } // create seperate plots for each quality of data. int[] qualityMasks = new int[] { 0xC0, 0x40, 0x00 }; // create different icons for each type of data. Marker[] markers = new Marker[] { new Marker(MarkerType.Circle, 4, new Pen(Color.Black)), new Marker(MarkerType.Square, 4, new Pen(Color.Blue)), new Marker(MarkerType.Cross1, 4, new Pen(Color.Red)) }; // add plots to control. for (int ii = 0; ii < qualityMasks.Length; ii++) { ArrayAdapter adpater = CreateAdapter(values, qualityMasks[ii], startTime, units); if (adpater != null) { if (adpater.Count < 40) { plotCtrl_.Add(new PointPlot(adpater, markers[ii])); } else { plotCtrl_.Add(new LinePlot(adpater)); } } } // update the label. plotCtrl_.XAxis1.Label = CreateLabel(startTime, units); // display the data. plotCtrl_.Refresh(); }