Profile Picture

INPaintCallBack.OnBeforePaint interfering with NChartControl.ImageExporter

Posted By Kevin Harrison 7 Years Ago
Author
Message
Kevin Harrison
Posted 7 Years Ago
View Quick Profile
Supreme Being

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
Last Active: 3 Years Ago
Posts: 176, Visits: 1,865
Bugfinder strikes again! :-)

Thanks for the speedy response. Is the release you're referring to 17.6.16.12?

Nevron Support
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hi Kevin,
Yes that's the latest one - do you meet any problems?

Best Regards,
Nevron Support Team



Kevin Harrison
Posted 6 Years Ago
View Quick Profile
Supreme Being

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
Last Active: 3 Years Ago
Posts: 176, Visits: 1,865
Hi guys
Sadly I  have found a problem with using
m_ChartControl.document.RecalcLayout(m_ChartControl.document.CurrentRenderingContext);
(using 18.4.26.12)
If this line is executed, then I find that none of the interactivity tools work
Interestingly, if I rotate the mouse wheel slightly then zoom starts working
If I have both DataZoom and DataPointDrag activated, then rotating the mouse wheel activates zoom, but not DataPointDrag.
However, if I perform a zoom, then data point drag starts working.

Can you shed some light on this please?
It is not easy for me to send you a sample project, so I hope you can reproduce this easily or suggest  a way for me to overcome this.

Thanks
Kevin


Nevron Support
Posted 6 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hi Kevin,
It's most likely something related to the selection, but its hard to tell like that. We tried to reproduce a problem but were unable to do so. However you can send us the state of the control after its broken to check it:
nChartControl1.Serializer.SaveControlStateToFile("c:\\temp\\chartstate.xml", Nevron.Serialization.PersistencyFormat.CustomXML, null);
Hopefully this will shed light as to why it fails to perform data point dragging after the layout.


Best Regards,
Nevron Support Team



Kevin Harrison
Posted 6 Years Ago
View Quick Profile
Supreme Being

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
Last Active: 3 Years Ago
Posts: 176, Visits: 1,865
I've found what's happening and have a fix, though I'd like advice on whether it's something I'm doing or if there's a bug. My code boils down to:
public void OnBeforePaint(NPanel panel, NPanelPaintEventArgs eventArgs)
(
     DoStuff();
      if (requiresRecalculate)
            {
                this.chartControl.document.Calculate();
                 this.chartControl.document.RecalcLayout(this.chartControl.document.CurrentRenderingContext);
            }
 }

if requiresRecalculate is false then we're Ok and all data interactivity behaves as expected.

However, if requiresRecalculate is true, then when clicking on the rendered chart, OnBeforePaint is entered again, as though the chart hasn't finished rendering.
My use of the mouse wheel fixed it because DoStuff() makes requiresRecalculate false.
My solution is to add extra checking in DoStuff, so that once requiresRecalculate has fired once, then on the second entry DoStuff detects the action has occurred, so we are done and don't recalculate again.

Extra info:
I notice that OnBeforePaint is entered twice when displaying the chart.
The second time originates from the following code, specifically the bolded line. It seems there may be some unexpected interaction here? Should I achieve this in a different way or modify this code?

   /// <summary>Intercepts mouse move to allow a cursor change depending upon the object beneath</summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="NMouseEventArgs"/> instance containing the event data.</param>
        /// <remarks>Code idea supplied by Nevron</remarks>
        public override void OnMouseMove(object sender, NMouseEventArgs e)
        {
            if (e == null)
                return;

             NControlView view = (NControlView)this.GetView();

            NHitTestCacheService hitTestService = view.GetServiceOfType(typeof (NHitTestCacheService)) as NHitTestCacheService;
            if (hitTestService == null)
                return;

            NHitTestResult hitTestResult = new NHitTestResult(hitTestService.HitTest(new NPointF(e.X, e.Y)) as NChartNode);
            INMouseService mouseService = (INMouseService) view.GetServiceOfType(typeof (INMouseService));

            bool cursorSet = false;
            if (hitTestResult.ChartElement == ChartElement.DataPoint && hitTestResult.Chart != null)
            {
                CartesianChartDefinition cartesianChartDefinition = hitTestResult.Chart.Tag as CartesianChartDefinition;
                ChartSeries series = cartesianChartDefinition?.ChartSeriesSet.HavingId((int) hitTestResult.Series.Tag);
                if (series != null && series.AllowDragging)
                {
                    mouseService.Cursor = cartesianChartDefinition.ChartLayout == CartesianChartLayout.Vertical ? Cursors.SizeNS : Cursors.SizeWE;
                    cursorSet = true;
                }
            }

            if (!cursorSet)
                mouseService.Cursor = Cursors.Default;

        }

Many thanks

Kevin
 



Nevron Support
Posted 6 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hi Kevin,
It is normal to have a render pass on the chart when it detects that the image map has changed - internally it uses a special render to build an image map (raster or vector depending on the target graphics 3D or 2D). This image map links the chart elements to their visual representation. We can expose a property that will allow you to have the ability to check whether the current rendering is part of a selection render or display rendering pass. Will that solve the problem (that way you won't have to have a variable in DoStuff that checks whether it was called before that)?


Best Regards,
Nevron Support Team



Kevin Harrison
Posted 6 Years Ago
View Quick Profile
Supreme Being

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
Last Active: 3 Years Ago
Posts: 176, Visits: 1,865
Thanks for the offer of the new variable, but now I understand it, I think I'll be fine.
I'm not actually adding a new variable in DoStuff.
DoStuff limits the size of the point symbol or line markers to a maximum, so I added a check for
       if (size != maxSize)
On the first pass this is true, so size is set to maxSize.
On the second pass, it isn't so requiresRecalculate is now false and we're done.

Many thanks as always

Kevin


Nevron Support
Posted 6 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746

Hi Kevin,
Understood - we exposed the property anyway and it will be available in subsequent builds Smile Let us know if you meet any problems.



Best Regards,
Nevron Support Team



Nevron Support
Posted 6 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746

Hi Kevin,
Understood - we exposed the property anyway and it will be available in subsequent builds Smile Let us know if you meet any problems.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic