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 .

tagHelper
tooltip.cs
<ejs-stockchart id="stockchart" load="stockload" title="AAPL Stock Price">
                <e-stockchart-series-collection>
                    <e-stockchart-series type='Candle' xName="x"> </e-stockchart-series>
                </e-stockchart-series-collection>
                <e-stockchart-tooltipsettings enable="true"></e-stockchart-tooltipsettings>
            </ejs-stockchart>

    <script src="~/financial-data.js"></script>
    <script>
        var data = chartData;
            function stockload(args) {
                args.stockChart.series[0].dataSource = data;
            }
    </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.

tagHelper
format.cs
<ejs-stockchart id="stockchart" load="stockload" title="AAPL Stock Price">
                <e-stockchart-series-collection>
                    <e-stockchart-series type='Candle' xName="x"> </e-stockchart-series>
                </e-stockchart-series-collection>
             <e-stockchart-tooltipsettings enable="true" header="Unemployment" format="<b>${point.x} : ${point.y}</b>"></e-stockchart-tooltipsettings>
            </ejs-stockchart>
        </div>

    <script src="~/scripts/chart/financial-data.js"></script>
    <script>
        var data = chartData;
            function stockload(args) {
                args.stockChart.series[0].dataSource = data;
            }
    </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.

tagHelper
customtooltip.cs
<ejs-stockchart id="stockchart" load="stockload" title="AAPL Stock Price">
                <e-stockchart-series-collection>
                    <e-stockchart-series type='Candle' xName="x"> </e-stockchart-series>
                </e-stockchart-series-collection>
                <e-stockchart-tooltipsettings enable="true" format="${point.x} : ${point.y}" fill="#7bb4eb"> 
                </e-stockchart-tooltipsettings>
            </ejs-stockchart>

    <script src="~/scripts/chart/financial-data.js"></script>
    <script>
        var data = chartData;
        function stockload(args) {
            args.stockChart.series[0].dataSource = data;
            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();
        }
    }
}