Search results

Print and Export in ASP.NET MVC Stock Chart control

30 Jul 2021 / 1 minute to read

The rendered stock chart can be exported to JPEG, PNG, SVG, or PDF format using the export dropdown button in the period selector toolbar. You can choose the required format using the export dropdown button in stock-chart.

The rendered stock chart can be printed directly using print button in period selector toolbar.

razor
print.cs
Copied to clipboard
<script src="~/financial-data.js"></script>

            @(Html.EJS().StockChart("container").Title("AAPL Stock Price")
                    .PrimaryXAxis(xaxis =>xaxis.MajorGridLines(mg=>mg.Color("transparent")))
                    .PrimaryYAxis(yaxis =>yaxis.MajorTickLines(mt=>mt.Color("transparent").Width(0))
                    .LineStyle(ls=>ls.Color("transparent")))
                                                                .Series(sr =>
                                                                {
                                                                    sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Candle).DataSource("data").Add();
                                                                })
                                                                .Render())

    <script>
        var data = window.chartData;
    </script>
Copied to clipboard
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace EJ2CoreSampleBrowser.Controllers.StockChart
{
    public partial class StockChartController : Controller
    {
        public IActionResult Default()
        {
            return View();
        }
    }
}

Disable Export and print

To empty the value of exportType for to disable the Export button.

razor
disable.cs
Copied to clipboard
<script src="~/financial-data.js"></script>

            @Html.EJS().StockChart("container").Title("AAPL Stock Price").ExportType(new List<Object>() { })
                    .PrimaryXAxis(xaxis =>xaxis.MajorGridLines(mg=>mg.Color("transparent")))
                    .PrimaryYAxis(yaxis =>yaxis.MajorTickLines(mt=>mt.Color("transparent").Width(0))
                    .LineStyle(ls=>ls.Color("transparent")))
                                                                .Series(sr =>
                                                                {
                                                                    sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Candle).DataSource("data").Add();
                                                                })
                                                                .Render()

    <script>
        var data = window.chartData;
    </script>
Copied to clipboard
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace EJ2CoreSampleBrowser.Controllers.StockChart
{
    public partial class StockChartController : Controller
    {
        public IActionResult Default()
        {
            return View();
        }
    }
}