Jump to content
Software FX Community

Ozzard

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by Ozzard

  1. Whoops - missed a step: 3.5) Delete the line in textButton_Click() that sets the chart's gallery.
  2. Software: Chart FX 7 for Windows Forms with the service pack installed. I'm trying to draw histograms (or, indeed, box plots) of multiple series, and to retain the series' labels when I do so. The technique I'm using is to load the series data and to set the current gallery type in the corresponding statistics object. I've now tried several different approaches, and all lead to the statistical series being labelled "Series1", "Series2" etc. To reproduce the issue: 1) Open the PassingData sample. 2) Extend the chart with a statistics extension. 3) Set the statistics extension's current gallery to Histogram. 4) Run the sample. 5) Click the "Text file" button. With the current gallery set to None, correct series labels are displayed. With the current gallery set to Histogram, Series1 and Series2 are displayed. How do I retain the series labels?
  3. I've created a BoxPlot by feeding it data explicitly (source appended). When I click the Properties icon on the chart toolbar, then click the Series tab, I get a NullReferenceException deep in Chart FX code: at ChartFX.WinForms.Internal.UI.h.e() at ChartFX.WinForms.Internal.UI.h.g() at ChartFX.WinForms.Internal.UI.h.h() at ChartFX.WinForms.Internal.UI.h.OnVisibleChanged(EventArgs ev) at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.TabPage.set_Visible(Boolean value) at System.Windows.Forms.TabControl.UpdateTabSelection(Boolean updateFocus) at System.Windows.Forms.TabControl.OnSelectedIndexChanged(EventArgs e) at System.Windows.Forms.TabControl.WmSelChange() at System.Windows.Forms.TabControl.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam) at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m) at System.Windows.Forms.Control.WmNotify(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam) at System.Windows.Forms.NativeWindow.DefWndProc(Message& m) at System.Windows.Forms.Control.DefWndProc(Message& m) at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.TabControl.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.RunDialog(Form form) at System.Windows.Forms.Form.ShowDialog(IWin32Window owner) at ChartFX.WinForms.Internal.UI.d.a(Object A_0, Object A_1, IUIObject A_2, Int32 A_3, ResourceSet A_4) at ChartFX.WinForms.Chart.ShowPropertiesDialog(Object context, Int32 pageNumber) at ChartFX.WinForms.at.a(CommandsEventArgs A_0, Boolean& A_1) at ChartFX.WinForms.at.a(Object A_0, CommandsEventArgs A_1, Boolean& A_2) at ChartFX.WinForms.at.a(Object A_0, CommandsEventArgs A_1) at ChartFX.WinForms.CommandCollection.a(Int32 A_0, Int32 A_1, IUIObject A_2) at ChartFX.WinForms.CommandCollection.a(Object A_0, Int32 A_1, ICommand A_2, Boolean A_3, IUIObject A_4) at ChartFX.WinForms.CommandCollection.a(Object A_0, Int32 A_1, ICommand A_2, Point A_3, CommandEventHandler A_4, CommandMenuFlags A_5) at ChartFX.WinForms.ToolBar.b(MouseEventArgs A_0) at ChartFX.WinForms.a.h(MouseEventArgs A_0) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.RunDialog(Form form) [...] Is this expected? -- code sample -- chart.Series.Clear(); chart.Data.Clear(); // Find how many series int seriesNumber = 0; foreach (Variable v in options.Parameters["data"].AsDataFrame.Variables) if (v.IsDoubleVariable) seriesNumber++; chart.Data.Series = seriesNumber; chart.Data.CommitChanges(); // TODO: Why is this necessary? // Add the series seriesNumber = 0; foreach (Variable v in options.Parameters["data"].AsDataFrame.Variables) { if (v.IsDoubleVariable) { DoubleVariable dv = v.AsDoubleVariable; if (dv.Data.Length > chart.Data.Points) chart.Data.Points = dv.Data.Length; for (int i = 0; i < dv.Data.Length; i++) chart.Data[seriesNumber, i] = dv.Data; seriesNumber++; } } -- End of code sample --
  4. I've been requested to make a box-and-whisker plot where the user can select between two methods of calculation for the box boundaries: EITHER 25th and 75th percentiles (which is implemented) OR one standard deviation. Is there a way of enabling this in Chart FX 7? My guess is that there isn't, but it'd be good to have that confirmed. - Peter
  5. I'm creating a box-and-whisker plot with several series. To distinguish the series I need to label each series along the X axis, to correspond to the name the user gives to each series of input data. How do I label a series in a box-and-whisker plot? - Peter
  6. I've got a requirement to create charts that are exportable to good old-fashioned Windows Metafile format, so that they can be displayed in a Rich Text Box. GDI+ has problems with anything other than solid lines in WMFs (it dithers them), so all the lines have to be solid. I've created a chart control on a form and have set all the axis and gridline styles that I can find to solid black. The designer contains the code in Listing 1, if anyone wants to check whether I've simply missed something. I've taken out the usual location, dock etc. properties from that listing. When the chart is displayed using the code in Listing 2, the horizontal gridlines are indeed solid black. However, the vertical gridlines (coming up from the numerical labels on the X axis) are dotted - and probably the default colour, though I've not put an eyedropper on it to check. As a result, these lines are dithered in the WMF output, making the package unusable for the purpose for which it was purchased. How can I set the vertical gridlines to be solid, and preferably black, in this case? Thanks in advance for any suggestions, - Peter -- Listing 1 -- this.chart.AxesStyle = ChartFX.WinForms.AxesStyle.Math; this.chart.AxisX.Grids.Major.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.chart.AxisX.Grids.Major.Style = System.Drawing.Drawing2D.DashStyle.Solid; this.chart.AxisX.Grids.Minor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.chart.AxisX.Line.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.chart.AxisX.Title.Text = "X Axis"; this.chart.AxisY.Grids.Major.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.chart.AxisY.Grids.Major.Style = System.Drawing.Drawing2D.DashStyle.Solid; this.chart.AxisY.Grids.Minor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.chart.AxisY.Line.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.chart.AxisY.Title.Text = "Y Axis"; this.chart.AxisY2.Grids.Major.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.chart.AxisY2.Grids.Major.Style = System.Drawing.Drawing2D.DashStyle.Solid; this.chart.AxisY2.Grids.Minor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.chart.AxisY2.Line.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); solidBackground1.AssemblyName = "ChartFX.WinForms.Adornments"; this.chart.Background = solidBackground1; this.chart.Border = new ChartFX.WinForms.Adornments.SimpleBorder(ChartFX.WinForms.Adornments.SimpleBorderType.Color, System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(125)))), ((int)(((byte)(138)))))); -- End of Listing 1 -- -- Listing 2 -- private void SetChartFromOptions() { switch (options.ChartType) { case ChartExplorerChartType.Histogram: ChartFX.WinForms.Statistical.Histogram gallery = statistics1.Gallery.Histogram; chart.GalleryAttributes = gallery; gallery.ShowNormal = chkShowNormal.Checked; chart.AxisY.Title.Text = "Count"; break; default: throw new ArgumentOutOfRangeException("options.ChartType", options.ChartType, "Unknown chart type"); } chart.Series.Clear(); chart.Data.Clear(); // Find how many series int seriesNumber = 0; foreach (Variable v in options.Parameters["data"].AsDataFrame.Variables) if (v.IsDoubleVariable) seriesNumber++; chart.Data.Series = seriesNumber; chart.Data.CommitChanges(); // TODO: Why is this necessary? // Add the series seriesNumber = 0; foreach (Variable v in options.Parameters["data"].AsDataFrame.Variables) { if (v.IsDoubleVariable) { DoubleVariable dv = v.AsDoubleVariable; if (dv.Data.Length > chart.Data.Points) chart.Data.Points = dv.Data.Length; for (int i = 0; i < dv.Data.Length; i++) chart.Data[seriesNumber, i] = dv.Data; seriesNumber++; } } chart.LegendBox.Visible = false; } -- End of Listing 2 --
  7. Chart FX 7 for WinForms with statistics extensions - so I think I'm in the right forum, but please redirect me if required :-). I'm trying to create a histogram chart (with multiple series, possibly each with its own histogram) by putting data straight into it, rather than data binding. Code is Listing 1 at the end. Problem 1: The legend is initially displayed correctly, but the series names revert to "Series 1", "Series 2" etc as soon as I do anything using the Chart FX toolbar. If I turn on bin counts via code, the labels stay intact. If I click the toolbar button to show counts, the labels are changed (and there's sometimes a display glitch as well). Problem 2: To bypass this, I've tried creating custom legend items and setting the Visible item attribute for the built-in series to false (Listing 2). The custom items are (correctly) displayed, and the standard items are (correctly) hidden. However, the border around the legend is (incorrectly) sized for all the legend items, including the invisible ones. Problem 3: To get round that little lot, I've tried telling the legend to autosize, then resizing it based on the automatically-calculated size. Except that the size isn't calculated until display time, so the height I read is always 0px. Ideally, I would like: 1) A way of preventing the series names reverting. 2) If there's no way of doing 1, a way of getting the border of the legend box to surround only the visible legend items. 3) If there's no way of doing 1 or 2, a way of setting the height that doesn't make assumptions about Chart FX's internal constants such as the height of a legend box item. All ideas welcome. - Peter -- Listing 1 -- private void SetChartFromOptions() { switch (options.ChartType) { case ChartExplorerChartType.Histogram: ChartFX.WinForms.Statistical.Histogram gallery = statistics1.Gallery.Histogram; chart.GalleryAttributes = gallery; gallery.ShowNormal = chkShowNormal.Checked; chart.AxisY.Title.Text = "Count"; statistics1.Studies.Add(StudyGroup.CentralTendencyMedian); statistics1.Studies.Add(StudyGroup.CentralTendencyMean); statistics1.LegendBox.Visible = true; break; default: throw new ArgumentOutOfRangeException("options.ChartType", options.ChartType, "Unknown chart type"); } chart.Series.Clear(); chart.Data.Clear(); // Find how many series int seriesNumber = 0; foreach (Variable v in options.Parameters["data"].AsDataFrame.Variables) if (v.IsDoubleVariable) seriesNumber++; chart.Data.Series = seriesNumber; chart.Data.CommitChanges(); // TODO: Why is this necessary? // Add the series seriesNumber = 0; foreach (Variable v in options.Parameters["data"].AsDataFrame.Variables) { if (v.IsDoubleVariable) { DoubleVariable dv = v.AsDoubleVariable; if (dv.Data.Length > chart.Data.Points) chart.Data.Points = dv.Data.Length; for (int i = 0; i < dv.Data.Length; i++) chart.Data[seriesNumber, i] = dv.Data; chart.Series[seriesNumber].Text = dv.Title; seriesNumber++; } } chart.LegendBox.Visible = seriesNumber > 1; } -- End of Listing 1 -- -- Listing 2 -- private void SetChartFromOptions() { switch (options.ChartType) { case ChartExplorerChartType.Histogram: ChartFX.WinForms.Statistical.Histogram gallery = statistics1.Gallery.Histogram; chart.GalleryAttributes = gallery; gallery.ShowNormal = chkShowNormal.Checked; chart.AxisY.Title.Text = "Count"; statistics1.Studies.Add(StudyGroup.CentralTendencyMedian); statistics1.Studies.Add(StudyGroup.CentralTendencyMean); statistics1.LegendBox.Visible = true; break; default: throw new ArgumentOutOfRangeException("options.ChartType", options.ChartType, "Unknown chart type"); } chart.Series.Clear(); chart.Data.Clear(); // Find how many series int seriesNumber = 0; foreach (Variable v in options.Parameters["data"].AsDataFrame.Variables) if (v.IsDoubleVariable) seriesNumber++; chart.Data.Series = seriesNumber; chart.Data.CommitChanges(); // TODO: Why is this necessary? // Add the series seriesNumber = 0; foreach (Variable v in options.Parameters["data"].AsDataFrame.Variables) { if (v.IsDoubleVariable) { DoubleVariable dv = v.AsDoubleVariable; if (dv.Data.Length > chart.Data.Points) chart.Data.Points = dv.Data.Length; for (int i = 0; i < dv.Data.Length; i++) chart.Data[seriesNumber, i] = dv.Data; chart.LegendBox.ItemAttributes[chart.Series, seriesNumber].Visible = false; chart.Series[seriesNumber].MarkerShape = MarkerShape.Rect; // Set up custom legend item CustomLegendItem legendItemA = new CustomLegendItem(); legendItemA.Text = dv.Title; legendItemA.MarkerShape = chart.Series[seriesNumber].MarkerShape; legendItemA.Color = chart.Series[seriesNumber].Color; chart.LegendBox.CustomItems.Add(legendItemA); seriesNumber++; } } chart.LegendBox.Visible = seriesNumber > 1; } -- End of Listing 2 --
  8. A late response, I accept - but the trick is to reset the stream's position to 0 before reading from it. MemoryStream stream = new MemoryStream(); chart.Export( FileFormat.Metafile, stream);stream.Position = 0; Image metaImage = Image.FromStream(stream); stream.Close();
×
×
  • Create New...