public static PlotModel TornadoDiagram1() { // http://en.wikipedia.org/wiki/Tornado_diagram var model = new PlotModel("Tornado diagram 1") { LegendPlacement = LegendPlacement.Outside }; var s1 = new BarSeries { Title = "High", IsStacked = true, FillColor = OxyColor.FromRGB(216, 82, 85), BaseValue = 7, StrokeColor = OxyColors.Black, StrokeThickness = 1 }; s1.Items.Add(new BarItem(1)); s1.Items.Add(new BarItem(1)); s1.Items.Add(new BarItem(4)); s1.Items.Add(new BarItem(5)); var s2 = new BarSeries { Title = "Low", IsStacked = true, FillColor = OxyColor.FromRGB(84, 138, 209), BaseValue = 7, StrokeColor = OxyColors.Black, StrokeThickness = 1 }; s2.Items.Add(new BarItem(-1)); s2.Items.Add(new BarItem(-3)); s2.Items.Add(new BarItem(-2)); s2.Items.Add(new BarItem(-3)); var categoryAxis = new CategoryAxis { Position = AxisPosition.Left }; categoryAxis.Labels.Add("F/X rate"); categoryAxis.Labels.Add("Inflation"); categoryAxis.Labels.Add("Price"); categoryAxis.Labels.Add("Conversion"); var valueAxis = new LinearAxis(AxisPosition.Bottom) { ExtraGridlines = new[] { 7.0 } }; model.Series.Add(s1); model.Series.Add(s2); model.Axes.Add(categoryAxis); model.Axes.Add(valueAxis); return(model); }
/// <summary> /// Creates a 'hot' palette with the specified number of colors. /// </summary> /// <param name="numberOfColors"> /// The number of colors to create for the palette. /// </param> /// <returns> /// A palette. /// </returns> public static OxyPalette Hot(int numberOfColors) { return(OxyPalette.Interpolate( numberOfColors, OxyColors.Black, OxyColor.FromRGB(127, 0, 0), OxyColor.FromRGB(255, 127, 0), OxyColor.FromRGB(255, 255, 127), OxyColors.White)); }
private void UpdatePlot() { if (ChosenField.Equals(default(KeyValuePair <string, double>))) { return; } if (m_featureHistogram == null) { m_featureHistogram = new PlotModel(); m_featureHistogram.PlotMargins = new OxyThickness(-10, -10, 0, 0); m_featureHistogram.PlotAreaBorderThickness = 1; m_featureHistogram.LegendTextColor = OxyColor.FromRGB(0x92, 0x92, 0x92); m_featureHistogram.LegendMargin = 0; m_featureHistogram.LegendSymbolMargin = 0; m_featureHistogram.LegendBorderThickness = 0; m_featureHistogram.LegendBackground = OxyColors.Transparent; m_featureHistogram.LegendOrientation = LegendOrientation.Horizontal; m_featureHistogram.LegendPlacement = LegendPlacement.Inside; m_featureHistogram.LegendPadding = 0; m_xAxis = new CategoryAxis(); m_xAxis.Position = AxisPosition.Bottom; m_xAxis.MajorGridlineStyle = LineStyle.Solid; m_xAxis.MajorGridlineThickness = 1; m_xAxis.MinorGridlineThickness = 0; m_xAxis.TickStyle = TickStyle.None; m_xAxis.IsPanEnabled = false; m_xAxis.IsZoomEnabled = false; m_featureHistogram.Axes.Add(m_xAxis); m_yAxis = new LinearAxis(); m_yAxis.Position = AxisPosition.Left; m_featureHistogram.Axes.Add(m_yAxis); m_featureHistogramPlotPoints = new ColumnSeries(); m_featureHistogram.Series.Add(m_featureHistogramPlotPoints); m_featureHistogramPlotPointsOther = new ColumnSeries(); m_featureHistogram.Series.Add(m_featureHistogramPlotPointsOther); } m_featureHistogramPlotPoints.Items.Clear(); m_featureHistogramPlotPointsOther.Items.Clear(); var field = AppDataCenter.Singleton.EntireModelStats.fieldList.First(b => b.name == ChosenField.Key); var fields = AppDataCenter.Singleton.EntireModelStats.fieldList.Where(b => b.name != ChosenField.Key).ToList(); fields.Add(AppDataCenter.Singleton.EntireModelStats.notAName); var featureId = AppDataCenter.Singleton.ChosenFeatures.FindIndex(x => x.Name == SelectedFeature.Key); if (featureId >= 0) { var histogram = AppDataCenter.Singleton.EntireModelStats.GetFeatureFieldHistogram(10, featureId, field); var histogramGraph = histogram.GetHistogramGraphNormalized(); var histogramOther = AppDataCenter.Singleton.EntireModelStats.GetFeatureFieldHistogram(10, featureId, fields); var histogramGraphIther = histogramOther.GetHistogramGraphNormalized(); if (histogramGraph.Keys.Last() > 50) { m_xAxis.Labels = histogramGraph.Keys.Select(x => x.ToString("F0")).ToArray(); } else if (histogramGraph.Keys.Last() > 5) { m_xAxis.Labels = histogramGraph.Keys.Select(x => x.ToString("F1")).ToArray(); } else { m_xAxis.Labels = histogramGraph.Keys.Select(x => x.ToString("F2")).ToArray(); } foreach (var histogramData in histogramGraph) { m_featureHistogramPlotPoints.Items.Add(new ColumnItem(histogramData.Value)); } foreach (var histogramData in histogramGraphIther) { m_featureHistogramPlotPointsOther.Items.Add(new ColumnItem(histogramData.Value, -1, OxyColors.Blue)); } } if (m_featureHistogram.PlotControl != null) { m_featureHistogram.PlotControl.RefreshPlot(); } OnPropertyChanged("FeatureHistogram"); }