Pre loader

Tag: ExportToFile

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0 votes
11k views

I’m implementing exporting charts. As part of my export, the user can specify the size of the chart. I’ve managed to get sciChartSurface.ExportToBitmapSource() working fine for single graphs.

However, I’ve got some quite complex layouts, and when I try to render parent controls that contain Scichart controls manually, with say:

ExportUIElement.Measure(size);
ExportUIElement.Arrange(new Rect(size));

 int dpiScaling = 3;
RenderTargetBitmap bmp = new RenderTargetBitmap(Width * dpiScaling, Height * dpiScaling,
                                                                                                           96 * dpiScaling, 96 * dpiScaling,
                                                                                                           PixelFormats.Pbgra32);

I’m finding everything working, the chart layout & axis/labels update and render fine, but the chart content is not re-rendered to the new size, causing some messy/strange visual effects. This one was arranged to a larger size, you can see that the actual chart content is now sitting snugly in the middle of a large margin:

enter image description here

Can I force Scichart to re-render these so I can manually render the component in a different size?

  • Ken Hobbs asked 7 years ago
  • last active 5 years ago
1 vote
11k views

I would like to call ThemeManager.SetTheme to change the theme, export an image to file, and then restore the original theme. How can I ensure that the new theme has been applied before calling ExportToFile?

is there a better way to capture a screenshot of a plot using a different theme?

Bill

1 vote
10k views

Dear all,

In our application we have a chart that we need to explot into a BMP file at a given size.
For our scenario the process is as below :

1 – From the chart which is display to user at a default size we force the Width and Height of the chart to our desired size

mysciChart.Width = 480;
mysciChart.Height = 220;
mysciChart.UpdateLayout();

2 – We can then use the build in Export To file method to export the file

if (mysciChart.ActualWidth > 10 && mysciChart.ActualHeight > 10)
{
    mysciChart.ExportToFile(myBMPFile, ExportType.Bmp, false);
    }

The chart is then exported to correct size but it is not refresh with data as shown in picture attached

please note that the code above is executed in the Main UI thread dispatcher

Any idea how to get the chart properly render in Export, is there a kind of refresh something to call on the chart before export when we change its size ?

Thnaks for help

  • sc sc asked 6 years ago
  • last active 6 years ago
0 votes
0 answers
10k views

Microsoft has announced that it plans to retire the XPS file format and remove the XPS viewer in future Windows installations. I presume this mean the “Export to XPS” feature will not be useful for much longer. Given this news, does SciChart have plans to support a different vector format like SVG instead?

0 votes
0 answers
9k views

hi,
I am using ExpressionDark theme for my scichart surface.
I want to do ExportToFile after changing theme to BrightSpark.
When I do exporttofile after change the theme to BrightSpark, my exported image is still in ExpressionDark.

I do it like below.

ThemeManager.SetTheme(Chart, “BrightSpark”);
var tempFileName = Path.GetTempFileName();
Chart.ExportToFile(tempFileName, ExportType.Png);
var i = Image.FromFile(tempFileName);

Can some one help please?

0 votes
9k views

Dear SciChart people,

when trying to export a SciChartSurface instance present in a view (i.e. modified by zoom and series visibility settings etc. done by the user in the UI), it seems that its member functions
ExportToFile
may only be called from the UI thread – invocations from a background thread yield an InvalidOperation exception

So for the period of exporting, the application stays unresponsive even when “useXamlRenderSurface=false” is set in the call.

This does not change when trying to clone the surface, using a derived SciChartSurface class (still in in the view) that allows for cloning (cf . the SciChartEx class in the “CreateAnnotationsDynamically” SciChart example): calling CreateCloneSurfaceInMemory is still only allowed on the UI thread.
If one accepts this, but tries to continue with a background thread on the cloned surface’ s ExportToFile instance, it still mandates using the UI thread, so no escape …

Any ideas to go away from the UI thread in this scenario?

Thanks a lot.

0 votes
7k views

hello

I have two questions,

First , when I using :

   sciChart.ExportToFile(SaveFileName, Core.ExportType.Jpeg, false,savingImageSize);  

In ContoursView ,this function works well, however in UniformMesh3DChart and SurfaceMeshContours it dosent work.
Only these parameters can be used:

    sciChart.ExportToFile(SaveFileName, Core.ExportType.Jpeg, false);  

as these parameters they dont work either:

    sciChart.ExportToFile(SaveFileName, Core.ExportType.Jpeg, true);  

Second, As “ExporToFile()” function, Can I export to file with ColorMap in UniformMesh3DChart and SurfaceMeshContours ?

0 votes
7k views

Hello,

I am trying to export my 3D chart to a file using SciChart3DSurface.ExportToFile. However, I am getting this error:

InvalidOperationException: There was an error reflecting property ‘InputBindings’.

Code behind:

var surface = ResultTestContent.Positional6DOFErrorTestPage.PositionalChart;
surface.ExportToFile($@"C:\temp\ChartTest.jpeg", SciChart.Core.ExportType.Jpeg, true,new Size(800,800));

XAML:

<s3D:SciChart3DSurface x:Name="PositionalChart" Grid.Column="1" ShowLicensingWarnings="True"
                    IsFpsCounterVisible="False"
                     IsAxisCubeVisible="True"
                     IsXyzGizmoVisible="False"
                     CoordinateSystem="RightHanded"
                           Background="White"
                           DebugWhyDoesntSciChartRender="True" RenderableSeries="{extensions:SeriesBinding RenderSeries3DViewModels}"
                           Visibility="Collapsed">

        <!-- Create XAxis -->
        <s3D:SciChart3DSurface.XAxis>
            <s3D:NumericAxis3D TickTextBrush="Black" AxisTitle="X (mm)" DrawMajorBands="True" DrawMajorGridLines="True"
                    DrawMinorGridLines="False"
                    DrawMajorTicks="True"
                    DrawMinorTicks="True"
                               MajorGridLineStyle="{StaticResource ResourceKey=MajorGridLineStyle}"
                               MinorGridLineStyle="{StaticResource ResourceKey=MinorGridLineStyle}"
                    AxisBandsFill="LightCyan"
                    FontSize="10"
                    TickLabelAlignment="Camera"
                               GrowBy="0.1, 0.1"/>
        </s3D:SciChart3DSurface.XAxis>
        <!-- Create YAxis -->
        <s3D:SciChart3DSurface.YAxis>
            <s3D:NumericAxis3D AxisTitle="Z (mm)" MajorGridLineStyle="{StaticResource ResourceKey=MajorGridLineStyle}"
                               MinorGridLineStyle="{StaticResource ResourceKey=MinorGridLineStyle}"
                               DrawMinorGridLines="False"
                    AxisBandsFill="LightCyan"
                    TickTextBrush="Black"
                    FontSize="10"
                    TickLabelAlignment="Camera"
                               GrowBy="0.1, 0.1"/>
        </s3D:SciChart3DSurface.YAxis>
        <!-- Create ZAxis -->
        <s3D:SciChart3DSurface.ZAxis>
            <s3D:NumericAxis3D AxisTitle="Y (mm)" MajorGridLineStyle="{StaticResource ResourceKey=MajorGridLineStyle}"
                               MinorGridLineStyle="{StaticResource ResourceKey=MinorGridLineStyle}"
                               DrawMinorGridLines="False"
                    AxisBandsFill="LightCyan"
                    TickTextBrush="Black"
                    FontSize="10"
                    TickLabelAlignment="Camera"
                               GrowBy="0.1, 0.1"/>
        </s3D:SciChart3DSurface.ZAxis>

        <!-- Create Interactivity Modifiers for rotating camera -->
        <s3D:SciChart3DSurface.ChartModifier>
            <s3D:ModifierGroup3D>
                <s3D:OrbitModifier3D ExecuteOn="MouseLeftButton" ExecuteWhen="None"/>
                <s3D:MouseWheelZoomModifier3D MouseWheelSensitivity="90" />
                <s3D:FreeLookModifier3D ExecuteOn="MouseRightButton"/>
                <s3D:TooltipModifier3D IsEnabled="True" SourceMode="AllSeries" ShowTooltipOn="MouseOver"/>
            </s3D:ModifierGroup3D>
        </s3D:SciChart3DSurface.ChartModifier>
    </s3D:SciChart3DSurface>

I’ve removed the binding from the xaml, yet I am still getting the same issue. Any help is appreciated, thanks.

0 votes
6k views

Such as title

  • Josk Zhou asked 2 years ago
  • last active 1 year ago
1 vote
5k views

I need to export a load of images from one graph. Export from the View is very long. So, I’ve implemented the export in memory like in this example:
https://support.scichart.com/index.php?/Knowledgebase/Article/View/17213/34/rendering-chart-to-bitmap-in-memory

Export is fast and flexible. One of my axes has a custom label provider, but I see a default axis labels after export. Export from View gives correct label values. Here is the code of the label provider:

public class MyCustomLabelProvider: NumericLabelProvider
{

    public override string FormatLabel(IComparable dataValue)
    {
        return string.Format("{0:" + this.ParentAxis.TextFormatting + "}", 1 / (double)dataValue);
    }

    public override string FormatCursorLabel(IComparable dataValue)
    {
        return string.Format("{0:" + this.ParentAxis.TextFormatting + "}", 1 / (double)dataValue);
    }
}

And a code of export:

    var sciChartSurface = new SciChartSurface();
    ThemeManager.SetTheme(sciChartSurface, "BrightSpark");
    sciChartSurface.YAxes = new AxisCollection()
    {
        new NumericAxis()
        {
            AxisAlignment = AxisAlignment.Left,
            VisibleRangeLimitMode = RangeClipMode.MinMax,
            LabelProvider = new MyCustomLabelProvider(),
            DrawMajorGridLines = false,
            DrawMinorGridLines = false,
            DrawMajorBands = false,
        }
    };
    sciChartSurface.XAxes = new AxisCollection()
    {
        new NumericAxis()
        {
            AxisAlignment = AxisAlignment.Bottom,
            LabelProvider = new CurvatureLabelProvider(),
            VisibleRangeLimitMode = RangeClipMode.MinMax,
            DrawMajorGridLines = false,
            DrawMinorGridLines = false,
            DrawMajorBands = false
        }
    };

    sciChartSurface.RenderableSeries = new ObservableCollection<IRenderableSeries>()
    {
        new FastLineRenderableSeries() { DataSeries = lineSeries, Stroke = Colors.Green }
    };

    ...

    sciChartSurface.XAxes.FirstOrDefault().VisibleRange = new DoubleRange(0, 100);
    sciChartSurface.ExportToFile(Path.Combine(folderPath, $"Object.png"), ExportType.Png, false, new Size(1500, 750));

Any suggestions?

0 votes
5k views

Hello,

This question is related to this discussion :
https://www.scichart.com/questions/wpf/export-chart-with-heatmapcolormap

I want to export a chart as XPS and have the HeatmapColorMap on the XPS. I put the HeatmapColorMap inside a CustomAnnotation. I had an issue with the ticks and labels not appearing on the printed XPS so I was advised to use a workaround :

public class SciChartSurfaceEx : SciChartSurface
{
    protected override SciChartSurfaceBase CreateCloneOfSurfaceInMemory(Size newSize)
    {
        // Grab custom annotation that stores HeatmapColormap on a real chart
        var originalColormapAnnotation = (CustomAnnotation)this.Annotations.Where(x => x.GetType() == typeof(CustomAnnotation)).FirstOrDefault();
        var originalColorMap = originalColormapAnnotation.Content as HeatmapColorMap;

        // Perform exporting functionality(serializing\deserializing)
        var cloned = (SciChartSurface)base.CreateCloneOfSurfaceInMemory(newSize);

        var newWindow = new Window();
        newWindow.Content = cloned;
        newWindow.Show();
        newWindow.Close();

        return cloned;
    }
}

Opening a new window is a workaround to prevent the HeatmapColorMap from disappearing after exporting, because it disappears otherwise.
This works fine when exporting a PNG at non-default size but it does not work when exporting as XPS. I get the following exception :

System.InvalidOperationException: ‘Specified element is already the logical child of another element. Disconnect it first.’

Why do I have this exception ? Is there any way around it ?
There are quite a few bugs when exporting charts, it would be nice to have them fixed.

Thank you in advance !

Showing 11 results

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies