ejChart
Namespace: Wisej.Web.Ext.Syncfusion
Assembly: Wisej.Web.Ext.Syncfusion (4.1.0.0)
Essential Chart for JavaScript is a visually stunning Charting component. It includes common Chart types ranging from line Charts to specialized financial Charts.
- C#
- VB.NET
public class ejChart : ejBase
Public Class ejChart
Inherits ejBase
Constructors
ejChart()
Constructs a new instance of the ejChart class.
Example:
The following example creates the chart and defines the title and one series through the options.
var chart = new ejChart();
chart.Options.title = new { text = "Sales" };
chart.Options.series = new[]
{
new { dataSource = sales, xName = "Month", yName = "Total", type = "line" }
};
chart.Dock = DockStyle.Fill;
this.Controls.Add(chart);
ejChart(options)
Constructs a new instance of the ejChart class.
| Name | Type | Description |
|---|---|---|
| options | Object | Initial set of options. |
Example:
The following example creates a column chart with a series of points.
var chart = new ejChart(new
{
title = new { text = "Sales by quarter" },
series = new[]
{
new
{
name = "2025",
type = "column",
points = new[]
{
new { x = "Q1", y = 120 },
new { x = "Q2", y = 150 },
new { x = "Q3", y = 90 },
new { x = "Q4", y = 180 }
}
}
}
});
chart.Dock = DockStyle.Fill;
this.Controls.Add(chart);
Methods
ExportImage(callback)
Exports the chart to an image.
| Parameter | Type | Description |
|---|---|---|
| callback | Action<Image> | Callback method that receives the image, or null when the chart could not be exported. |
The image is created in the browser, which switches the chart to canvas rendering, and is drawn on the server over a background filled with the BackColor of the control. The method returns immediately; the callback is invoked when the client returns the image.
Throws:
- ArgumentNullException
callback is
null.
Example:
this.chart1.ExportImage((image) =>
{
this.pictureBox1.Image = image;
});
ExportImageAsync()
Exports the chart to an image asynchronously.
Returns: Task<Image>. An awaitable Task that returns the image that represents the chart, or null when the chart could not be exported.
The image is created in the browser, which switches the chart to canvas rendering, and is drawn on the server over a background filled with the BackColor of the control.
Example:
private async void buttonExport_Click(object sender, EventArgs e)
{
var image = await this.chart1.ExportImageAsync();
if (image != null)
image.Save(Path.Combine(Path.GetTempPath(), "chart.png"), ImageFormat.Png);
}