Selection in ASP.NET MVC 3D Chart Component
9 Jan 202419 minutes to read
The 3D chart provides selection support for the series and its data points on mouse click.
When mouse is clicked on the data points, the corresponding series legend will also be selected.
We have different types of selection mode for selecting a data.
- None
- Point
- Series
- Cluster
Point
To select a point, set the SelectionMode
property to Point.
@(Html.EJS().Chart3D("container").WallColor("transparent").EnableRotation(true).Rotation(7).Tilt(10).Depth(100)
.Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("gold").
Name("Gold").
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("silver").
Name("Silver").
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("bronze").
Name("Bronze").
DataSource(ViewBag.dataSource).
Add();
})
.PrimaryXAxis(px =>
px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
)
.Title("Olympic Medals")
.SelectionMode(Syncfusion.EJ2.Charts.Chart3DSelectionMode.Point)
.Render())
public ActionResult Index()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { country= "USA", gold= 50, silver= 70, bronze= 45 },
new ChartData { country= "China", gold= 40, silver= 60, bronze= 55 },
new ChartData { country= "Japan", gold= 70, silver= 60, bronze= 50 },
new ChartData { country= "Australia", gold= 60, silver= 56, bronze= 40 },
new ChartData { country= "France", gold= 50, silver= 45, bronze= 35 },
new ChartData { country= "Germany", gold= 40, silver= 30, bronze= 22 },
new ChartData { country= "Italy", gold= 40, silver= 35, bronze= 37 },
new ChartData { country= "Sweden", gold= 30, silver= 25, bronze= 27 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string country;
public double gold;
public double silver;
public double bronze;
}
Series
To select a series, set the SelectionMode
property to Series.
@(Html.EJS().Chart3D("container").WallColor("transparent").EnableRotation(true).Rotation(7).Tilt(10).Depth(100)
.Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("gold").
Name("Gold").
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("silver").
Name("Silver").
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("bronze").
Name("Bronze").
DataSource(ViewBag.dataSource).
Add();
})
.PrimaryXAxis(px =>
px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
)
.Title("Olympic Medals")
.SelectionMode(Syncfusion.EJ2.Charts.Chart3DSelectionMode.Series)
.Render())
public ActionResult Index()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { country= "USA", gold= 50, silver= 70, bronze= 45 },
new ChartData { country= "China", gold= 40, silver= 60, bronze= 55 },
new ChartData { country= "Japan", gold= 70, silver= 60, bronze= 50 },
new ChartData { country= "Australia", gold= 60, silver= 56, bronze= 40 },
new ChartData { country= "France", gold= 50, silver= 45, bronze= 35 },
new ChartData { country= "Germany", gold= 40, silver= 30, bronze= 22 },
new ChartData { country= "Italy", gold= 40, silver= 35, bronze= 37 },
new ChartData { country= "Sweden", gold= 30, silver= 25, bronze= 27 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string country;
public double gold;
public double silver;
public double bronze;
}
Cluster
To select the points that corresponds to the same index in all the series, set the SelectionMode
property to Cluster.
@(Html.EJS().Chart3D("container").WallColor("transparent").EnableRotation(true).Rotation(7).Tilt(10).Depth(100)
.Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("gold").
Name("Gold").
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("silver").
Name("Silver").
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("bronze").
Name("Bronze").
DataSource(ViewBag.dataSource).
Add();
})
.PrimaryXAxis(px =>
px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
)
.Title("Olympic Medals")
.SelectionMode(Syncfusion.EJ2.Charts.Chart3DSelectionMode.Cluster)
.Render())
public ActionResult Index()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { country= "USA", gold= 50, silver= 70, bronze= 45 },
new ChartData { country= "China", gold= 40, silver= 60, bronze= 55 },
new ChartData { country= "Japan", gold= 70, silver= 60, bronze= 50 },
new ChartData { country= "Australia", gold= 60, silver= 56, bronze= 40 },
new ChartData { country= "France", gold= 50, silver= 45, bronze= 35 },
new ChartData { country= "Germany", gold= 40, silver= 30, bronze= 22 },
new ChartData { country= "Italy", gold= 40, silver= 35, bronze= 37 },
new ChartData { country= "Sweden", gold= 30, silver= 25, bronze= 27 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string country;
public double gold;
public double silver;
public double bronze;
}
Selection type
To select multiple points or series, enable the IsMultiSelect
property.
@(Html.EJS().Chart3D("container").WallColor("transparent").EnableRotation(true).Rotation(7).Tilt(10).Depth(100)
.Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("gold").
Name("Gold").
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("silver").
Name("Silver").
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("bronze").
Name("Bronze").
DataSource(ViewBag.dataSource).
Add();
})
.PrimaryXAxis(px =>
px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
)
.Title("Olympic Medals")
.SelectionMode(Syncfusion.EJ2.Charts.Chart3DSelectionMode.Series)
.IsMultiSelect(true)
.Render())
public ActionResult Index()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { country= "USA", gold= 50, silver= 70, bronze= 45 },
new ChartData { country= "China", gold= 40, silver= 60, bronze= 55 },
new ChartData { country= "Japan", gold= 70, silver= 60, bronze= 50 },
new ChartData { country= "Australia", gold= 60, silver= 56, bronze= 40 },
new ChartData { country= "France", gold= 50, silver= 45, bronze= 35 },
new ChartData { country= "Germany", gold= 40, silver= 30, bronze= 22 },
new ChartData { country= "Italy", gold= 40, silver= 35, bronze= 37 },
new ChartData { country= "Sweden", gold= 30, silver= 25, bronze= 27 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string country;
public double gold;
public double silver;
public double bronze;
}
Selection during initial loading
In a 3D chart, selecting a point or series during initial loading can only be done programmatically. The SelectedDataIndexes
property can be used for this.
@(Html.EJS().Chart3D("container").WallColor("transparent").EnableRotation(true).Rotation(7).Tilt(10).Depth(100)
.Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("gold").
Name("Gold").
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("silver").
Name("Silver").
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("bronze").
Name("Bronze").
DataSource(ViewBag.dataSource).
Add();
})
.PrimaryXAxis(px =>
px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
)
.Title("Olympic Medals")
.SelectionMode(Syncfusion.EJ2.Charts.Chart3DSelectionMode.Point)
.IsMultiSelect(true)
.SelectedDataIndexes(ViewBag.selectedData)
.Render())
public ActionResult Index()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { country= "USA", gold= 50, silver= 70, bronze= 45 },
new ChartData { country= "China", gold= 40, silver= 60, bronze= 55 },
new ChartData { country= "Japan", gold= 70, silver= 60, bronze= 50 },
new ChartData { country= "Australia", gold= 60, silver= 56, bronze= 40 },
new ChartData { country= "France", gold= 50, silver= 45, bronze= 35 },
new ChartData { country= "Germany", gold= 40, silver= 30, bronze= 22 },
new ChartData { country= "Italy", gold= 40, silver= 35, bronze= 37 },
new ChartData { country= "Sweden", gold= 30, silver= 25, bronze= 27 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string country;
public double gold;
public double silver;
public double bronze;
}
Selection through legend
To select a point or series through on legend use ToggleVisibility
property. Also, use EnableHighlight
property for highlighting the series through legend.
@(Html.EJS().Chart3D("container").WallColor("transparent").EnableRotation(true).Rotation(7).Tilt(10).Depth(100)
.Series(series =>
{
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("gold").
Name("Gold").
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("silver").
Name("Silver").
DataSource(ViewBag.dataSource).
Add();
series.Type(Syncfusion.EJ2.Charts.Chart3DSeriesType.Column).
XName("country").
YName("bronze").
Name("Bronze").
DataSource(ViewBag.dataSource).
Add();
})
.PrimaryXAxis(px =>
px.ValueType(Syncfusion.EJ2.Charts.ValueType.Category)
)
.Title("Olympic Medals")
.LegendSettings(lg => lg.Visible(true).ToggleVisibility(false).EnableHighlight(true))
.Render())
public ActionResult Index()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { country= "USA", gold= 50, silver= 70, bronze= 45 },
new ChartData { country= "China", gold= 40, silver= 60, bronze= 55 },
new ChartData { country= "Japan", gold= 70, silver= 60, bronze= 50 },
new ChartData { country= "Australia", gold= 60, silver= 56, bronze= 40 },
new ChartData { country= "France", gold= 50, silver= 45, bronze= 35 },
new ChartData { country= "Germany", gold= 40, silver= 30, bronze= 22 },
new ChartData { country= "Italy", gold= 40, silver= 35, bronze= 37 },
new ChartData { country= "Sweden", gold= 30, silver= 25, bronze= 27 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string country;
public double gold;
public double silver;
public double bronze;
}