Restricting maximum marker size


Author
Message
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi Kevin,

In general you should not see performance degradation compared to a point series - what are the marker settings? - circle rendering for example is much slower than rectangles...

Best Regards,
Nevron Support Team


Kevin Harrison 1
Kevin Harrison 1
Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)
Group: Forum Members
Posts: 176, Visits: 1.9K

Answering my own question - performance seems to be poor using marker shapes. Is this as expected?

Thanks

Kevin


Kevin Harrison 1
Kevin Harrison 1
Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)
Group: Forum Members
Posts: 176, Visits: 1.9K
Are there any disadvantages to using markers than the point shapes?
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi Kevin,

In general point series do not need markers (you can consider the point data point as a kind of marker), however this functionality is generally inherited from the functionality of the base classes the point series inherits from - so it's there and implemented. The only thing you need to do in order to use markers (and not point series data point visualization) is to ensure that the marker style has horizontal and vertical alignments set to center. If you meet any problems or have any questions please let us know...



Best Regards,
Nevron Support Team


Kevin Harrison 1
Kevin Harrison 1
Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)
Group: Forum Members
Posts: 176, Visits: 1.9K

Hi

Sorry, I didn't really understand your last reply, probably because I don't understand why point series have a MarkerStyle, but the point symbols are determined by the PointShape and the size by Size, whereas line series use the MarkerStyle. Why the different behaviour in the first place?

Anyway, your reply suggests that point series can have markers and no points, but the whole reason I started having to use PointShape and Size is that MarkerStyles didn't work for me for point series! Perhaps I'm missing the point (sorry!) of the reason point series exist separately from line series?

Your confusedly

Kevin


Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi Kevin,

The functionality of point series with markers and hidden points is identical to a point series with min / max control or probably you need a combination of both?

Best Regards,
Nevron Support Team


Kevin Harrison 1
Kevin Harrison 1
Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)
Group: Forum Members
Posts: 176, Visits: 1.9K

Can someone reply please?

Thanks

Kevin


Kevin Harrison 1
Kevin Harrison 1
Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)
Group: Forum Members
Posts: 176, Visits: 1.9K

Thaks for the speedy response, but there is still a size discontinuity.

Would it be possible to add a maximum size for point series in the next release? Then I can remove all this code (assuming point and line series behave identically)

Thanks

Kevin


Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi Kevin,

Probably the best way to do it is to use a points series with markers and hide the points.

Regarding your questions:

1) I tried using chart panel Width / Height, but the numbers were very small and I do not know how to convert them to pixels. Instead, I used the size of the chart control. Am I converting the chart control size to pixels correctly? This is not the same as the chart panel size, but, even with no legend, there is still a size discontinuity.

You need to access the chart panel Bounds (Width / Height are used to specify an aspect of the chart).

2) When I use ParentPercentage in setting the MarkerSize of a series, what exactly is the Parent?

It is generally the a size relative to the parent panel bounds Width or Height, but with some exceptions:
1. When the length is used for X coordinates - it is percentage of the Width.
2. When the length is used for Y coordinates - it is percentage of the Height.
3. When the length is used for both X and Y coordinates - it is calculated as (Width + Height) * Percentage / 200.0;

3) Ideally I would read the size of the marker directly in pixels - can I do this?
No, however the code below shows how to calculate this correctly.

We tested with the following code:

using System;
using System.Windows.Forms;
using Nevron.Chart;
using Nevron.Chart.WinForm;
using Nevron.GraphicsCore;

namespace WindowsFormsApplication1
{
   public partial class Form1 : Form
   {
      public Form1()
      {
         InitializeComponent();
      }

      private void Form1_Load(object sender, EventArgs e)
      {
         NChart chart = nChartControl1.Charts[0];

         chart.BoundsMode = BoundsMode.Fit;

         NPointSeries point = new NPointSeries();

         point.UseXValues = true;
         point.DataLabelStyle.Visible = false;
         point.MarkerStyle.Visible = false;

         Random rand = new Random();

         for (int i = 0; i < 10; i++)
         {
            double yValue = rand.Next(100);
            double xValue = rand.Next(100);

            point.XValues.Add(xValue);
            point.Values.Add(yValue);
         }

         chart.Series.Add(point);
         chart.PaintCallback = new NPaintCallback(nChartControl1);
      }

      internal class NPaintCallback : INPaintCallback
      {
         public NPaintCallback(NChartControl chartControl)
         {
            m_ChartControl = chartControl;
         }
         NChartControl m_ChartControl;
         float DefaultPercentagePointSize = 10;
         float MaximumPointSize = 10;

         #region INPaintCallback Members

         public void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs)
         {
            
         }

         public void OnBeforePaint(NPanel panel, NPanelPaintEventArgs eventArgs)
         {
            NChart chart = (NChart)panel;
            bool seriesFound = false;
            bool requiresRecalculate = false;
            NLength requiredMarkerSize = NLength.Empty;

            foreach (NSeries series in chart.Series)
            {
               NPointSeries pointSeries = series as NPointSeries;
               NLineSeries lineSeries = series as NLineSeries;

               if (pointSeries != null || lineSeries != null)
               {
                  // Determine if size needs changing for the first series only.
                  if (!seriesFound)
                  {
                     // Set flag so this calculation is only executed once
                     seriesFound = true;

                     // Determine if the point size should be changed
                     bool overMaximum = ((chart.Bounds.Width + chart.Bounds.Height) * this.DefaultPercentagePointSize / 200.0) > (double)this.MaximumPointSize;
                     NLength markerSize = pointSeries != null ? pointSeries.Size : lineSeries.MarkerStyle.Width;

                     requiresRecalculate = overMaximum ? markerSize.MeasurementUnit == NRelativeUnit.ParentPercentage : markerSize.MeasurementUnit == NGraphicsUnit.Pixel;
                     requiredMarkerSize = overMaximum ? new NLength((float)this.MaximumPointSize, NGraphicsUnit.Pixel) : new NLength((float)this.DefaultPercentagePointSize, NRelativeUnit.ParentPercentage);
                  }

                  // Reset the point size if required
                  if (requiresRecalculate)
                  {
                     if (pointSeries != null)
                        pointSeries.Size = requiredMarkerSize;
                     else
                     {
                        lineSeries.MarkerStyle.Width = requiredMarkerSize;
                        lineSeries.MarkerStyle.Height = requiredMarkerSize;
                     }
                  }
               }
            }

            // Recalculate the layout only if necessary
            if (requiresRecalculate)
            {
               this.m_ChartControl.Document.Calculate();
               this.m_ChartControl.RecalcLayout();
            }
         }

         #endregion
      }

      private void button1_Click(object sender, EventArgs e)
      {
         nChartControl1.ShowEditor();
      }
   }
}

Let us know if you meet any problems.

Best Regards,
Nevron Support Team


Kevin Harrison 1
Kevin Harrison 1
Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)
Group: Forum Members
Posts: 176, Visits: 1.9K

Because I need to limit the size of both line and point series, sometimes on the same chart, I have resorted to using the PaintCallback method you described earlier. I am attempting to calculate the change point when the % setting should switch over to the fixed pixel size (and vice versa), but I am getting a jump in size at the crossover point. My code is below.

There are several things I am not sure about.

1) I tried using chart panel Width / Height, but the numbers were very small and I do not know how to convert them to pixels.
Instead, I used the size of the chart control. Am I converting the chart control size to pixels correctly? This is not the same as the chart panel size, but, even with no legend, there is still a size discontinuity.
2) When I use ParentPercentage in setting the MarkerSize of a series, what exactly is the Parent?
3) Ideally I would read the size of the marker directly in pixels - can I do this?

Any other help would be most welcome.

     public void OnBeforePaint(NPanel panel, NPanelPaintEventArgs eventArgs)
        {
            NChart chart = (NChart)panel;
            double chartSize = Math.Min(this.chartControl.Width, this.chartControl.Height);

            bool seriesFound = false;
            bool requiresRecalculate = false;
            NLength requiredMarkerSize = NLength.Empty;

            foreach (NSeries series in chart.Series)
            {
                NPointSeries pointSeries = series as NPointSeries;
                NLineSeries lineSeries = series as NLineSeries;
                if (pointSeries != null || lineSeries != null)
                {
                    // Determine if size needs changing for the first series only.
                    if (!seriesFound)
                    {
                        // Set flag so this calculation is only executed once
                        seriesFound = true;

                        // Have to convert the returned chartSize to pixels to compare with the maximum pixel size 
                        NMeasurementUnitConverter converter = new NMeasurementUnitConverter(eventArgs.Graphics.DpiX, eventArgs.Graphics.DpiY);
                        float pixelsPerPointUnit = converter.ConvertX(NGraphicsUnit.Point, NGraphicsUnit.Pixel, 1);

                        // Determine if the point size should be changed
                        bool overMaximum = (chartSize * pixelsPerPointUnit * this.DefaultPercentagePointSize / 100.0) > (double)this.MaximumPointSize;
                        NLength markerSize = pointSeries != null ? pointSeries.Size : lineSeries.MarkerStyle.Width;
                        requiresRecalculate = overMaximum ? markerSize.MeasurementUnit == NRelativeUnit.ParentPercentage : markerSize.MeasurementUnit == NGraphicsUnit.Pixel;
                        requiredMarkerSize = overMaximum ? new NLength((float)this.MaximumPointSize, NGraphicsUnit.Pixel) : new NLength((float)this.DefaultPercentagePointSize, NRelativeUnit.ParentPercentage);
                    }

                    // Reset the point size if required
                    if (requiresRecalculate)
                    {
                        if (pointSeries != null)
                            pointSeries.Size = requiredMarkerSize;
                        else
                        {
                            lineSeries.MarkerStyle.Width = requiredMarkerSize;
                            lineSeries.MarkerStyle.Height = requiredMarkerSize;
                        }
                    }
                }
            }

            // Recalculate the layout only if necessary
            if (requiresRecalculate)
            {
                this.chartControl.Document.Calculate();
                this.chartControl.RecalcLayout();
            }
        }

 


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search