NVennSeries: Issue rendering Venn Contour within OnPaint() method of UserControl class


NVennSeries: Issue rendering Venn Contour within OnPaint() method of...
Author
Message
Edem Attiogbe
Edem Attiogbe
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)
Group: Forum Members
Posts: 3, Visits: 1
I'm trying to render a Venn diagram within a System.Windows.Forms.UserControl class. I added an NVennSeries to an NVennChart, and the NVennChart to the NChartControl.

I do all the setup within either my UserControl's constructor OnLoad() eventhandler. Everything renders fine when my NVennSeries 'AddVennContour()' call is right after my setup code, but when I move the 'AddVennContour()' method call of the NVennSeries to my UserControl's OnPaint() method, nothing happens. I know OnPaint() is being called anytime the window changes.

Any ideas? Thanks

My Code:

this.vennChartTitle = nevronChartControl.Labels.AddHeader("Spotfire Novartis Venn Diagram");
this.vennChartTitle.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
this.vennChartTitle.TextStyle.ShadowStyle.Color = Color.BlueViolet;

this.nevronChartControl.Legends.Clear();
this.nevronChartControl.Charts.Clear();//Make sure we are starting fresh, with no Nevron Charts of any sort
this.nevronChartControl.Charts.Add(VennPlot);//Add the Nevron venn diagram component to the collection of Nevron Charts
this.VennPlot.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal);//Set the projection to Orthagonal
this.VennPlot.Series.Clear();

this.VennPlot.Series.Add(TheVennSeries);
this.TheVennSeries.Name = VennSeries;
this.TheVennSeries.Visible = true;




protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
NVennSeries vseries = this.VennPlot.Series[0] as NVennSeries;
vseries.ClearContours();//Remove any pre-existing venn rendering
vseries.AddVennContour(VennShape.Ellipse, new NPointF(15, 0), new NSizeF(50, 50), 0, 1);
}
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
Hello,

In general OnPaint is not the proper place to modify the chart control.
Apart from this, you have to call the Refresh method of the chart control in order to update it - like in most of the event handlers in our examples.


Best Regards,
Nevron Support Team


Edem Attiogbe
Edem Attiogbe
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)
Group: Forum Members
Posts: 3, Visits: 1
Thanks for the tips. calling the NChartControl's Refresh() method did the trick. Also, if it's not advisable to put this code in the UserControl's 'OnPaint()' method, where should it go? I'm looking through the Nevron example project/solution.

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
Hello Edem,

It depends on what you're trying to achieve. In general the control should be modified either in some initialization function like Form_Load or as a response to user input - i.e. in the event handlers of the form controls. What is the purpose of adding a Venn contour in OnPaint()?

Best Regards,
Nevron Support Team


Edem Attiogbe
Edem Attiogbe
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)
Group: Forum Members
Posts: 3, Visits: 1
I added Venn Contours within OnPaint() so that if a user re-sizes the main window, I my Venn Diagram will automatically adjust accordingly (the same way visualizations adjust in the Nevron Charts for Windows Forms - Examples project).

I have some other events attached to other controls to handle user data input changes.
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,

In general the chart contents are automatically resized when the control size is changed. I don't think we process the Paint event anywhere in our examples.

By the way, if you want to do some action in response to a user resize you can use the Resize event, because Paint is fired on other occasions too.



Best Regards,
Nevron Support Team


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