Search results

Print and Export in Blazor Accumulation Chart component

Print

The rendered chart can be printed directly from the browser by calling the public method print.

print.razor
@using Syncfusion.Blazor.Charts
<SfAccumulationChart @ref="ChartObj" Title="Mobile Browser Statistics" EnableSmartLabels="true">
    <AccumulationChartLegendSettings Visible="false"></AccumulationChartLegendSettings>

    <AccumulationChartSeriesCollection>
        <AccumulationChartSeries DataSource="@StatisticsDetails" XName="Browser" YName="Users" Name="RIO" GroupTo="10">
            <AccumulationDataLabelSettings Visible="true" Name="Text" Position="AccumulationLabelPosition.Outside">
            </AccumulationDataLabelSettings>
        </AccumulationChartSeries>
    </AccumulationChartSeriesCollection>
</SfAccumulationChart>


<Syncfusion.Blazor.Buttons.SfButton Id="button" Content="Print" @Onclick="@Click" IsPrimary="true" CssClass="e-flat"></Syncfusion.Blazor.Buttons.SfButton>

@code{
    SfAccumulationChart ChartObj;

    private void Click(UIMouseEventArgs args)
    {
        ChartObj.Print();
    }

    public class Statistics
    {
        public string Browser;
        public double Users;
    }

    public List<Statistics> StatisticsDetails = new List<Statistics>
{
        new Statistics { Browser = "Chrome", Users = 37 },
        new Statistics { Browser = "UC Browser", Users = 17 },
        new Statistics { Browser = "iPhone", Users = 19 },
        new Statistics { Browser = "Others", Users = 4  },
        new Statistics { Browser = "Opera", Users = 11 },
        new Statistics { Browser = "Android", Users = 12 },
    };

}

Export

The rendered chart can be exported to Image(jpeg or png) or SVG or PDF format by using the export method. Input parameters for this method are Export Type for format and FileName of result.

export.razor
@using Syncfusion.Blazor.Charts
<SfAccumulationChart @ref="AccChartObj" Title="Mobile Browser Statistics" EnableSmartLabels="true">
    <AccumulationChartLegendSettings Visible="false"></AccumulationChartLegendSettings>

    <AccumulationChartSeriesCollection>
        <AccumulationChartSeries DataSource="@StatisticsDetails" XName="Browser" YName="Users" Name="RIO" GroupTo="10">
            <AccumulationDataLabelSettings Visible="true" Name="Text" Position="AccumulationLabelPosition.Outside">
            </AccumulationDataLabelSettings>
        </AccumulationChartSeries>
    </AccumulationChartSeriesCollection>
</SfAccumulationChart>

<Syncfusion.Blazor.Buttons.SfButton Id="button" Content="Export" @Onclick="@Click" IsPrimary="true" CssClass="e-flat"></Syncfusion.Blazor.Buttons.SfButton>

@code{

    SfAccumulationChart AccChartObj;

    private void Click(UIMouseEventArgs args)
    {
        AccChartObj.Export(ExportType.PNG, "pngImage");
    }

    public class Statistics
    {
        public string Browser;
        public double Users;
    }

    public List<Statistics> StatisticsDetails = new List<Statistics>
{
        new Statistics { Browser = "Chrome", Users = 37 },
        new Statistics { Browser = "UC Browser", Users = 17 },
        new Statistics { Browser = "iPhone", Users = 19 },
        new Statistics { Browser = "Others", Users = 4  },
        new Statistics { Browser = "Opera", Users = 11 },
        new Statistics { Browser = "Android", Users = 12 },
    };

}
Contents
Contents