Export Chart with multiple charts?

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
Greg9504
Posts: 38
Joined: Fri Dec 06, 2013 4:51 pm

Export Chart with multiple charts?

Post by Greg9504 » Tue May 13, 2014 1:47 pm

Currently I'm using a second LightningChartUltimate object to generate a color scale legend. Similar to what is done in the ExampleStanford.cs example, except I am using the second plot for color scale where as the sample uses the second plot to display a text legend.

The problem is that when I export the main plot the second plot is not exported as part of the image (emf format). I have set the parent of the second plot to the first plot and it is displayed within the margins of the main plot.

Here is a screen shot showing the original plot within the application:
exportplotorg.jpg
exportplotorg.jpg (151.89 KiB) Viewed 7617 times
When I export the plot and place it in Word it looks like (notice no color legend):
exportplot.jpg
exportplot.jpg (56.7 KiB) Viewed 7617 times
This is the code used to create the second chart:

Code: Select all


            m_chartAnotherLegendBox = new LightningChartUltimate(LicenseKeys.LicenseKeyStrings.LightningChartUltimate);
            
            m_chartAnotherLegendBox.BeginUpdate();
            //Set chart name
            m_chartAnotherLegendBox.Name = "Dummy chart for another legend box";
            m_chartAnotherLegendBox.Parent = m_chart; //<----- parent set to main chart
            m_chartAnotherLegendBox.Title.Visible = false;
            m_chartAnotherLegendBox.ColorTheme = ColorTheme.LightGray;

            //Set margins, location and anchor it to top-right corner
            m_chartAnotherLegendBox.ViewXY.Margins = new Padding(0, 0, 0, 0);
            m_chartAnotherLegendBox.Size = new Size(120, 300);
            m_chartAnotherLegendBox.Location = new Point(m_chart.ClientSize.Width - m_chartAnotherLegendBox.Size.Width, m_chart.ViewXY.Margins.Top);
            m_chartAnotherLegendBox.Anchor = AnchorStyles.Top | AnchorStyles.Right;

            //Set graph background fill to transparent, to hide it
            m_chartAnotherLegendBox.ViewXY.GraphBackground.Color = Color.Transparent;
            m_chartAnotherLegendBox.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
            m_chartAnotherLegendBox.ViewXY.GraphBorderColor = Color.Transparent;
            m_chartAnotherLegendBox.BorderStyle = BorderStyle.None;

            //Hide axis grids
            m_chartAnotherLegendBox.ViewXY.XAxes[0].MajorGrid.Visible = false;
            m_chartAnotherLegendBox.ViewXY.YAxes[0].MajorGrid.Visible = false;

            //Set legend box properties
            m_chartAnotherLegendBox.ViewXY.LegendBox.Position = LegendBoxPosition.TopLeft;
            m_chartAnotherLegendBox.ViewXY.LegendBox.Offset.SetValues(0, 0);
            m_chartAnotherLegendBox.ViewXY.LegendBox.Layout = LegendBoxLayout.Vertical;
            m_chartAnotherLegendBox.ViewXY.LegendBox.ShowCheckboxes = false;
            m_chartAnotherLegendBox.ViewXY.LegendBox.SeriesTitleFont = new Font(FontFamily.GenericSansSerif, 9.5f, FontStyle.Regular);


            IntensityGridSeries dummy = new IntensityGridSeries(m_chartAnotherLegendBox.ViewXY, m_chartAnotherLegendBox.ViewXY.XAxes[0], m_chartAnotherLegendBox.ViewXY.YAxes[0]);
            dummy.Visible = false;//<--- if set to true slows down rendering even though no data
            dummy.Title.Text = plotdata.colorByAttribute.name;
            dummy.Title.ShowInLegendBox = true;
            dummy.FullInterpolation = true;
            ValueRangePalette colourPalette = CreatePalette(dummy, plotdata.minColorByValue, plotdata.maxColorByValue);
            dummy.ValueRangePalette = colourPalette;
            m_chartAnotherLegendBox.ViewXY.IntensityGridSeries.Add(dummy);
            m_chartAnotherLegendBox.EndUpdate();
Is there a way to get the second plot/legend to show up in the exported image?
Thanks
Greg.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Export Chart with multiple charts?

Post by ArctionPasi » Tue May 13, 2014 6:23 pm

This should work for raster formats:

Code: Select all

Bitmap bm = ChartTools.CaptureControlToBitmap(m_chart);
bm.Save("c:\\temp\\combined.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
But for EMF, I don't know a built-in way to achieve that. You may need to do some System.Drawing-related combining of the images on your side.
LightningChart Support Team, PT

Greg9504
Posts: 38
Joined: Fri Dec 06, 2013 4:51 pm

Re: Export Chart with multiple charts?

Post by Greg9504 » Thu May 15, 2014 1:49 pm

Ran into another problem. When I try to export an emf with "transparent" points. When the chart is imported to Power Point or Word (I've only tried 2010 versions) the points with a black boarder transparent fill are not visible.

Original plot displayed in my app:
copytoclipboardorg.jpg
copytoclipboardorg.jpg (110.53 KiB) Viewed 7608 times
Plot in Power Point:
copytoclipboard_ppt.jpg
copytoclipboard_ppt.jpg (59.88 KiB) Viewed 7608 times
The points were created with following code:

Code: Select all

  marker.Symbol.Color1= Color.Transparent;
  marker.Symbol.GradientFill = GradientFillPoint.Edge;
  marker.Symbol.LinearGradientDirection = Direction.None;
  marker.Symbol.Color2 = Color.Black;
  marker.Symbol.Color3 = Color.Black;
From reading on the web it seems Power point (and Word) may have problems with transparent entries in emf files. Not sure where the problem lies.

Greg.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Export Chart with multiple charts?

Post by ArctionPasi » Thu May 15, 2014 2:41 pm

Hi Greg,

the EMF export uses GDI+. LightningChart UI rendering runs on DirectX engine. The EMF export has only a subset of features available, and it means that only Color1 is applied. If Color1 is transparent, it won't show up. We should improve the rendering of point styles, I know.

For full-detailed export, please consider using PNG, JPG, BMP, or TIFF format.
LightningChart Support Team, PT

Post Reply