Tooltip in ASP.NET CORE 3D Chart Component
9 Jan 202414 minutes to read
The 3D Chart will display details about the points through tooltip, when the mouse is moved over the specific point.
Default tooltip
By default, tooltip is not visible. The tooltip can be enabled by setting the Enable
property in TooltipSettings
to true.
<ejs-chart3d id="container" wallColor="transparent" enableRotation="true" rotation="7" tilt="10" depth="100">
<e-chart3d-primaryxaxis valueType="@Syncfusion.EJ2.Charts.ValueType.Category"
labelPlacement="@Syncfusion.EJ2.Charts.LabelPlacement.BetweenTicks" labelRotation="-45">
</e-chart3d-primaryxaxis>
<e-chart3d-series-collection>
<e-chart3d-series dataSource="ViewBag.dataSource" xName="month" yName="sales"
type="@Syncfusion.EJ2.Charts.Chart3DSeriesType.Column"></e-chart3d-series>
</e-chart3d-series-collection>
<e-chart3d-tooltipsettings enable="true">
</e-chart3d-tooltipsettings>
</ejs-chart3d>
public ActionResult Index()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { month= "Jan", sales= 35 },
new ChartData { month= "Feb", sales= 28 },
new ChartData { month= "Mar", sales= 34 },
new ChartData { month= "Apr", sales= 32 },
new ChartData { month= "May", sales= 40 },
new ChartData { month= "Jun", sales= 32 },
new ChartData { month= "Jul", sales= 35 },
new ChartData { month= "Aug", sales= 55 },
new ChartData { month= "Sep", sales= 38 },
new ChartData { month= "Oct", sales= 30 },
new ChartData { month= "Nov", sales= 25 },
new ChartData { month= "Dec", sales= 32 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string month;
public double sales;
}
Fixed tooltip
By default, tooltip track the mouse movement, but the tooltip can be set in fixed position by using the Location
property.
<ejs-chart3d id="container" wallColor="transparent" enableRotation="true" rotation="7" tilt="10" depth="100">
<e-chart3d-primaryxaxis valueType="@Syncfusion.EJ2.Charts.ValueType.Category"
labelPlacement="@Syncfusion.EJ2.Charts.LabelPlacement.BetweenTicks" labelRotation="-45">
</e-chart3d-primaryxaxis>
<e-chart3d-series-collection>
<e-chart3d-series dataSource="ViewBag.dataSource" xName="month" yName="sales"
type="@Syncfusion.EJ2.Charts.Chart3DSeriesType.Column"></e-chart3d-series>
</e-chart3d-series-collection>
<e-chart3d-tooltipsettings enable="true" x="120" y="20">
</e-chart3d-tooltipsettings>
</ejs-chart3d>
public ActionResult Index()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { month= "Jan", sales= 35 },
new ChartData { month= "Feb", sales= 28 },
new ChartData { month= "Mar", sales= 34 },
new ChartData { month= "Apr", sales= 32 },
new ChartData { month= "May", sales= 40 },
new ChartData { month= "Jun", sales= 32 },
new ChartData { month= "Jul", sales= 35 },
new ChartData { month= "Aug", sales= 55 },
new ChartData { month= "Sep", sales= 38 },
new ChartData { month= "Oct", sales= 30 },
new ChartData { month= "Nov", sales= 25 },
new ChartData { month= "Dec", sales= 32 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string month;
public double sales;
}
Format the tooltip
By default, tooltip shows information of x and y value in points. In addition to that, more information can be shown in tooltip by using the Format
property. For example the format ${series.name} : ${point.y}
shows series name and point y value.
<ejs-chart3d id="container" wallColor="transparent" enableRotation="true" rotation="7" tilt="10" depth="100">
<e-chart3d-primaryxaxis valueType="@Syncfusion.EJ2.Charts.ValueType.Category"
labelPlacement="@Syncfusion.EJ2.Charts.LabelPlacement.BetweenTicks" labelRotation="-45">
</e-chart3d-primaryxaxis>
<e-chart3d-series-collection>
<e-chart3d-series dataSource="ViewBag.dataSource" xName="month" yName="sales" name="Month"
type="@Syncfusion.EJ2.Charts.Chart3DSeriesType.Column"></e-chart3d-series>
</e-chart3d-series-collection>
<e-chart3d-tooltipsettings enable="true" header="Unemployment" format="<b>${series.name} : ${point.y}</b>">
</e-chart3d-tooltipsettings>
</ejs-chart3d>
public ActionResult Index()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { month= "Jan", sales= 35 },
new ChartData { month= "Feb", sales= 28 },
new ChartData { month= "Mar", sales= 34 },
new ChartData { month= "Apr", sales= 32 },
new ChartData { month= "May", sales= 40 },
new ChartData { month= "Jun", sales= 32 },
new ChartData { month= "Jul", sales= 35 },
new ChartData { month= "Aug", sales= 55 },
new ChartData { month= "Sep", sales= 38 },
new ChartData { month= "Oct", sales= 30 },
new ChartData { month= "Nov", sales= 25 },
new ChartData { month= "Dec", sales= 32 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string month;
public double sales;
}
Tooltip template
Any HTML elements can be displayed in the tooltip by using the Template
property of the tooltip. The ${x} and ${y} can be used as place holders in the HTML element to display the x and y values of the corresponding data point.
<ejs-chart3d id="container" wallColor="transparent" enableRotation="true" rotation="7" tilt="10" depth="100">
<e-chart3d-primaryxaxis valueType="@Syncfusion.EJ2.Charts.ValueType.Category"
labelPlacement="@Syncfusion.EJ2.Charts.LabelPlacement.BetweenTicks" labelRotation="-45">
</e-chart3d-primaryxaxis>
<e-chart3d-series-collection>
<e-chart3d-series dataSource="ViewBag.dataSource" xName="month" yName="sales"
type="@Syncfusion.EJ2.Charts.Chart3DSeriesType.Column"></e-chart3d-series>
</e-chart3d-series-collection>
<e-chart3d-tooltipsettings enable="true" template="#Unemployment">
</e-chart3d-tooltipsettings>
</ejs-chart3d>
public ActionResult Index()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { month= "Jan", sales= 35 },
new ChartData { month= "Feb", sales= 28 },
new ChartData { month= "Mar", sales= 34 },
new ChartData { month= "Apr", sales= 32 },
new ChartData { month= "May", sales= 40 },
new ChartData { month= "Jun", sales= 32 },
new ChartData { month= "Jul", sales= 35 },
new ChartData { month= "Aug", sales= 55 },
new ChartData { month= "Sep", sales= 38 },
new ChartData { month= "Oct", sales= 30 },
new ChartData { month= "Nov", sales= 25 },
new ChartData { month= "Dec", sales= 32 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string month;
public double sales;
}
Customize the appearance of tooltip
The Fill
and Border
properties are used to customize the background color and border of the tooltip respectively. The TextStyle
property in the tooltip is used to customize the font of the tooltip text.
<ejs-chart3d id="container" wallColor="transparent" enableRotation="true" rotation="7" tilt="10" depth="100">
<e-chart3d-primaryxaxis valueType="@Syncfusion.EJ2.Charts.ValueType.Category"
labelPlacement="@Syncfusion.EJ2.Charts.LabelPlacement.BetweenTicks" labelRotation="-45">
</e-chart3d-primaryxaxis>
<e-chart3d-series-collection>
<e-chart3d-series dataSource="ViewBag.dataSource" xName="month" yName="sales" name="China"
type="@Syncfusion.EJ2.Charts.Chart3DSeriesType.Column"></e-chart3d-series>
</e-chart3d-series-collection>
<e-chart3d-tooltipsettings enable="true" format="${point.x} : ${point.y}" fill="#7bb4eb">
<e-chart3dtooltipsettings-border width="2" color="grey"></e-chart3dtooltipsettings-border>
</e-chart3d-tooltipsettings>
</ejs-chart3d>
public ActionResult Index()
{
List<ChartData> chartData = new List<ChartData>
{
new ChartData { month= "Jan", sales= 35 },
new ChartData { month= "Feb", sales= 28 },
new ChartData { month= "Mar", sales= 34 },
new ChartData { month= "Apr", sales= 32 },
new ChartData { month= "May", sales= 40 },
new ChartData { month= "Jun", sales= 32 },
new ChartData { month= "Jul", sales= 35 },
new ChartData { month= "Aug", sales= 55 },
new ChartData { month= "Sep", sales= 38 },
new ChartData { month= "Oct", sales= 30 },
new ChartData { month= "Nov", sales= 25 },
new ChartData { month= "Dec", sales= 32 }
};
ViewBag.dataSource = chartData;
return View();
}
public class ChartData
{
public string month;
public double sales;
}