Search results

Tooltip

Stock Chart will display details about the points through tooltip, when the mouse is moved over the point.

Default Tooltip

By default, tooltip is not visible. Enable the tooltip by setting enableproperty to true .

razor
tooltip.cs
<script src="~/financial-data.js"></script>

            @(Html.EJS().StockChart("container").Load("stockload").Title("AAPL Stock Price")
                                                                .Series(sr =>
                                                                {
                                                                    sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Candle).DataSource("data").Add();
                                                                }).Tooltip(tp => tp.Enable(true))
                                                                .Render())

    <script>
        var data = window.chartData;
        function stockload(args) {
            args.stockChart.tooltip = { enable: true };

        }
        
    </script>
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();
        }
    }
}

Format the Tooltip

By default, tooltip shows information of x and y value in points. In addition to that, you can show more information in tooltip. For example the format ${series.name} ${point.x} shows series name and point x value.

razor
format.cs
<script src="~/financial-data.js"></script>

            @(Html.EJS().StockChart("container").Load("stockload").Title("AAPL Stock Price")
                                                                .Series(sr =>
                                                                {
                                                                    sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Candle).DataSource("data").Add();
                                                                })
                                   .Tooltip(tp => tp.Enable(true).Header("Unemployment").Format("<b>${point.x} : ${point.y}</b>"))
                                                                .Render())

    <script>
        var data = window.chartData;
    </script>
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();
        }
    }
}

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.

razor
customtooltip.cs
<script src="~/financial-data.js"></script>

            @(Html.EJS().StockChart("container").Load("stockload").Title("AAPL Stock Price")
                                                                .Series(sr =>
                                                                {
                                                                    sr.Type(Syncfusion.EJ2.Charts.ChartSeriesType.Candle).DataSource("data").Add();
                                                                })
                                   .Tooltip(tp => tp.Enable(true).Format("${point.x} : ${point.y}").Fill("#7bb4eb")))
                                                                .Render())

    <script>
        var data = window.chartData;
          function stockload(args) {
             args.stockChart.tooltip = {
                    border: {
                     width: 2,
                     color: 'grey'
                 }

             };
          }
    </script>
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();
        }
    }
}