Group: Forum Members
Last Active: 10 Years Ago
Posts: 15,
Visits: 1
|
Now it is clear. Thank you very much for the answer.
|
Group: Forum Members
Last Active: Yesterday @ 1:54 AM
Posts: 3,054,
Visits: 4,009
|
Hi Vladimir, Unfortunately in .NET you cannot place controls on top of each other, even if they are marked as transparent. The solution would be to measure the control that contains the legend. The following code shows how to create two controls and the first one layout is synchronized with the second one so that it reserves some space in the layout for the legend. In addition the code automatically resizes the second control so that it matches the legend size: using System;using System.Drawing;using System.Windows.Forms;using Nevron.Chart;using Nevron.GraphicsCore; namespace WindowsFormsApplication1{ public partial class Form1 : Form{ public Form1(){ InitializeComponent(); } private void Form1_Load(object sender, EventArgs e){ // configure the second chart and measure itnChartControl2.Panels.Clear(); NLegend legend = new NLegend();nChartControl2.Panels.Add(legend); nChartControl2.BackgroundStyle.FrameStyle.Visible = false;legend.Location = new NPointL(new NLength(1, NGraphicsUnit.Pixel), new NLength(1, NGraphicsUnit.Pixel));for (int i = 0; i < 5; i++){ NLegendItemCellData licd = new NLegendItemCellData();licd.Text = "Data Item Value" + i.ToString();legend.Data.Items.Add(licd); } legend.Mode = LegendMode.Manual;// calculate the controlnChartControl2.Document.Calculate(); nChartControl2.Document.RecalcLayout(nChartControl1.View.Context); // create the second chartNChart chart = nChartControl1.Charts[0];NBarSeries bar = new NBarSeries();for (int i = 0; i < 5; i++){ bar.Values.Add(i); } chart.Series.Add(bar); nChartControl1.Legends[0].Mode = LegendMode.Disabled;// configure the chart location so that it does not overlap the legendchart.Location = new NPointL(0, 0);chart.Margins = new NMarginsL(10);chart.Size = new NSizeL(new NLength(nChartControl2.Width - legend.ContentArea.Width - 20, NGraphicsUnit.Pixel), new NLength(100, NRelativeUnit.ParentPercentage));nChartControl2.Location = new Point((int)(nChartControl1.Location.X + nChartControl1.Width - legend.ContentArea.Width - 10),nChartControl1.Location.Y + 10); nChartControl2.Width = ( int)legend.ContentArea.Width + 2; // leave some room for rounding errorsnChartControl2.Height = ( int)legend.ContentArea.Height + 2; // leave some room for rounding errors} } } This code produces a chart which looks like having an embedded legend, but you have two controls and you can update both of them dynamically...
Best Regards, Nevron Support Team
|
Group: Forum Members
Last Active: 10 Years Ago
Posts: 15,
Visits: 1
|
Thank you for quick answer. In this solution, how do I configure this second control to be totally transparent (except for legend) and how do I enable user interaction with underlying control? I suppose, that only way to print graph with legend would be to export both control images and combine them, is it? Thank you in advance.
|
Group: Forum Members
Last Active: Yesterday @ 1:54 AM
Posts: 3,054,
Visits: 4,009
|
Hi Vladimir, You cannot refresh the legend only, however you can place another chart control with a manual legend on top of first one and refresh that control only...
Best Regards, Nevron Support Team
|
Group: Forum Members
Last Active: 10 Years Ago
Posts: 15,
Visits: 1
|
Hello!
I am using Nevron Chart (v2012Vol1 Enterprise) to draw some measure-over-time 2D line graphs. My customer wants to see "current" values (values under cursor) for each series in legend. I'm using Axis Cursors and Data Cursor Tool, so I can handle ValueChanged event and get current time and value for each series. So far, so good. The problem is, that the only way I found so far to show those values in legend includes use of NChartControl.Refresh() method. And refreshing of all chart graphics on every mouse move is very slow. Is it any way that I can redraw/refresh legend only? NLegend has Refresh() method, but using it doesn't have any effect. Please help. Thanks in advance, Vladimir
|