Exemplo n.º 1
0
        private static MCharting.Series GetOrCreateSeriesForValue(MCharting.Plot plot, Column column, Visualisable vis, ref bool isGroup)
        {
            object value = column.GetRow(vis);

            MCharting.Series series = plot.Series.FirstOrDefault(z => (z.Tag == null && value == null) || (z.Tag != null && z.Tag.Equals(value)));

            if (series == null)
            {
                series      = new MCharting.Series();
                series.Name = Column.AsString(value, column.DisplayMode);
                series.Tag  = value;

                if (value is GroupInfoBase)
                {
                    GroupInfoBase group = (GroupInfoBase)value;
                    UiControls.CreateIcon(series, group);
                    isGroup = true;
                }
                else
                {
                    series.Style.DrawPoints = new SolidBrush(column.GetColour(vis));
                }

                plot.Series.Add(series);
            }

            return(series);
        }
Exemplo n.º 2
0
        protected void DrawLabels(MCharting.Plot plot, bool bConditionsSideBySide, IEnumerable <GroupInfoBase> orderOfGroups, bool includeText)
        {
            if (bConditionsSideBySide)
            {
                foreach (GroupInfoBase ti in orderOfGroups)
                {
                    int x;

                    if (ti is GroupInfo)
                    {
                        x = this.GetTypeOffset((IEnumerable <GroupInfo>)orderOfGroups, (GroupInfo)ti);
                    }
                    else // if (ti is BatchInfo)
                    {
                        x = this.GetBatchOffset((IEnumerable <BatchInfo>)orderOfGroups, (BatchInfo)ti);
                    }

                    int    minX = ti.Range.Min;
                    int    maxX = ti.Range.Max;
                    string text = includeText ? ti.DisplayName : string.Empty;

                    this.DrawAxisBar(plot, x, minX, maxX, text);
                }
            }
            else
            {
                int    minX = this._core.TimeRange.Min;
                int    maxX = this._core.TimeRange.Max;
                int    x    = 0;
                string text = includeText ? StringHelper.ArrayToString(orderOfGroups, z => z.DisplayName, ", ") : string.Empty;

                this.DrawAxisBar(plot, x, minX, maxX, text);
            }
        }
Exemplo n.º 3
0
        protected Dictionary <GroupInfoBase, MCharting.Series> DrawLegend(MCharting.Plot plot, IEnumerable <GroupInfoBase> viewTypes)
        {
            Dictionary <GroupInfoBase, MCharting.Series> result = new Dictionary <GroupInfoBase, MCharting.Series>();

            foreach (GroupInfoBase group in viewTypes)
            {
                MCharting.Series legendEntry = new MCharting.Series();
                legendEntry.Name             = group.DisplayName;
                legendEntry.Style.DrawVBands = new SolidBrush(group.Colour);
                plot.LegendEntries.Add(legendEntry);
                result.Add(group, legendEntry);
            }

            return(result);
        }
Exemplo n.º 4
0
        private void DrawAxisBar(MCharting.Plot plot, int x, int min, int max, string text)
        {
            if (min == max)
            {
                plot.XTicks.Add(new MCharting.Tick(text, x + min, -3, 1));
                plot.XTicks.Add(new MCharting.Tick(null, x + min, 2, 0));
                return;
            }

            plot.XTicks.Add(new MCharting.Tick(text, x + (min + max) / 2, -3, 0));

            plot.XTicks.Add(new MCharting.Tick(min.ToString(), x + min, 2, 1));

            plot.XTicks.Add(new MCharting.Tick(max.ToString(), x + max, 2, 1));

            for (int n = min + 1; n < max; n++)
            {
                plot.XTicks.Add(new MCharting.Tick(null, x + n, 1, 0));
            }
        }
Exemplo n.º 5
0
        public void Plot(StylisedPeak stylisedPeak)
        {
            // Get observations
            Vector vector;

            if (stylisedPeak.ForceObservations != null)
            {
                vector = stylisedPeak.ForceObservations;
            }
            else
            {
                IntensityMatrix matrix = this._core.Options.SelectedMatrix;

                if (matrix == null)
                {
                    vector = null;
                }
                else
                {
                    vector = matrix.Find(stylisedPeak.Peak);
                }
            }

            Debug.WriteLine("PeakPlot: " + stylisedPeak);
            Dictionary <string, MCharting.Series> seriesNames = new Dictionary <string, MCharting.Series>();
            Peak peak = stylisedPeak?.Peak;

            // Clear plot
            MCharting.Plot plot = this.PrepareNewPlot(stylisedPeak != null && !stylisedPeak.IsPreview, peak, vector?.Source);

            try // <- CompletNewPlot
            {
                // Get selection
                this.SelectedPeak = peak;
                this.SetCaption("Plot of {0}.", peak);

                if (peak == null)
                {
                    return;
                }

                // Get options
                StylisedPeakOptions opts = stylisedPeak.OverrideDefaultOptions ?? new StylisedPeakOptions(this._core);

                // Get order data
                ObservationInfo[] obsOrder = this._core.Observations.ToArray();

                // Group legends
                IEnumerable <GroupInfoBase> order = opts.ShowAcqisition ? (IEnumerable <GroupInfoBase>)opts.ViewBatches : (IEnumerable <GroupInfoBase>)opts.ViewGroups;
                Dictionary <GroupInfoBase, MCharting.Series> groupLegends = this.DrawLegend(plot, order);

                if (vector == null)
                {
                    return;
                }

                // Show acquisition and batches?
                if (opts.ShowAcqisition)
                {
                    // --- RAW DATA (points) ---
                    MCharting.Series legendEntry = new MCharting.Series();
                    legendEntry.Name             = "Observations";
                    legendEntry.Style.DrawPoints = new SolidBrush(Color.Black);
                    plot.LegendEntries.Add(legendEntry);

                    this.AddToPlot(plot, peak, seriesNames, vector, "Raw data", opts, EPlot.ByBatch, groupLegends, legendEntry);

                    // --- TREND (thick line) ---
                    if (stylisedPeak.ForceTrend != null)
                    {
                        MCharting.Series legendEntry2 = new MCharting.Series();
                        legendEntry2.Name                  = "Trend";
                        legendEntry2.Style.DrawLines       = new Pen(Color.Black, this._core.Options.LineWidth);
                        legendEntry2.Style.DrawLines.Width = 4;
                        plot.LegendEntries.Add(legendEntry2);

                        this.AddToPlot(plot, peak, seriesNames, stylisedPeak.ForceTrend, "Trend data", opts, EPlot.ByBatch | EPlot.DrawLine | EPlot.DrawBold, groupLegends, legendEntry2);
                    }

                    this.DrawLabels(plot, opts.ConditionsSideBySide, order, opts.DrawExperimentalGroupAxisLabels);
                    return;
                }

                // Sort data
                ConfigurationTrend trend = opts.SelectedTrend;
                Vector             avg   = stylisedPeak.ForceTrend ?? trend.CreateTrend(this._core, vector);
                Vector             min   = MinSmoother.CreateTrend(this._core, vector);
                Vector             max   = MaxSmoother.CreateTrend(this._core, vector);

                // --- PLOT MEAN & SD (lines across)
                if (opts.ShowVariableMean)
                {
                    this.AddMeanAndSdLines(plot, opts, vector.Values, peak, groupLegends);
                }

                // --- RANGE (shaded area) ---
                if (opts.ShowRanges)
                {
                    this.AddUpperAndLowerShade(plot, opts, seriesNames, peak, min, max, groupLegends);
                }

                // --- RAW DATA (points) ---
                if (opts.ShowPoints && !stylisedPeak.IsPreview)
                {
                    MCharting.Series legendEntry = new MCharting.Series();
                    legendEntry.Name             = "Observations";
                    legendEntry.Style.DrawPoints = new SolidBrush(Color.Black);
                    plot.LegendEntries.Add(legendEntry);

                    this.AddToPlot(plot, peak, seriesNames, vector, "Raw data", opts, EPlot.None, groupLegends, legendEntry);
                }

                // --- RANGE (lines) ---
                if (opts.ShowMinMax)
                {
                    MCharting.Series legendEntry = new MCharting.Series();
                    legendEntry.Name            = "Range min/max";
                    legendEntry.Style.DrawLines = new Pen(Color.Gray, this._core.Options.LineWidth);
                    plot.LegendEntries.Add(legendEntry);

                    this.AddToPlot(plot, peak, seriesNames, min, "Min value", opts, EPlot.DrawLine, groupLegends, legendEntry);
                    this.AddToPlot(plot, peak, seriesNames, max, "Max value", opts, EPlot.DrawLine, groupLegends, legendEntry);
                }

                // --- TREND (thick line) ---
                if (opts.ShowTrend)
                {
                    MCharting.Series legendEntry = new MCharting.Series();
                    legendEntry.Name                  = "Trend";
                    legendEntry.Style.DrawLines       = new Pen(Color.Black, this._core.Options.LineWidth);
                    legendEntry.Style.DrawLines.Width = this._core.Options.LineWidth * 4;
                    plot.LegendEntries.Add(legendEntry);

                    this.AddToPlot(plot, peak, seriesNames, avg, "Trend data", opts, EPlot.DrawLine | EPlot.DrawBold, groupLegends, legendEntry);
                }

                // --- LABELS ---
                this.DrawLabels(plot, opts.ConditionsSideBySide, order, opts.DrawExperimentalGroupAxisLabels);
            }
            finally
            {
                this.CompleteNewPlot(plot);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Plots a line of conditions on the graph
        /// </summary>
        /// <param name="peak">Peak to plot</param>
        /// <param name="seriesNames">Names of existing series</param>
        /// <param name="intensities">Intensity values (y)</param>
        /// <param name="seriesName">Name of this series</param>
        /// <param name="xInfo">Info for x position of intentises (in same order as intensities)</param>
        /// <param name="line">Line or dots/</param>
        /// <param name="bold">Bold line?</param>
        /// <param name="isConditions">Order by conditions or obervations</param>
        private void AddToPlot(
            MCharting.Plot plot,
            Peak peak,
            Dictionary <string, MCharting.Series> seriesNames,
            Vector intensities,
            string seriesName,
            StylisedPeakOptions o,
            EPlot draw,
            Dictionary <GroupInfoBase, MCharting.Series> groupLegends,
            MCharting.Series legend)
        {
            // Iterate whatever it is we're iterating
            for (int i = 0; i < intensities.Observations.Length; ++i)
            {
                // Get the values
                ObservationInfo obs = intensities.Observations[i];

                // Name the series
                if (draw.HasFlag(EPlot.ByBatch))
                {
                    if (!o.ViewBatches.Contains(obs.Batch))
                    {
                        continue;
                    }
                }
                else
                {
                    if (!o.ViewGroups.Contains(obs.Group))
                    {
                        continue;
                    }
                }

                bool          colorByBatch = draw.HasFlag(EPlot.ByBatch);
                GroupInfoBase seriesUsing  = colorByBatch ? (GroupInfoBase)obs.Batch : (GroupInfoBase)obs.Group;

                string           name = seriesName + " for " + seriesUsing.DisplayName;
                MCharting.Series series;

                // Create the series (if required)
                if (!seriesNames.ContainsKey(name))
                {
                    series = plot.Series.Add(name);
                    series.Style.StrictOrder = SeriesStyle.EOrder.X;
                    series.ApplicableLegends.Add(groupLegends[seriesUsing]);
                    series.ApplicableLegends.Add(legend);
                    seriesNames.Add(name, series);
                    series.Tag = peak;

                    Color colour = (draw.HasFlag(EPlot.DrawBold) || draw.HasFlag(EPlot.ByBatch) || !o.ShowTrend) ? seriesUsing.Colour : seriesUsing.ColourLight;

                    if (draw.HasFlag(EPlot.DrawLine))
                    {
                        series.Style.DrawLines       = new Pen(colour);
                        series.Style.DrawLines.Width = draw.HasFlag(EPlot.DrawBold) ? this._core.Options.LineWidth * 4 : this._core.Options.LineWidth;
                    }
                    else
                    {
                        UiControls.CreateIcon(series, seriesUsing);
                    }
                }
                else
                {
                    series = seriesNames[name];
                }

                // Get the X position
                double xPos;

                if (draw.HasFlag(EPlot.ByBatch))
                {
                    xPos = obs.Order;

                    if (o.ConditionsSideBySide)
                    {
                        xPos += this.GetBatchOffset(o.ViewBatches, obs.Batch);
                    }
                }
                else
                {
                    xPos = obs.Time;

                    if (o.ConditionsSideBySide)
                    {
                        xPos += this.GetTypeOffset(o.ViewGroups, obs.Group);
                    }
                }

                // Get the Y position
                double yPos = intensities.Values[i];

                if (double.IsNaN(yPos) || double.IsInfinity(yPos))
                {
                    yPos = 0;
                }

                // Create the point
                MCharting.DataPoint cdp = new MCharting.DataPoint(xPos, yPos);
                IntensityInfo       tag = new IntensityInfo(obs.Time, obs.Rep, obs.Group, yPos);
                cdp.Tag = tag;
                series.Points.Add(cdp);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Adds the mean and standard deviation lines to the plot.
        /// </summary>
        /// <param name="plot">Target plot</param>
        /// <param name="o">Options</param>
        /// <param name="observations">Set of observations</param>
        /// <param name="peak">Peak being plotted</param>
        /// <param name="groupLegends">Dictionary to get group legends from</param>
        private void AddMeanAndSdLines(
            MCharting.Plot plot,
            StylisedPeakOptions o,
            IReadOnlyList <double> observations,
            Peak peak,
            Dictionary <GroupInfoBase, MCharting.Series> groupLegends)
        {
            MCharting.Series legendEntry = new MCharting.Series();
            legendEntry.Name                      = "Std. Dev. Min/Max";
            legendEntry.Style.DrawLines           = new Pen(Color.Gray, this._core.Options.LineWidth);
            legendEntry.Style.DrawLines.DashStyle = DashStyle.Dot;
            plot.LegendEntries.Add(legendEntry);

            MCharting.Series legendEntry2 = new MCharting.Series();
            legendEntry2.Name            = "Mean";
            legendEntry2.Style.DrawLines = new Pen(Color.Black, this._core.Options.LineWidth);
            plot.LegendEntries.Add(legendEntry2);

            // Iterate the types
            foreach (GroupInfo group in o.ViewGroups)
            {
                // Get the Y values
                double yMean = Maths.Mean(observations);
                double sd    = Maths.StdDev(observations, yMean);
                double yMin  = yMean - sd / 2;
                double yMax  = yMean + sd / 2;

                // Get the X values
                int xLeft  = @group.Range.Min;
                int xRight = @group.Range.Max;

                if (o.ConditionsSideBySide)
                {
                    int typeOffset = this.GetTypeOffset(o.ViewGroups, @group);
                    xLeft  += typeOffset;
                    xRight += typeOffset;
                }

                // Create the series
                MCharting.Series sMean = plot.Series.Add(@group.DisplayName + ": Mean");
                MCharting.Series sMin  = plot.Series.Add(@group.DisplayName + ": StdDevMin");
                MCharting.Series sMax  = plot.Series.Add(@group.DisplayName + ": StdDevMax");

                sMean.Style.StrictOrder = SeriesStyle.EOrder.X;
                sMin.Style.StrictOrder  = SeriesStyle.EOrder.X;
                sMax.Style.StrictOrder  = SeriesStyle.EOrder.X;

                sMean.ApplicableLegends.Add(groupLegends[group]);
                sMin.ApplicableLegends.Add(groupLegends[group]);
                sMax.ApplicableLegends.Add(groupLegends[group]);
                sMean.ApplicableLegends.Add(legendEntry2);
                sMin.ApplicableLegends.Add(legendEntry);
                sMax.ApplicableLegends.Add(legendEntry);

                sMean.Tag = peak;
                sMin.Tag  = peak;
                sMax.Tag  = peak;

                Color c = @group.ColourLight;
                sMean.Style.DrawLines = new Pen(c, this._core.Options.LineWidth);
                sMin.Style.DrawLines  = new Pen(c, this._core.Options.LineWidth);
                sMax.Style.DrawLines  = new Pen(c, this._core.Options.LineWidth);

                sMean.Style.DrawLines.DashStyle = DashStyle.Dash;
                sMin.Style.DrawLines.DashStyle  = DashStyle.Dash;
                sMax.Style.DrawLines.DashStyle  = DashStyle.Dash;

                // Add the points
                AddDataPoint(sMean, xLeft, yMean, @group);
                AddDataPoint(sMean, xRight, yMean, @group);

                AddDataPoint(sMin, xLeft, yMin, @group);
                AddDataPoint(sMin, xRight, yMin, @group);

                AddDataPoint(sMax, xLeft, yMax, @group);
                AddDataPoint(sMax, xRight, yMax, @group);
            }
        }
Exemplo n.º 8
0
        private void AddUpperAndLowerShade(
            MCharting.Plot plot,
            StylisedPeakOptions o,
            Dictionary <string, MCharting.Series> seriesNames,
            Peak peak,
            Vector min,
            Vector max,
            Dictionary <GroupInfoBase, MCharting.Series> groupLegends)
        {
            MCharting.Series legendEntry = new MCharting.Series();
            legendEntry.Name             = "Range";
            legendEntry.Style.DrawVBands = new SolidBrush(Color.Gray);
            plot.LegendEntries.Add(legendEntry);

            // Iterate the conditions
            for (int i = 0; i < min.Observations.Length; i++)
            {
                ObservationInfo obs = min.Observations[i];

                Debug.Assert(max.Observations[i] == min.Observations[i], "Expected max and min trends to match sequences.");

                if (o.ViewGroups.Contains(obs.Group))
                {
                    // Name the series
                    string           name = "Range for " + obs.Group.DisplayName;
                    MCharting.Series series;

                    // Create the series (if required)
                    if (!seriesNames.ContainsKey(name))
                    {
                        series = plot.Series.Add(name);
                        series.Style.StrictOrder = SeriesStyle.EOrder.X;
                        Color c = obs.Group.ColourLight;
                        c          = Color.FromArgb(0x80, c.R, c.G, c.B);
                        series.Tag = peak;
                        series.Style.DrawVBands = obs.Group.CreateBrush(c);
                        series.ApplicableLegends.Add(groupLegends[obs.Group]);
                        series.ApplicableLegends.Add(legendEntry);
                        seriesNames.Add(name, series);
                    }
                    else
                    {
                        series = seriesNames[name];
                    }

                    // Get the X coordinate
                    int typeOffset = this.GetTypeOffset(o.ViewGroups, obs.Group);

                    double xVal = obs.Time;

                    if (o.ConditionsSideBySide)
                    {
                        xVal += typeOffset;
                    }

                    // Get the Y coordinates
                    double yMin = min.Values[i];
                    double yMax = max.Values[i];

                    if (double.IsNaN(yMin) || double.IsInfinity(yMin))
                    {
                        yMin = 0;
                    }

                    if (double.IsNaN(yMax) || double.IsInfinity(yMax))
                    {
                        yMax = 0;
                    }

                    // Create the point
                    IntensityInfo       info1 = new IntensityInfo(obs.Time, null, obs.Group, yMin);
                    IntensityInfo       info2 = new IntensityInfo(obs.Time, null, obs.Group, yMax);
                    MCharting.DataPoint cdp   = new MCharting.DataPoint(xVal, new[] { yMin, yMax });
                    cdp.Tag = new[] { info1, info2 };
                    series.Points.Add(cdp);
                }
            }
        }
Exemplo n.º 9
0
        private void UpdatePlot()
        {
            if (this._scores == null)
            {
                this._lblSelection.Text      = this._errorMessage;
                this._lblSelection.ForeColor = Color.Red;
                this._chart.Visible          = false;
                return;
            }

            this._chart.Visible          = true;
            this._lblSelection.Text      = "";
            this._lblSelection.ForeColor = ForeColor;

            MCharting.Plot plot = new MCharting.Plot();

            plot.Title    = $"{this._lblMethod.Text} of {this._core.FileNames.Title}";
            plot.SubTitle = $"Source: {this._lblPcaSource.Text}, View: {this._lblPlotView.Text}, Legend: {this._lblLegend.Text}, Corrections: {this._lblCorrections.Text}, Observations: {this._lblObs.Text}, Peaks: {this._lblPeaks.Text}";

            switch (this._method)
            {
            case EMethod.Pca:
                plot.XLabel = $"PC{this._component + 1}";
                plot.YLabel = $"PC{this._component + 2}";
                break;

            case EMethod.Plsr:
                plot.XLabel    = $"Component {this._component + 1}";
                plot.YLabel    = $"Component {this._component + 2}";
                plot.SubTitle += ", PLSR Response: " + this._lblPlsrSource.Text;
                break;
            }

            this._chart.Style.Margin = new Padding(48, 48, 48, 48);
            plot.Style.GridStyle     = new Pen(Color.FromArgb(224, 224, 224));

            // Get the "rows"
            IEnumerator enSources;
            Column      column;

            this.GetSource(this._colourBy, out enSources, out column);

            // Get the "columns"
            double[,] plotPoints;

            if (this._plotSource == EPlotSource.Loadings)
            {
                plotPoints = this._loadings;
            }
            else
            {
                plotPoints = this._scores;
            }

            // Get the component
            if (this._component < 0)
            {
                this._component = 0;
            }

            if (this._component >= plotPoints.GetLength(1))
            {
                this._component = plotPoints.GetLength(1) - 1;
            }

            this._btnPrevPc.Enabled = this._component != 0;
            this._btnNextPc.Enabled = this._component != plotPoints.GetLength(1) - 1;

            this._lblPlotView.Text    = this._plotSource == EPlotSource.Loadings ? "Loadings" : "Scores";
            this._btnScores.Checked   = this._plotSource == EPlotSource.Scores;
            this._btnLoadings.Checked = this._plotSource == EPlotSource.Loadings;

            this._lblPcNumber.Text = "PC" + (this._component + 1).ToString() + " / " + plotPoints.GetLength(1);

            this._lblLegend.Text = column.DisplayName;

            bool isGroup = false;

            // Iterate scores
            for (int r = 0; r < plotPoints.GetLength(0); r++)
            {
                enSources.MoveNext();

                MCharting.Series series = GetOrCreateSeriesForValue(plot, column, (Visualisable)enSources.Current, ref isGroup);

                var coord = new MCharting.DataPoint(plotPoints[r, this._component], plotPoints[r, this._component + 1]);
                coord.Tag = enSources.Current;

                series.Points.Add(coord);
            }

            // Assign colours
            if (!column.HasColourSupport && !isGroup)
            {
                foreach (var colour in PlotCreator.AutoColour(plot.Series))
                {
                    colour.Key.Style.DrawPoints = new SolidBrush(colour.Value);
                }
            }

            this._chart.Style.Animate         = true;
            this._chart.Style.SelectionColour = Color.Yellow;

            this._chart.SetPlot(plot);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Returns the series for a group and vector, creating one if it doesn't already exist
        /// </summary>
        /// <param name="plot">Plot to create series in</param>
        /// <param name="existingSeries">Existing series</param>
        /// <param name="group">Group to create series for</param>
        /// <param name="vector">Vector to create series for</param>
        /// <param name="style">Styles (colours and highlights)</param>
        /// <param name="groupLegends">Where to add legends to</param>
        /// <param name="lineLegend">Where to add legends to</param>
        /// <returns>Series (new or existing)</returns>
        private MCharting.Series GetOrCreateSeries(
            MCharting.Plot plot,
            Dictionary <GroupInfo, MCharting.Series> existingSeries,
            GroupInfo group,
            Vector vector,
            StylisedCluster style,
            Dictionary <GroupInfoBase, MCharting.Series> groupLegends,
            MCharting.Series lineLegend,
            HashSet <MCharting.Series> toBringToFront,
            bool bandw)
        {
            MCharting.Series series;

            if (existingSeries.TryGetValue(group, out series))
            {
                return(series);
            }

            Peak peak = vector.Peak;
            Dictionary <Peak, LineInfo> colours = style?.Colours;

            // Each peak + condition gets its own series (yes we end up with lots of series)
            series = new MCharting.Series();
            series.Style.StrictOrder = SeriesStyle.EOrder.X;
            series.Name = vector.ToString() + " : " + group.DisplayName;
            series.ApplicableLegends.Add(groupLegends[group]);
            series.ApplicableLegends.Add(lineLegend);
            plot.Series.Add(series);

            // If the parameters specify a colour for this peak use that, else use the default
            if (colours != null && colours.ContainsKey(peak))
            {
                series.Style.DrawLines           = new Pen(colours[peak].Colour, this._core.Options.LineWidth);
                series.Style.DrawLines.DashStyle = colours[peak].DashStyle;
                series.Name = colours[peak].SeriesName + " : " + group.DisplayName;
            }
            else
            {
                series.Style.DrawLines = new Pen(group.Colour, this._core.Options.LineWidth);
            }

            if (bandw)
            {
                series.Style.DrawLines = new Pen(this._core.Options.Colours.InputVectorJoiners, this._core.Options.LineWidth);
            }

            series.Style.DrawLines.Width = this._core.Options.LineWidth;
            series.Tag = peak;

            if (style.Highlight != null && !bandw)
            {
                foreach (StylisedCluster.HighlightElement highlight in style.Highlight)
                {
                    if (highlight.Peak == vector.Peak &&
                        (highlight.Group == null || highlight.Group == group))
                    {
                        series.Style.DrawLines.Color = this._core.Options.Colours.NotableHighlight;
                        series.Style.DrawLines.Width = this._core.Options.LineWidth * 2;
                        toBringToFront.Add(series);
                        break;
                    }
                }
            }

            existingSeries.Add(group, series);

            return(series);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Creates the MChart.Plot object
        /// </summary>
        /// <param name="axes">Include axis text (i.e. not a preview)</param>
        /// <param name="toPlot">What will be plotted</param>
        /// <returns>New MChart.Plot object</returns>
        protected MCharting.Plot PrepareNewPlot(bool axes, Associational toPlot, IntensityMatrix sourceMatrix)
        {
            MCharting.Plot plot = new MCharting.Plot();

            PlotSetup setup = this._core.Options.GetPlotSetup(this._core, toPlot);

            if (this._mnuPlot != null)
            {
                if (toPlot != null)
                {
                    this._mnuPlot.Text  = toPlot.DisplayName;
                    this._mnuPlot.Image = UiControls.GetImage(toPlot.Icon, true);

                    if (ParseElementCollection.IsNullOrEmpty(setup.Information))
                    {
                        this._mnuCustomText.Text = "(Click here to configure text)";
                    }
                    else
                    {
                        this._mnuCustomText.Text = setup.Information.ConvertToString(toPlot, this._core);
                    }

                    this._mnuPlot.Visible       = true;
                    this._mnuCustomText.Visible = this._chkShowCustom.Checked;
                }
                else
                {
                    this._mnuPlot.Text          = "No selection";
                    this._mnuPlot.Image         = Resources.IconTransparent;
                    this._mnuPlot.Visible       = false;
                    this._mnuCustomText.Text    = "";
                    this._mnuCustomText.Visible = false;
                }
            }

            if (this._core.Options.NoAxes)
            {
                axes = false;
            }

            if (axes)
            {
                plot.Style.BackColour = this._core.Options.Colours.PlotBackground;

                if (!ParseElementCollection.IsNullOrEmpty(setup.AxisX))
                {
                    plot.XLabel = setup.AxisX.ConvertToString(toPlot, this._core);
                }

                if (!ParseElementCollection.IsNullOrEmpty(setup.AxisY))
                {
                    plot.YLabel = setup.AxisY.ConvertToString(toPlot, this._core);
                }

                if (!ParseElementCollection.IsNullOrEmpty(setup.Title))
                {
                    plot.Title = setup.Title.ConvertToString(toPlot, this._core);
                }

                if (!ParseElementCollection.IsNullOrEmpty(setup.SubTitle))
                {
                    plot.SubTitle = setup.SubTitle.ConvertToString(toPlot, this._core);
                }

                plot.Style.AutoTickX    = false;
                plot.Style.GridStyle    = new Pen(this._core.Options.Colours.MinorGrid, this._core.Options.LineWidth);
                plot.Style.TickStyle    = new Pen(this._core.Options.Colours.MajorGrid, this._core.Options.LineWidth);
                plot.Style.AxisText     = new SolidBrush(this._core.Options.Colours.AxisTitle);
                this.Chart.Style.Margin = new Padding(this._core.Options.Margin);
            }
            else
            {
                plot.Style.BackColour   = this._core.Options.Colours.PreviewBackground;
                plot.Style.AutoTickX    = false;
                plot.Style.AutoTickY    = false;
                plot.Style.GridStyle    = null;
                plot.Style.TickStyle    = null;
                plot.Style.AxisStyle    = null;
                this.Chart.Style.Margin = Padding.Empty;
            }

            plot.Style.XMin = setup.RangeXMin.GetValue();
            plot.Style.XMax = setup.RangeXMax.GetValue();
            plot.Style.YMin = setup.RangeYMin.GetValue();
            plot.Style.YMax = setup.RangeYMax.GetValue();

            // Min/max of IM
            if (sourceMatrix != null)
            {
                if (setup.RangeYMin.Mode == EAxisRange.General)
                {
                    if (setup.RangeYMax.Mode == EAxisRange.General)
                    {
                        var range = sourceMatrix.AllValues.Range();
                        plot.Style.YMin = range.Min;
                        plot.Style.YMax = range.Max;
                    }
                    else
                    {
                        plot.Style.YMin = sourceMatrix.AllValues.Min();
                    }
                }
                else if (setup.RangeYMax.Mode == EAxisRange.General)
                {
                    plot.Style.YMax = sourceMatrix.AllValues.Max();
                }
            }

            switch (setup.RangeXMin.Mode)
            {
            case EAxisRange.Fixed:
                plot.Style.XMin = setup.RangeXMin.Value;
                break;

            case EAxisRange.Automatic:
            case EAxisRange.General:
                plot.Style.XMin = null;
                break;
            }


            //plot.Style.XMin = setup.RangeXMin.Get( toPlot );
            //plot.Style.XMax = setup.RangeXMax.Get( toPlot );
            //plot.Style.YMin = setup.RangeYMin.Get( toPlot );
            //plot.Style.YMax = setup.RangeYMax.Get( toPlot );

            return(plot);
        }
Exemplo n.º 12
0
 protected void CompleteNewPlot(MCharting.Plot plot)
 {
     this._chart.SetPlot(plot);
 }