INPaintCallBack.OnBeforePaint interfering with NChartControl.ImageExporter


Author
Message
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
This is a behaviour change between 16.8.8.12 and 17.3.6.12

On your helpful recommendation we added an INPaintCallBack and use OnBeforePaint to allow the user to change the symbol sizes on chart lines by turning the mouse wheel. This works fine in 16.8.8.12 and 17.3.6.12. However, we have found that the OnBeforePaint code affects chart export in 17.3.612 - the chart is not resized in the export when the export size is changed form the default size.

I have tracked this to these lines of code:

this.chartControl.document.Calculate();
this.chartControl.RecalcLayout();

If they are removed the export is the correct size but the symbol resizing has not been applied to the export.

Is there a different way to achieve this in 17.3.6.12?

I also notice that previously I could reorganise panel layout; e.g. moving the legend panel from right to left and the chart would redraw. Now I have to explicitly call NChartControl.Refresh().

Some general advice on the changes and recommended strategies would be much appreciated.

Thanks

Kevin
Replies
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 guys

I have found an issue with the suggested code relating to 3D charts.
The chart area is blank; i.e. not rendered, if cartesianChart.Enable3D is set to true.
Cabn you suggest a solution pelase?

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,
Indeed there is a problem in the 3D case - we just released a new SP of the control that fixes this issue. Also the code that recalculates the layout should be changed to:
m_ChartControl.document.RecalcLayout(m_ChartControl.document.CurrentRenderingContext);
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
Bugfinder strikes again! :-)

Thanks for the speedy response. Is the release you're referring to 17.6.16.12?
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,
Yes that's the latest one - do 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
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
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,
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 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
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
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,
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


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Kevin Harrison 1 - 8 Years Ago
Nevron Support - 8 Years Ago
Kevin Harrison 1 - 8 Years Ago
Nevron Support - 8 Years Ago
Kevin Harrison 1 - 8 Years Ago
                         Hi Kevin, The control works properly - when you call...
Nevron Support - 8 Years Ago
Kevin Harrison 1 - 8 Years Ago
Nevron Support - 8 Years Ago
Kevin Harrison 1 - 8 Years Ago
Nevron Support - 8 Years Ago
                         Bugfinder strikes again! :-) Thanks for the speedy response. Is the...
Kevin Harrison 1 - 8 Years Ago
                             Hi Kevin, Yes that's the latest one - do you meet any problems?
Nevron Support - 8 Years Ago
                                 Hi guys Sadly I have found a problem with using...
Kevin Harrison 1 - 7 Years Ago
                                     Hi Kevin, It's most likely something related to the selection, but its...
Nevron Support - 7 Years Ago
                                         I've found what's happening and have a fix, though I'd like advice on...
Kevin Harrison 1 - 7 Years Ago
                                             Hi Kevin, It is normal to have a render pass on the chart when it...
Nevron Support - 7 Years Ago
Kevin Harrison 1 - 7 Years Ago
Nevron Support - 7 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search