Chart / Import and Export / Export / Saving and Loading Charts
In This Topic
    Saving and Loading Charts
    In This Topic

    NOV Chart for .NET support serialization of its state to a stream or file. Saving and loading the chart state is done by calling one of the Save... or Load... method overloads of the NChartView class. The following sections discuss the different serialization options.

     Save to File or Stream Directly

    To save synchronously to a Nevron Binary Chart local file call the SaveToLocalFile method of the chart view. This method doesn't work on sandboxed platforms like Blazor WebAssembly.

    Save to a Nevron Binary Chart file synchronously
    Copy Code
    chartView.SaveToLocalFile(@"D:\Documents\MyChart.ncb");
    

    To save a chart to a file asynchronously call the SaveToFileAsync method of the chart view. Calling this method shows a loader over the chart view until the saving completes. The method returns a promise, which you can use to get notified when the saving completes.

    Save to a Nevron Binary Chart file asynchronously
    Copy Code
    chartView.SaveToFileAsync(@"D:\Documents\MyChart.ncb").Then(
        delegate (bool success)
        {
        },
        delegate (Exception ex)
        {
        }
    );
    

    To save a chart to a stream you need to call the SaveToStream method of the chart view and pass the chart format to save to:

    Save to Nevron Binary Chart stream
    Copy Code
    chartView.SaveToStream(stream, NChartFormat.NevronBinary);
    
     Show a Save File Dialog

    To show the standard Save File dialog, use the SaveAsAsync method:

    Save File dialog
    Copy Code
    chartView.SaveAsAsync();
    

    If you want a specific format to be selected by default, then you need to pass it as an argument:

    Save File dialog with a specific file format selected
    Copy Code
    chartView.SaveAsAsync(NChartFormat.NevronBinary);
    
     Load from File or Stream Directly

    To load the state of NOV Chart for .NET synchronously from a local file you need to call the LoadFromLocalFile method of the chart view.

    This method doesn't work on sandboxed platforms like Blazor WebAssembly.
    Load a Nevron Binary Chart file synchronously
    Copy Code
    chartView.LoadFromLocalFile(@"D:\Documents\MyChart.ndb");
    

    To load a Nevron Chart asynchronously call the LoadFromFileAsync method of the chart view. Calling this method shows a loader over the chart view until the loading completes. The method returns a promise, which can be used to get notified when the loading completes.

    Load a Nevron Binary Chart file asynchronously
    Copy Code
    chartView.LoadFromFileAsync(@"D:\Documents\MyChart.ncb").Then(
        delegate (bool success)
        {
        },
        delegate (Exception ex)
        {
        }
    );
    

    To load a chart from a stream call the LoadFromStream method of the chart view and pass the chart format to load:

    Load from Nevron Binary Chart stream
    Copy Code
    chartView.LoadFromStream(stream, NChartFormat.NevronBinary);
    
     Show an Open File Dialog

    The OpenFileAsync method shows an Open File dialog with all supported chart formats:

    Open File dialog
    Copy Code
    chartView.OpenFileAsync();
    

    If you want a specific format to be selected by default, pass it as an argument:

    Open File dialog with a specific file format selected
    Copy Code
    chartView.OpenFileAsync(NChartFormat.NevronBinary);