[2908] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[14185] | 3 | * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[2908] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
[4068] | 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Drawing;
|
---|
[3703] | 25 | using System.Linq;
|
---|
[4068] | 26 | using System.Windows.Forms;
|
---|
[2908] | 27 | using System.Windows.Forms.DataVisualization.Charting;
|
---|
[14435] | 28 | using HeuristicLab.Collections;
|
---|
[14519] | 29 | using HeuristicLab.MainForm.WindowsForms;
|
---|
[2908] | 30 |
|
---|
| 31 | namespace HeuristicLab.Analysis.Views {
|
---|
[14519] | 32 | public partial class DataTableControl : AsynchronousContentView {
|
---|
[5097] | 33 | protected List<Series> invisibleSeries;
|
---|
| 34 | protected Dictionary<IObservableList<double>, DataRow> valuesRowsTable;
|
---|
[7244] | 35 |
|
---|
[14519] | 36 | public new DataTable Content {
|
---|
| 37 | get { return (DataTable)base.Content; }
|
---|
| 38 | set { base.Content = value; }
|
---|
[2908] | 39 | }
|
---|
| 40 |
|
---|
[14439] | 41 | public DataTableControl() {
|
---|
[2908] | 42 | InitializeComponent();
|
---|
| 43 | valuesRowsTable = new Dictionary<IObservableList<double>, DataRow>();
|
---|
[3703] | 44 | invisibleSeries = new List<Series>();
|
---|
[4636] | 45 | chart.CustomizeAllChartAreas();
|
---|
| 46 | chart.ChartAreas[0].CursorX.Interval = 1;
|
---|
[14435] | 47 | chart.ContextMenuStrip.Items.Add(configureToolStripMenuItem);
|
---|
[2908] | 48 | }
|
---|
| 49 |
|
---|
[6342] | 50 | #region Event Handler Registration
|
---|
[14519] | 51 | protected override void DeregisterContentEvents() {
|
---|
[2908] | 52 | foreach (DataRow row in Content.Rows)
|
---|
| 53 | DeregisterDataRowEvents(row);
|
---|
[4870] | 54 | Content.VisualPropertiesChanged -= new EventHandler(Content_VisualPropertiesChanged);
|
---|
[2908] | 55 | Content.Rows.ItemsAdded -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded);
|
---|
| 56 | Content.Rows.ItemsRemoved -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsRemoved);
|
---|
| 57 | Content.Rows.ItemsReplaced -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced);
|
---|
| 58 | Content.Rows.CollectionReset -= new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset);
|
---|
| 59 | }
|
---|
[14519] | 60 | protected override void RegisterContentEvents() {
|
---|
[4870] | 61 | Content.VisualPropertiesChanged += new EventHandler(Content_VisualPropertiesChanged);
|
---|
[2908] | 62 | Content.Rows.ItemsAdded += new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded);
|
---|
| 63 | Content.Rows.ItemsRemoved += new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsRemoved);
|
---|
| 64 | Content.Rows.ItemsReplaced += new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced);
|
---|
| 65 | Content.Rows.CollectionReset += new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset);
|
---|
| 66 | }
|
---|
| 67 |
|
---|
[6342] | 68 | protected virtual void RegisterDataRowEvents(DataRow row) {
|
---|
| 69 | row.NameChanged += new EventHandler(Row_NameChanged);
|
---|
| 70 | row.VisualPropertiesChanged += new EventHandler(Row_VisualPropertiesChanged);
|
---|
| 71 | valuesRowsTable.Add(row.Values, row);
|
---|
| 72 | row.Values.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsAdded);
|
---|
| 73 | row.Values.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsRemoved);
|
---|
| 74 | row.Values.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsReplaced);
|
---|
| 75 | row.Values.ItemsMoved += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsMoved);
|
---|
| 76 | row.Values.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_CollectionReset);
|
---|
| 77 | }
|
---|
| 78 | protected virtual void DeregisterDataRowEvents(DataRow row) {
|
---|
| 79 | row.Values.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsAdded);
|
---|
| 80 | row.Values.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsRemoved);
|
---|
| 81 | row.Values.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsReplaced);
|
---|
| 82 | row.Values.ItemsMoved -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsMoved);
|
---|
| 83 | row.Values.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_CollectionReset);
|
---|
| 84 | valuesRowsTable.Remove(row.Values);
|
---|
| 85 | row.VisualPropertiesChanged -= new EventHandler(Row_VisualPropertiesChanged);
|
---|
| 86 | row.NameChanged -= new EventHandler(Row_NameChanged);
|
---|
| 87 | }
|
---|
| 88 | #endregion
|
---|
| 89 |
|
---|
[14519] | 90 | protected override void OnContentChanged() {
|
---|
[3703] | 91 | invisibleSeries.Clear();
|
---|
[4637] | 92 | chart.Titles[0].Text = string.Empty;
|
---|
[4870] | 93 | chart.ChartAreas[0].AxisX.Title = string.Empty;
|
---|
| 94 | chart.ChartAreas[0].AxisY.Title = string.Empty;
|
---|
| 95 | chart.ChartAreas[0].AxisY2.Title = string.Empty;
|
---|
[2908] | 96 | chart.Series.Clear();
|
---|
[3454] | 97 | if (Content != null) {
|
---|
[4637] | 98 | chart.Titles[0].Text = Content.Name;
|
---|
[14438] | 99 | chart.Titles[0].Visible = !string.IsNullOrEmpty(Content.Name);
|
---|
[7977] | 100 | AddDataRows(Content.Rows);
|
---|
[6342] | 101 | ConfigureChartArea(chart.ChartAreas[0]);
|
---|
| 102 | RecalculateAxesScale(chart.ChartAreas[0]);
|
---|
[2908] | 103 | }
|
---|
| 104 | }
|
---|
| 105 |
|
---|
[14519] | 106 | protected override void SetEnabledStateOfControls() {
|
---|
[3454] | 107 | chart.Enabled = Content != null;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
[6342] | 110 | public void ShowConfiguration() {
|
---|
| 111 | if (Content != null) {
|
---|
[9258] | 112 | using (var dialog = new DataTableVisualPropertiesDialog(Content)) {
|
---|
[7244] | 113 | dialog.ShowDialog(this);
|
---|
| 114 | }
|
---|
[6342] | 115 | } else MessageBox.Show("Nothing to configure.");
|
---|
| 116 | }
|
---|
[7977] | 117 | protected virtual void AddDataRows(IEnumerable<DataRow> rows) {
|
---|
| 118 | foreach (var row in rows) {
|
---|
| 119 | RegisterDataRowEvents(row);
|
---|
[14582] | 120 | var series = new Series(row.Name) {
|
---|
| 121 | Tag = row
|
---|
| 122 | };
|
---|
[7977] | 123 | if (row.VisualProperties.DisplayName.Trim() != String.Empty) series.LegendText = row.VisualProperties.DisplayName;
|
---|
| 124 | else series.LegendText = row.Name;
|
---|
| 125 | ConfigureSeries(series, row);
|
---|
| 126 | FillSeriesWithRowValues(series, row);
|
---|
| 127 | chart.Series.Add(series);
|
---|
| 128 | }
|
---|
[6342] | 129 | ConfigureChartArea(chart.ChartAreas[0]);
|
---|
| 130 | RecalculateAxesScale(chart.ChartAreas[0]);
|
---|
| 131 | UpdateYCursorInterval();
|
---|
[14582] | 132 | UpdateHistogramTransparency();
|
---|
[6342] | 133 | }
|
---|
| 134 |
|
---|
[7979] | 135 | protected virtual void RemoveDataRows(IEnumerable<DataRow> rows) {
|
---|
| 136 | foreach (var row in rows) {
|
---|
| 137 | DeregisterDataRowEvents(row);
|
---|
| 138 | Series series = chart.Series[row.Name];
|
---|
| 139 | chart.Series.Remove(series);
|
---|
| 140 | if (invisibleSeries.Contains(series))
|
---|
| 141 | invisibleSeries.Remove(series);
|
---|
| 142 | }
|
---|
| 143 | RecalculateAxesScale(chart.ChartAreas[0]);
|
---|
| 144 | }
|
---|
| 145 |
|
---|
[6342] | 146 | private void ConfigureSeries(Series series, DataRow row) {
|
---|
| 147 | RemoveCustomPropertyIfExists(series, "PointWidth");
|
---|
| 148 | series.BorderWidth = 1;
|
---|
| 149 | series.BorderDashStyle = ChartDashStyle.Solid;
|
---|
| 150 | series.BorderColor = Color.Empty;
|
---|
| 151 |
|
---|
| 152 | if (row.VisualProperties.Color != Color.Empty)
|
---|
| 153 | series.Color = row.VisualProperties.Color;
|
---|
| 154 | else series.Color = Color.Empty;
|
---|
[7126] | 155 | series.IsVisibleInLegend = row.VisualProperties.IsVisibleInLegend;
|
---|
[6342] | 156 |
|
---|
[4644] | 157 | switch (row.VisualProperties.ChartType) {
|
---|
| 158 | case DataRowVisualProperties.DataRowChartType.Line:
|
---|
| 159 | series.ChartType = SeriesChartType.FastLine;
|
---|
[6342] | 160 | series.BorderWidth = row.VisualProperties.LineWidth;
|
---|
| 161 | series.BorderDashStyle = ConvertLineStyle(row.VisualProperties.LineStyle);
|
---|
[4644] | 162 | break;
|
---|
| 163 | case DataRowVisualProperties.DataRowChartType.Bars:
|
---|
[6342] | 164 | // Bar is incompatible with anything but Bar and StackedBar*
|
---|
| 165 | if (!chart.Series.Any(x => x.ChartType != SeriesChartType.Bar && x.ChartType != SeriesChartType.StackedBar && x.ChartType != SeriesChartType.StackedBar100))
|
---|
| 166 | series.ChartType = SeriesChartType.Bar;
|
---|
| 167 | else {
|
---|
| 168 | series.ChartType = SeriesChartType.FastPoint; //default
|
---|
| 169 | row.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points;
|
---|
| 170 | }
|
---|
[4644] | 171 | break;
|
---|
| 172 | case DataRowVisualProperties.DataRowChartType.Columns:
|
---|
| 173 | series.ChartType = SeriesChartType.Column;
|
---|
| 174 | break;
|
---|
| 175 | case DataRowVisualProperties.DataRowChartType.Points:
|
---|
| 176 | series.ChartType = SeriesChartType.FastPoint;
|
---|
| 177 | break;
|
---|
[6342] | 178 | case DataRowVisualProperties.DataRowChartType.Histogram:
|
---|
[14582] | 179 | bool stacked = row.VisualProperties.Aggregation == DataRowVisualProperties.DataRowHistogramAggregation.Stacked;
|
---|
| 180 | series.ChartType = stacked ? SeriesChartType.StackedColumn : SeriesChartType.Column;
|
---|
| 181 | bool sideBySide = row.VisualProperties.Aggregation == DataRowVisualProperties.DataRowHistogramAggregation.SideBySide;
|
---|
| 182 | series.SetCustomProperty("DrawSideBySide", sideBySide ? "True" : "False");
|
---|
[6342] | 183 | series.SetCustomProperty("PointWidth", "1");
|
---|
| 184 | if (!series.Color.IsEmpty && series.Color.GetBrightness() < 0.25)
|
---|
| 185 | series.BorderColor = Color.White;
|
---|
| 186 | else series.BorderColor = Color.Black;
|
---|
| 187 | break;
|
---|
[7297] | 188 | case DataRowVisualProperties.DataRowChartType.StepLine:
|
---|
| 189 | series.ChartType = SeriesChartType.StepLine;
|
---|
| 190 | series.BorderWidth = row.VisualProperties.LineWidth;
|
---|
| 191 | series.BorderDashStyle = ConvertLineStyle(row.VisualProperties.LineStyle);
|
---|
| 192 | break;
|
---|
[4644] | 193 | default:
|
---|
| 194 | series.ChartType = SeriesChartType.FastPoint;
|
---|
| 195 | break;
|
---|
| 196 | }
|
---|
| 197 | series.YAxisType = row.VisualProperties.SecondYAxis ? AxisType.Secondary : AxisType.Primary;
|
---|
[6342] | 198 | series.XAxisType = row.VisualProperties.SecondXAxis ? AxisType.Secondary : AxisType.Primary;
|
---|
[6628] | 199 | if (row.VisualProperties.DisplayName.Trim() != String.Empty) series.LegendText = row.VisualProperties.DisplayName;
|
---|
| 200 | else series.LegendText = row.Name;
|
---|
[7304] | 201 |
|
---|
| 202 | string xAxisTitle = string.IsNullOrEmpty(Content.VisualProperties.XAxisTitle)
|
---|
| 203 | ? "X"
|
---|
| 204 | : Content.VisualProperties.XAxisTitle;
|
---|
| 205 | string yAxisTitle = string.IsNullOrEmpty(Content.VisualProperties.YAxisTitle)
|
---|
| 206 | ? "Y"
|
---|
| 207 | : Content.VisualProperties.YAxisTitle;
|
---|
| 208 | series.ToolTip =
|
---|
| 209 | series.LegendText + Environment.NewLine +
|
---|
| 210 | xAxisTitle + " = " + "#INDEX," + Environment.NewLine +
|
---|
| 211 | yAxisTitle + " = " + "#VAL";
|
---|
[2908] | 212 | }
|
---|
[3703] | 213 |
|
---|
[6342] | 214 | private void ConfigureChartArea(ChartArea area) {
|
---|
| 215 | if (Content.VisualProperties.TitleFont != null) chart.Titles[0].Font = Content.VisualProperties.TitleFont;
|
---|
| 216 | if (!Content.VisualProperties.TitleColor.IsEmpty) chart.Titles[0].ForeColor = Content.VisualProperties.TitleColor;
|
---|
[7224] | 217 | chart.Titles[0].Text = Content.VisualProperties.Title;
|
---|
[14438] | 218 | chart.Titles[0].Visible = !string.IsNullOrEmpty(Content.VisualProperties.Title);
|
---|
[5097] | 219 |
|
---|
[6342] | 220 | if (Content.VisualProperties.AxisTitleFont != null) area.AxisX.TitleFont = Content.VisualProperties.AxisTitleFont;
|
---|
| 221 | if (!Content.VisualProperties.AxisTitleColor.IsEmpty) area.AxisX.TitleForeColor = Content.VisualProperties.AxisTitleColor;
|
---|
| 222 | area.AxisX.Title = Content.VisualProperties.XAxisTitle;
|
---|
| 223 |
|
---|
| 224 | if (Content.VisualProperties.AxisTitleFont != null) area.AxisX2.TitleFont = Content.VisualProperties.AxisTitleFont;
|
---|
| 225 | if (!Content.VisualProperties.AxisTitleColor.IsEmpty) area.AxisX2.TitleForeColor = Content.VisualProperties.AxisTitleColor;
|
---|
| 226 | area.AxisX2.Title = Content.VisualProperties.SecondXAxisTitle;
|
---|
| 227 |
|
---|
| 228 | if (Content.VisualProperties.AxisTitleFont != null) area.AxisY.TitleFont = Content.VisualProperties.AxisTitleFont;
|
---|
| 229 | if (!Content.VisualProperties.AxisTitleColor.IsEmpty) area.AxisY.TitleForeColor = Content.VisualProperties.AxisTitleColor;
|
---|
| 230 | area.AxisY.Title = Content.VisualProperties.YAxisTitle;
|
---|
| 231 |
|
---|
| 232 | if (Content.VisualProperties.AxisTitleFont != null) area.AxisY2.TitleFont = Content.VisualProperties.AxisTitleFont;
|
---|
| 233 | if (!Content.VisualProperties.AxisTitleColor.IsEmpty) area.AxisY2.TitleForeColor = Content.VisualProperties.AxisTitleColor;
|
---|
| 234 | area.AxisY2.Title = Content.VisualProperties.SecondYAxisTitle;
|
---|
[9258] | 235 |
|
---|
| 236 | area.AxisX.IsLogarithmic = Content.VisualProperties.XAxisLogScale;
|
---|
| 237 | area.AxisX2.IsLogarithmic = Content.VisualProperties.SecondXAxisLogScale;
|
---|
| 238 | area.AxisY.IsLogarithmic = Content.VisualProperties.YAxisLogScale;
|
---|
| 239 | area.AxisY2.IsLogarithmic = Content.VisualProperties.SecondYAxisLogScale;
|
---|
[6342] | 240 | }
|
---|
| 241 |
|
---|
| 242 | private void RecalculateAxesScale(ChartArea area) {
|
---|
| 243 | // Reset the axes bounds so that RecalculateAxesScale() will assign new bounds
|
---|
| 244 | foreach (Axis a in area.Axes) {
|
---|
| 245 | a.Minimum = double.NaN;
|
---|
| 246 | a.Maximum = double.NaN;
|
---|
| 247 | }
|
---|
| 248 | area.RecalculateAxesScale();
|
---|
| 249 | area.AxisX.IsMarginVisible = false;
|
---|
| 250 | area.AxisX2.IsMarginVisible = false;
|
---|
| 251 |
|
---|
| 252 | if (!Content.VisualProperties.XAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.XAxisMinimumFixedValue)) area.AxisX.Minimum = Content.VisualProperties.XAxisMinimumFixedValue;
|
---|
| 253 | if (!Content.VisualProperties.XAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.XAxisMaximumFixedValue)) area.AxisX.Maximum = Content.VisualProperties.XAxisMaximumFixedValue;
|
---|
| 254 | if (!Content.VisualProperties.SecondXAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.SecondXAxisMinimumFixedValue)) area.AxisX2.Minimum = Content.VisualProperties.SecondXAxisMinimumFixedValue;
|
---|
| 255 | if (!Content.VisualProperties.SecondXAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.SecondXAxisMaximumFixedValue)) area.AxisX2.Maximum = Content.VisualProperties.SecondXAxisMaximumFixedValue;
|
---|
| 256 | if (!Content.VisualProperties.YAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.YAxisMinimumFixedValue)) area.AxisY.Minimum = Content.VisualProperties.YAxisMinimumFixedValue;
|
---|
| 257 | if (!Content.VisualProperties.YAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.YAxisMaximumFixedValue)) area.AxisY.Maximum = Content.VisualProperties.YAxisMaximumFixedValue;
|
---|
| 258 | if (!Content.VisualProperties.SecondYAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.SecondYAxisMinimumFixedValue)) area.AxisY2.Minimum = Content.VisualProperties.SecondYAxisMinimumFixedValue;
|
---|
| 259 | if (!Content.VisualProperties.SecondYAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.SecondYAxisMaximumFixedValue)) area.AxisY2.Maximum = Content.VisualProperties.SecondYAxisMaximumFixedValue;
|
---|
[6676] | 260 | if (area.AxisX.Minimum >= area.AxisX.Maximum) area.AxisX.Maximum = area.AxisX.Minimum + 1;
|
---|
| 261 | if (area.AxisX2.Minimum >= area.AxisX2.Maximum) area.AxisX2.Maximum = area.AxisX2.Minimum + 1;
|
---|
| 262 | if (area.AxisY.Minimum >= area.AxisY.Maximum) area.AxisY.Maximum = area.AxisY.Minimum + 1;
|
---|
| 263 | if (area.AxisY2.Minimum >= area.AxisY2.Maximum) area.AxisY2.Maximum = area.AxisY2.Minimum + 1;
|
---|
[6342] | 264 | }
|
---|
| 265 |
|
---|
[5097] | 266 | protected virtual void UpdateYCursorInterval() {
|
---|
[6342] | 267 | double interestingValuesRange = (
|
---|
| 268 | from series in chart.Series
|
---|
| 269 | where series.Enabled
|
---|
| 270 | let values = (from point in series.Points
|
---|
| 271 | where !point.IsEmpty
|
---|
| 272 | select point.YValues[0]).DefaultIfEmpty(1.0)
|
---|
| 273 | let range = values.Max() - values.Min()
|
---|
| 274 | where range > 0.0
|
---|
| 275 | select range
|
---|
| 276 | ).DefaultIfEmpty(1.0).Min();
|
---|
[3703] | 277 |
|
---|
| 278 | double digits = (int)Math.Log10(interestingValuesRange) - 3;
|
---|
| 279 | double yZoomInterval = Math.Pow(10, digits);
|
---|
| 280 | this.chart.ChartAreas[0].CursorY.Interval = yZoomInterval;
|
---|
| 281 | }
|
---|
| 282 |
|
---|
[14582] | 283 | protected void UpdateHistogramTransparency() {
|
---|
| 284 | if (Content.Rows.Any(r => RequiresTransparency(r) && r.VisualProperties.Color.IsEmpty)) {
|
---|
| 285 | foreach (var series in chart.Series) // sync colors before applying palette colors
|
---|
| 286 | series.Color = ((DataRow)series.Tag).VisualProperties.Color;
|
---|
| 287 | chart.ApplyPaletteColors();
|
---|
| 288 | }
|
---|
| 289 |
|
---|
| 290 | var numTransparent = Content.Rows.Count(RequiresTransparency);
|
---|
| 291 | if (numTransparent <= 1) return;
|
---|
| 292 | foreach (var series in chart.Series) {
|
---|
| 293 | var row = (DataRow)series.Tag;
|
---|
| 294 | if (!RequiresTransparency(row))
|
---|
| 295 | continue;
|
---|
| 296 | var baseColor = row.VisualProperties.Color;
|
---|
| 297 | if (baseColor.IsEmpty) baseColor = series.Color;
|
---|
| 298 | series.Color = Color.FromArgb(180, baseColor);
|
---|
| 299 | }
|
---|
| 300 | }
|
---|
| 301 | private bool RequiresTransparency(DataRow row) {
|
---|
| 302 | return row.VisualProperties.ChartType == DataRowVisualProperties.DataRowChartType.Histogram
|
---|
| 303 | && row.VisualProperties.Aggregation == DataRowVisualProperties.DataRowHistogramAggregation.Overlapping;
|
---|
| 304 | }
|
---|
| 305 |
|
---|
[6342] | 306 | #region Event Handlers
|
---|
| 307 | #region Content Event Handlers
|
---|
[4870] | 308 | private void Content_VisualPropertiesChanged(object sender, EventArgs e) {
|
---|
| 309 | if (InvokeRequired)
|
---|
| 310 | Invoke(new EventHandler(Content_VisualPropertiesChanged), sender, e);
|
---|
| 311 | else {
|
---|
[6342] | 312 | ConfigureChartArea(chart.ChartAreas[0]);
|
---|
| 313 | RecalculateAxesScale(chart.ChartAreas[0]); // axes min/max could have changed
|
---|
[4870] | 314 | }
|
---|
| 315 | }
|
---|
[6342] | 316 | #endregion
|
---|
| 317 | #region Rows Event Handlers
|
---|
[2908] | 318 | private void Rows_ItemsAdded(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
|
---|
| 319 | if (InvokeRequired)
|
---|
| 320 | Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded), sender, e);
|
---|
| 321 | else {
|
---|
[7977] | 322 | AddDataRows(e.Items);
|
---|
[2908] | 323 | }
|
---|
| 324 | }
|
---|
| 325 | private void Rows_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
|
---|
| 326 | if (InvokeRequired)
|
---|
| 327 | Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsRemoved), sender, e);
|
---|
| 328 | else {
|
---|
[7977] | 329 | RemoveDataRows(e.Items);
|
---|
[2908] | 330 | }
|
---|
| 331 | }
|
---|
| 332 | private void Rows_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
|
---|
| 333 | if (InvokeRequired)
|
---|
| 334 | Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced), sender, e);
|
---|
| 335 | else {
|
---|
[7977] | 336 | RemoveDataRows(e.OldItems);
|
---|
| 337 | AddDataRows(e.Items);
|
---|
[2908] | 338 | }
|
---|
| 339 | }
|
---|
| 340 | private void Rows_CollectionReset(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
|
---|
| 341 | if (InvokeRequired)
|
---|
| 342 | Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset), sender, e);
|
---|
| 343 | else {
|
---|
[7977] | 344 | RemoveDataRows(e.OldItems);
|
---|
| 345 | AddDataRows(e.Items);
|
---|
[2908] | 346 | }
|
---|
| 347 | }
|
---|
[6342] | 348 | #endregion
|
---|
| 349 | #region Row Event Handlers
|
---|
[4644] | 350 | private void Row_VisualPropertiesChanged(object sender, EventArgs e) {
|
---|
| 351 | if (InvokeRequired)
|
---|
| 352 | Invoke(new EventHandler(Row_VisualPropertiesChanged), sender, e);
|
---|
| 353 | else {
|
---|
| 354 | DataRow row = (DataRow)sender;
|
---|
[6342] | 355 | Series series = chart.Series[row.Name];
|
---|
| 356 | series.Points.Clear();
|
---|
| 357 | ConfigureSeries(series, row);
|
---|
[14582] | 358 | if (!invisibleSeries.Contains(series)) {
|
---|
| 359 | FillSeriesWithRowValues(series, row);
|
---|
| 360 | RecalculateAxesScale(chart.ChartAreas[0]);
|
---|
| 361 | UpdateHistogramTransparency();
|
---|
| 362 | }
|
---|
[4644] | 363 | }
|
---|
| 364 | }
|
---|
[2908] | 365 | private void Row_NameChanged(object sender, EventArgs e) {
|
---|
| 366 | if (InvokeRequired)
|
---|
| 367 | Invoke(new EventHandler(Row_NameChanged), sender, e);
|
---|
| 368 | else {
|
---|
| 369 | DataRow row = (DataRow)sender;
|
---|
| 370 | chart.Series[row.Name].Name = row.Name;
|
---|
| 371 | }
|
---|
| 372 | }
|
---|
[6342] | 373 | #endregion
|
---|
| 374 | #region Values Event Handlers
|
---|
[2908] | 375 | private void Values_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) {
|
---|
| 376 | if (InvokeRequired)
|
---|
| 377 | Invoke(new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsAdded), sender, e);
|
---|
| 378 | else {
|
---|
[3561] | 379 | DataRow row = null;
|
---|
| 380 | valuesRowsTable.TryGetValue((IObservableList<double>)sender, out row);
|
---|
| 381 | if (row != null) {
|
---|
[3703] | 382 | Series rowSeries = chart.Series[row.Name];
|
---|
| 383 | if (!invisibleSeries.Contains(rowSeries)) {
|
---|
[4778] | 384 | rowSeries.Points.Clear();
|
---|
| 385 | FillSeriesWithRowValues(rowSeries, row);
|
---|
[6342] | 386 | RecalculateAxesScale(chart.ChartAreas[0]);
|
---|
[3703] | 387 | UpdateYCursorInterval();
|
---|
[3080] | 388 | }
|
---|
| 389 | }
|
---|
[2908] | 390 | }
|
---|
| 391 | }
|
---|
| 392 | private void Values_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) {
|
---|
| 393 | if (InvokeRequired)
|
---|
| 394 | Invoke(new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsRemoved), sender, e);
|
---|
| 395 | else {
|
---|
[3561] | 396 | DataRow row = null;
|
---|
| 397 | valuesRowsTable.TryGetValue((IObservableList<double>)sender, out row);
|
---|
| 398 | if (row != null) {
|
---|
[3703] | 399 | Series rowSeries = chart.Series[row.Name];
|
---|
| 400 | if (!invisibleSeries.Contains(rowSeries)) {
|
---|
[4778] | 401 | rowSeries.Points.Clear();
|
---|
| 402 | FillSeriesWithRowValues(rowSeries, row);
|
---|
[6342] | 403 | RecalculateAxesScale(chart.ChartAreas[0]);
|
---|
[3703] | 404 | UpdateYCursorInterval();
|
---|
| 405 | }
|
---|
[3561] | 406 | }
|
---|
[2908] | 407 | }
|
---|
| 408 | }
|
---|
| 409 | private void Values_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) {
|
---|
| 410 | if (InvokeRequired)
|
---|
| 411 | Invoke(new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsReplaced), sender, e);
|
---|
| 412 | else {
|
---|
[3561] | 413 | DataRow row = null;
|
---|
| 414 | valuesRowsTable.TryGetValue((IObservableList<double>)sender, out row);
|
---|
| 415 | if (row != null) {
|
---|
[3703] | 416 | Series rowSeries = chart.Series[row.Name];
|
---|
| 417 | if (!invisibleSeries.Contains(rowSeries)) {
|
---|
[6342] | 418 | if (row.VisualProperties.ChartType == DataRowVisualProperties.DataRowChartType.Histogram) {
|
---|
| 419 | rowSeries.Points.Clear();
|
---|
| 420 | FillSeriesWithRowValues(rowSeries, row);
|
---|
| 421 | } else {
|
---|
| 422 | foreach (IndexedItem<double> item in e.Items) {
|
---|
| 423 | if (IsInvalidValue(item.Value))
|
---|
| 424 | rowSeries.Points[item.Index].IsEmpty = true;
|
---|
| 425 | else {
|
---|
| 426 | rowSeries.Points[item.Index].YValues = new double[] { item.Value };
|
---|
| 427 | rowSeries.Points[item.Index].IsEmpty = false;
|
---|
| 428 | }
|
---|
[3703] | 429 | }
|
---|
[3561] | 430 | }
|
---|
[6342] | 431 | RecalculateAxesScale(chart.ChartAreas[0]);
|
---|
[3703] | 432 | UpdateYCursorInterval();
|
---|
[3530] | 433 | }
|
---|
[3080] | 434 | }
|
---|
[2908] | 435 | }
|
---|
| 436 | }
|
---|
| 437 | private void Values_ItemsMoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) {
|
---|
| 438 | if (InvokeRequired)
|
---|
| 439 | Invoke(new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_ItemsMoved), sender, e);
|
---|
| 440 | else {
|
---|
[3561] | 441 | DataRow row = null;
|
---|
| 442 | valuesRowsTable.TryGetValue((IObservableList<double>)sender, out row);
|
---|
| 443 | if (row != null) {
|
---|
[3703] | 444 | Series rowSeries = chart.Series[row.Name];
|
---|
| 445 | if (!invisibleSeries.Contains(rowSeries)) {
|
---|
[4778] | 446 | rowSeries.Points.Clear();
|
---|
| 447 | FillSeriesWithRowValues(rowSeries, row);
|
---|
[6342] | 448 | RecalculateAxesScale(chart.ChartAreas[0]);
|
---|
[3703] | 449 | UpdateYCursorInterval();
|
---|
[3530] | 450 | }
|
---|
[3080] | 451 | }
|
---|
[2908] | 452 | }
|
---|
| 453 | }
|
---|
[3530] | 454 |
|
---|
[2908] | 455 | private void Values_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<double>> e) {
|
---|
| 456 | if (InvokeRequired)
|
---|
| 457 | Invoke(new CollectionItemsChangedEventHandler<IndexedItem<double>>(Values_CollectionReset), sender, e);
|
---|
| 458 | else {
|
---|
[3561] | 459 | DataRow row = null;
|
---|
| 460 | valuesRowsTable.TryGetValue((IObservableList<double>)sender, out row);
|
---|
| 461 | if (row != null) {
|
---|
[3703] | 462 | Series rowSeries = chart.Series[row.Name];
|
---|
| 463 | if (!invisibleSeries.Contains(rowSeries)) {
|
---|
| 464 | rowSeries.Points.Clear();
|
---|
[4778] | 465 | FillSeriesWithRowValues(rowSeries, row);
|
---|
[6342] | 466 | RecalculateAxesScale(chart.ChartAreas[0]);
|
---|
[4778] | 467 | UpdateYCursorInterval();
|
---|
[3530] | 468 | }
|
---|
[3080] | 469 | }
|
---|
[2908] | 470 | }
|
---|
| 471 | }
|
---|
| 472 | #endregion
|
---|
[14435] | 473 | private void configureToolStripMenuItem_Click(object sender, EventArgs e) {
|
---|
| 474 | ShowConfiguration();
|
---|
| 475 | }
|
---|
[6342] | 476 | #endregion
|
---|
[4623] | 477 |
|
---|
[6342] | 478 | #region Chart Event Handlers
|
---|
[3703] | 479 | private void chart_MouseDown(object sender, MouseEventArgs e) {
|
---|
| 480 | HitTestResult result = chart.HitTest(e.X, e.Y);
|
---|
| 481 | if (result.ChartElementType == ChartElementType.LegendItem) {
|
---|
| 482 | ToggleSeriesVisible(result.Series);
|
---|
| 483 | }
|
---|
| 484 | }
|
---|
[6342] | 485 | private void chart_MouseMove(object sender, MouseEventArgs e) {
|
---|
| 486 | HitTestResult result = chart.HitTest(e.X, e.Y);
|
---|
| 487 | if (result.ChartElementType == ChartElementType.LegendItem)
|
---|
| 488 | this.Cursor = Cursors.Hand;
|
---|
| 489 | else
|
---|
| 490 | this.Cursor = Cursors.Default;
|
---|
| 491 | }
|
---|
| 492 | private void chart_CustomizeLegend(object sender, CustomizeLegendEventArgs e) {
|
---|
| 493 | foreach (LegendItem legendItem in e.LegendItems) {
|
---|
| 494 | var series = chart.Series[legendItem.SeriesName];
|
---|
| 495 | if (series != null) {
|
---|
| 496 | bool seriesIsInvisible = invisibleSeries.Contains(series);
|
---|
| 497 | foreach (LegendCell cell in legendItem.Cells) {
|
---|
| 498 | cell.ForeColor = seriesIsInvisible ? Color.Gray : Color.Black;
|
---|
| 499 | }
|
---|
| 500 | }
|
---|
| 501 | }
|
---|
| 502 | }
|
---|
| 503 | #endregion
|
---|
[3530] | 504 |
|
---|
[3703] | 505 | private void ToggleSeriesVisible(Series series) {
|
---|
| 506 | if (!invisibleSeries.Contains(series)) {
|
---|
| 507 | series.Points.Clear();
|
---|
| 508 | invisibleSeries.Add(series);
|
---|
| 509 | } else {
|
---|
| 510 | invisibleSeries.Remove(series);
|
---|
| 511 | if (Content != null) {
|
---|
| 512 |
|
---|
| 513 | var row = (from r in Content.Rows
|
---|
| 514 | where r.Name == series.Name
|
---|
| 515 | select r).Single();
|
---|
| 516 | FillSeriesWithRowValues(series, row);
|
---|
| 517 | this.chart.Legends[series.Legend].ForeColor = Color.Black;
|
---|
[6342] | 518 | RecalculateAxesScale(chart.ChartAreas[0]);
|
---|
[3703] | 519 | UpdateYCursorInterval();
|
---|
| 520 | }
|
---|
| 521 | }
|
---|
| 522 | }
|
---|
| 523 |
|
---|
| 524 | private void FillSeriesWithRowValues(Series series, DataRow row) {
|
---|
[6342] | 525 | switch (row.VisualProperties.ChartType) {
|
---|
| 526 | case DataRowVisualProperties.DataRowChartType.Histogram:
|
---|
[14457] | 527 | // when a single histogram is updated, all histograms must be updated. otherwise the value ranges and bin sizes may not be equal.
|
---|
| 528 | var histograms = Content.Rows
|
---|
| 529 | .Where(r => r.VisualProperties.ChartType == DataRowVisualProperties.DataRowChartType.Histogram)
|
---|
| 530 | .ToList();
|
---|
| 531 | CalculateHistogram(series, row, histograms);
|
---|
| 532 | foreach (var h in from r in histograms
|
---|
| 533 | where r != row
|
---|
| 534 | let s = chart.Series.FindByName(r.Name)
|
---|
| 535 | where s != null
|
---|
| 536 | where !invisibleSeries.Contains(s)
|
---|
| 537 | select new { row = r, series = s }) {
|
---|
| 538 | h.series.Points.Clear();
|
---|
| 539 | CalculateHistogram(h.series, h.row, histograms);
|
---|
| 540 | }
|
---|
[6342] | 541 | break;
|
---|
| 542 | default: {
|
---|
[9258] | 543 | bool yLogarithmic = series.YAxisType == AxisType.Primary
|
---|
| 544 | ? Content.VisualProperties.YAxisLogScale
|
---|
| 545 | : Content.VisualProperties.SecondYAxisLogScale;
|
---|
| 546 | bool xLogarithmic = series.XAxisType == AxisType.Primary
|
---|
| 547 | ? Content.VisualProperties.XAxisLogScale
|
---|
| 548 | : Content.VisualProperties.SecondXAxisLogScale;
|
---|
[6342] | 549 | for (int i = 0; i < row.Values.Count; i++) {
|
---|
| 550 | var value = row.Values[i];
|
---|
[9258] | 551 | var point = new DataPoint();
|
---|
| 552 | point.XValue = row.VisualProperties.StartIndexZero && !xLogarithmic ? i : i + 1;
|
---|
| 553 | if (IsInvalidValue(value) || (yLogarithmic && value <= 0))
|
---|
[6342] | 554 | point.IsEmpty = true;
|
---|
| 555 | else
|
---|
| 556 | point.YValues = new double[] { value };
|
---|
| 557 | series.Points.Add(point);
|
---|
| 558 | }
|
---|
| 559 | }
|
---|
| 560 | break;
|
---|
[3703] | 561 | }
|
---|
| 562 | }
|
---|
| 563 |
|
---|
[14457] | 564 | protected virtual void CalculateHistogram(Series series, DataRow row, IEnumerable<DataRow> histogramRows) {
|
---|
[6342] | 565 | series.Points.Clear();
|
---|
| 566 | if (!row.Values.Any()) return;
|
---|
| 567 |
|
---|
[14508] | 568 | var validValues = histogramRows.SelectMany(r => r.Values).Where(x => !IsInvalidValue(x)).ToList();
|
---|
| 569 | if (!validValues.Any()) return;
|
---|
| 570 |
|
---|
[14457] | 571 | int bins = histogramRows.Max(r => r.VisualProperties.Bins);
|
---|
[14508] | 572 | decimal minValue = (decimal)validValues.Min();
|
---|
| 573 | decimal maxValue = (decimal)validValues.Max();
|
---|
[14458] | 574 | decimal intervalWidth = (maxValue - minValue) / bins;
|
---|
[6342] | 575 | if (intervalWidth < 0) return;
|
---|
| 576 | if (intervalWidth == 0) {
|
---|
| 577 | series.Points.AddXY(minValue, row.Values.Count);
|
---|
| 578 | return;
|
---|
| 579 | }
|
---|
| 580 |
|
---|
[14457] | 581 | if (!histogramRows.Any(r => r.VisualProperties.ExactBins)) {
|
---|
[14458] | 582 | intervalWidth = (decimal)HumanRoundRange((double)intervalWidth);
|
---|
[6342] | 583 | minValue = Math.Floor(minValue / intervalWidth) * intervalWidth;
|
---|
| 584 | maxValue = Math.Ceiling(maxValue / intervalWidth) * intervalWidth;
|
---|
| 585 | }
|
---|
| 586 |
|
---|
[14458] | 587 | decimal intervalCenter = intervalWidth / 2;
|
---|
[7223] | 588 |
|
---|
[14458] | 589 | decimal min = 0.0m, max = 0.0m;
|
---|
[6978] | 590 | if (!Double.IsNaN(Content.VisualProperties.XAxisMinimumFixedValue) && !Content.VisualProperties.XAxisMinimumAuto)
|
---|
[14458] | 591 | min = (decimal)Content.VisualProperties.XAxisMinimumFixedValue;
|
---|
[7223] | 592 | else min = minValue;
|
---|
[8339] | 593 | if (!Double.IsNaN(Content.VisualProperties.XAxisMaximumFixedValue) && !Content.VisualProperties.XAxisMaximumAuto)
|
---|
[14458] | 594 | max = (decimal)Content.VisualProperties.XAxisMaximumFixedValue;
|
---|
[8339] | 595 | else max = maxValue + intervalWidth;
|
---|
[6978] | 596 |
|
---|
[14458] | 597 | double axisInterval = (double)intervalWidth / row.VisualProperties.ScaleFactor;
|
---|
[6978] | 598 |
|
---|
[7223] | 599 | var area = chart.ChartAreas[0];
|
---|
| 600 | area.AxisX.Interval = axisInterval;
|
---|
[6978] | 601 |
|
---|
[7223] | 602 | series.SetCustomProperty("PointWidth", "1"); // 0.8 is the default value
|
---|
| 603 |
|
---|
| 604 | // get the range or intervals which define the grouping of the frequency values
|
---|
[14458] | 605 | var range = Range(min, max, intervalWidth).Skip(1).ToList();
|
---|
[7223] | 606 |
|
---|
| 607 | // aggregate the row values by unique key and frequency value
|
---|
| 608 | var valueFrequencies = (from v in row.Values
|
---|
| 609 | where !IsInvalidValue(v)
|
---|
| 610 | orderby v
|
---|
| 611 | group v by v into g
|
---|
| 612 | select new Tuple<double, double>(g.First(), g.Count())).ToList();
|
---|
| 613 |
|
---|
[14457] | 614 | // ensure that each column is displayed completely on the chart by adding two dummy datapoints on the upper and lower range
|
---|
[14458] | 615 | series.Points.Add(new DataPoint((double)(min - intervalWidth), 0));
|
---|
| 616 | series.Points.Add(new DataPoint((double)(max + intervalWidth), 0));
|
---|
[7223] | 617 |
|
---|
| 618 | // add data points
|
---|
| 619 | int j = 0;
|
---|
[14458] | 620 | foreach (var d in range) {
|
---|
[7223] | 621 | double sum = 0.0;
|
---|
| 622 | // sum the frequency values that fall within the same interval
|
---|
[14458] | 623 | while (j < valueFrequencies.Count && (decimal)valueFrequencies[j].Item1 < d) {
|
---|
[7223] | 624 | sum += valueFrequencies[j].Item2;
|
---|
| 625 | ++j;
|
---|
[3703] | 626 | }
|
---|
[7304] | 627 | string xAxisTitle = string.IsNullOrEmpty(Content.VisualProperties.XAxisTitle)
|
---|
| 628 | ? "X"
|
---|
| 629 | : Content.VisualProperties.XAxisTitle;
|
---|
| 630 | string yAxisTitle = string.IsNullOrEmpty(Content.VisualProperties.YAxisTitle)
|
---|
| 631 | ? "Y"
|
---|
| 632 | : Content.VisualProperties.YAxisTitle;
|
---|
[14458] | 633 | series.Points.Add(new DataPoint((double)(d - intervalCenter), sum) {
|
---|
[7304] | 634 | ToolTip =
|
---|
| 635 | xAxisTitle + ": [" + (d - intervalWidth) + "-" + d + ")" + Environment.NewLine +
|
---|
| 636 | yAxisTitle + ": " + sum
|
---|
| 637 | });
|
---|
[3703] | 638 | }
|
---|
| 639 | }
|
---|
| 640 |
|
---|
[6342] | 641 | #region Helpers
|
---|
[14458] | 642 | public static IEnumerable<decimal> Range(decimal min, decimal max, decimal step) {
|
---|
| 643 | decimal i;
|
---|
[7223] | 644 | for (i = min; i <= max; i += step)
|
---|
| 645 | yield return i;
|
---|
| 646 |
|
---|
| 647 | if (i != max + step)
|
---|
| 648 | yield return i;
|
---|
| 649 | }
|
---|
| 650 |
|
---|
[6342] | 651 | protected void RemoveCustomPropertyIfExists(Series series, string property) {
|
---|
| 652 | if (series.IsCustomPropertySet(property)) series.DeleteCustomProperty(property);
|
---|
| 653 | }
|
---|
[5097] | 654 |
|
---|
[6342] | 655 | private double HumanRoundRange(double range) {
|
---|
| 656 | double base10 = Math.Pow(10.0, Math.Floor(Math.Log10(range)));
|
---|
| 657 | double rounding = range / base10;
|
---|
| 658 | if (rounding <= 1.5) rounding = 1;
|
---|
| 659 | else if (rounding <= 2.25) rounding = 2;
|
---|
| 660 | else if (rounding <= 3.75) rounding = 2.5;
|
---|
| 661 | else if (rounding <= 7.5) rounding = 5;
|
---|
| 662 | else rounding = 10;
|
---|
| 663 | return rounding * base10;
|
---|
| 664 | }
|
---|
| 665 |
|
---|
| 666 | private double HumanRoundMax(double max) {
|
---|
| 667 | double base10;
|
---|
| 668 | if (max > 0) base10 = Math.Pow(10.0, Math.Floor(Math.Log10(max)));
|
---|
| 669 | else base10 = Math.Pow(10.0, Math.Ceiling(Math.Log10(-max)));
|
---|
| 670 | double rounding = (max > 0) ? base10 : -base10;
|
---|
| 671 | while (rounding < max) rounding += base10;
|
---|
| 672 | return rounding;
|
---|
| 673 | }
|
---|
| 674 |
|
---|
| 675 | private ChartDashStyle ConvertLineStyle(DataRowVisualProperties.DataRowLineStyle dataRowLineStyle) {
|
---|
| 676 | switch (dataRowLineStyle) {
|
---|
| 677 | case DataRowVisualProperties.DataRowLineStyle.Dash:
|
---|
| 678 | return ChartDashStyle.Dash;
|
---|
| 679 | case DataRowVisualProperties.DataRowLineStyle.DashDot:
|
---|
| 680 | return ChartDashStyle.DashDot;
|
---|
| 681 | case DataRowVisualProperties.DataRowLineStyle.DashDotDot:
|
---|
| 682 | return ChartDashStyle.DashDotDot;
|
---|
| 683 | case DataRowVisualProperties.DataRowLineStyle.Dot:
|
---|
| 684 | return ChartDashStyle.Dot;
|
---|
| 685 | case DataRowVisualProperties.DataRowLineStyle.NotSet:
|
---|
| 686 | return ChartDashStyle.NotSet;
|
---|
| 687 | case DataRowVisualProperties.DataRowLineStyle.Solid:
|
---|
| 688 | return ChartDashStyle.Solid;
|
---|
| 689 | default:
|
---|
| 690 | return ChartDashStyle.NotSet;
|
---|
| 691 | }
|
---|
| 692 | }
|
---|
| 693 |
|
---|
[5097] | 694 | protected static bool IsInvalidValue(double x) {
|
---|
[3530] | 695 | return double.IsNaN(x) || x < (double)decimal.MinValue || x > (double)decimal.MaxValue;
|
---|
| 696 | }
|
---|
[6342] | 697 | #endregion
|
---|
[2908] | 698 | }
|
---|
| 699 | }
|
---|