Hilo in ASP.NET Core Charts Component

8 Oct 202424 minutes to read

To get started with the ASP.NET Core Hilo charts, you can check on this video:

Hilo

To render a hilo series in your chart, you need to follow a few steps to configure it correctly. Here’s a concise guide on how to do this:

  • Set the series type: Define the series type as Hilo in your chart configuration. This indicates that the data should be represented as a hilo chart, which shows the high and low values for each data point, illustrating price movements in stocks and providing a clear visualization of price ranges.

  • Provide high and low values: The Hilo series requires two y-values for each data point, you need to specify both the high and low values. The high value represents the maximum price, while the low value represents the minimum price of the stock.

<ejs-chart id="container" width="60%">
  <e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
  <e-series-collection>
    <e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
      type="@Syncfusion.EJ2.Charts.ChartSeriesType.Hilo">
    </e-series>
  </e-series-collection>
</ejs-chart>
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
                new Data{ x= "Jan", low= 87, high= 200 },
                new Data{ x= "Feb", low= 45, high= 135 },
                new Data{ x= "Mar", low= 19, high= 85 }, 
                new Data{ x= "Apr", low= 31, high= 108 },
                new Data{ x= "May", low= 27, high= 80 },
                new Data{ x= "June",low= 84, high= 130 },
                new Data{ x= "Jul", low= 77, high=150 }, 
                new Data{ x= "Aug", low= 54, high= 125 },
                new Data{ x= "Sep", low= 60, high= 155 },
                new Data{ x= "Oct", low= 60, high= 180 },
                new Data{ x= "Nov", low= 88, high= 180 },
                new Data{ x= "Dec", low= 84, high= 230 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public double high;
            public double low;
        }

Binding data with series

You can bind data to the chart using the dataSource property within the series configuration. This allows you to connect a JSON dataset or remote data to your chart. To display the data correctly, map the fields from the data to the chart series xName, high, and low properties.

<ejs-chart id="container" width="60%">
  <e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
  <e-series-collection>
    <e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
      type="@Syncfusion.EJ2.Charts.ChartSeriesType.Hilo">
    </e-series>
  </e-series-collection>
</ejs-chart>
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
                new Data{ x= "Jan", low= 87, high= 200 },
                new Data{ x= "Feb", low= 45, high= 135 },
                new Data{ x= "Mar", low= 19, high= 85 }, 
                new Data{ x= "Apr", low= 31, high= 108 },
                new Data{ x= "May", low= 27, high= 80 },
                new Data{ x= "June",low= 84, high= 130 },
                new Data{ x= "Jul", low= 77, high=150 }, 
                new Data{ x= "Aug", low= 54, high= 125 },
                new Data{ x= "Sep", low= 60, high= 155 },
                new Data{ x= "Oct", low= 60, high= 180 },
                new Data{ x= "Nov", low= 88, high= 180 },
                new Data{ x= "Dec", low= 84, high= 230 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public double high;
            public double low;
        }

Series customization

The following properties can be used to customize the hilo series.

Fill

The fill property determines the color applied to the series.

<ejs-chart id="container" width="60%">
  <e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
  <e-series-collection>
    <e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
      type="@Syncfusion.EJ2.Charts.ChartSeriesType.Hilo" fill="blue">
    </e-series>
  </e-series-collection>
</ejs-chart>
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
                new Data{ x= "Jan", low= 87, high= 200 },
                new Data{ x= "Feb", low= 45, high= 135 },
                new Data{ x= "Mar", low= 19, high= 85 }, 
                new Data{ x= "Apr", low= 31, high= 108 },
                new Data{ x= "May", low= 27, high= 80 },
                new Data{ x= "June",low= 84, high= 130 },
                new Data{ x= "Jul", low= 77, high=150 }, 
                new Data{ x= "Aug", low= 54, high= 125 },
                new Data{ x= "Sep", low= 60, high= 155 },
                new Data{ x= "Oct", low= 60, high= 180 },
                new Data{ x= "Nov", low= 88, high= 180 },
                new Data{ x= "Dec", low= 84, high= 230 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public double high;
            public double low;
        }

The fill property can be used to apply a gradient color to the hilo series. By configuring this property with gradient values, you can create a visually appealing effect in which the color transitions smoothly from one shade to another.

<svg style="width:1px; height:1px">
  <defs>
      <linearGradient id="gradient">
          <stop offset="0%" style="stop-color:blue;stop-opacity:5" />
          <stop offset="50%" style="stop-color:violet;stop-opacity:5" />
      </linearGradient>
  </defs>
</svg>

<ejs-chart id="container" width="60%">
  <e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
  <e-series-collection>
    <e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
      type="@Syncfusion.EJ2.Charts.ChartSeriesType.Hilo" fill="url(#gradient)">
    </e-series>
  </e-series-collection>
</ejs-chart>
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
                new Data{ x= "Jan", low= 87, high= 200 },
                new Data{ x= "Feb", low= 45, high= 135 },
                new Data{ x= "Mar", low= 19, high= 85 }, 
                new Data{ x= "Apr", low= 31, high= 108 },
                new Data{ x= "May", low= 27, high= 80 },
                new Data{ x= "June",low= 84, high= 130 },
                new Data{ x= "Jul", low= 77, high=150 }, 
                new Data{ x= "Aug", low= 54, high= 125 },
                new Data{ x= "Sep", low= 60, high= 155 },
                new Data{ x= "Oct", low= 60, high= 180 },
                new Data{ x= "Nov", low= 88, high= 180 },
                new Data{ x= "Dec", low= 84, high= 230 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public double high;
            public double low;
        }

Opacity

The opacity property specifies the transparency level of the fill. Adjusting this property allows you to control how opaque or transparent the fill color of the series appears.

<ejs-chart id="container" width="60%">
  <e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
  <e-series-collection>
    <e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
      type="@Syncfusion.EJ2.Charts.ChartSeriesType.Hilo" opacity="0.5">
    </e-series>
  </e-series-collection>
</ejs-chart>
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
                new Data{ x= "Jan", low= 87, high= 200 },
                new Data{ x= "Feb", low= 45, high= 135 },
                new Data{ x= "Mar", low= 19, high= 85 }, 
                new Data{ x= "Apr", low= 31, high= 108 },
                new Data{ x= "May", low= 27, high= 80 },
                new Data{ x= "June",low= 84, high= 130 },
                new Data{ x= "Jul", low= 77, high=150 }, 
                new Data{ x= "Aug", low= 54, high= 125 },
                new Data{ x= "Sep", low= 60, high= 155 },
                new Data{ x= "Oct", low= 60, high= 180 },
                new Data{ x= "Nov", low= 88, high= 180 },
                new Data{ x= "Dec", low= 84, high= 230 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public double high;
            public double low;
        }

Empty points

Data points with null or undefined values are considered empty. Empty data points are ignored and not plotted on the chart.

Mode

Use the mode property to define how empty or missing data points are handled in the series. The default mode for empty points is Gap.

<ejs-chart id="container" width="60%">
  <e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
  <e-series-collection>
    <e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
      type="@Syncfusion.EJ2.Charts.ChartSeriesType.Hilo">
      <e-series-emptypointSettings mode="Average"></e-series-emptypointSettings>
    </e-series>
  </e-series-collection>
</ejs-chart>
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
                new Data{ x= "Jan", low= 87, high= 200 },
                new Data{ x= "Feb", low= 45, high= 135 },
                new Data{ x= "Mar", low= 19, high= 85 }, 
                new Data{ x= "Apr", low= null, high= 108 },
                new Data{ x= "May", low= 27, high= 80 },
                new Data{ x= "June",low= 84, high= 130 },
                new Data{ x= "Jul", low= 77, high=150 }, 
                new Data{ x= "Aug", low= null, high= 125 },
                new Data{ x= "Sep", low= 60, high= 155 },
                new Data{ x= "Oct", low= 60, high= 180 },
                new Data{ x= "Nov", low= 88, high= 180 },
                new Data{ x= "Dec", low= 84, high= 230 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public double high;
            public double low;
        }

Fill

Use the fill property to customize the fill color of empty points in the series.

<ejs-chart id="container" width="60%">
  <e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
  <e-series-collection>
    <e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
      type="@Syncfusion.EJ2.Charts.ChartSeriesType.Hilo">
      <e-series-emptypointSettings mode="Average" fill="red"></e-series-emptypointSettings>
    </e-series>
  </e-series-collection>
</ejs-chart>
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
                new Data{ x= "Jan", low= 87, high= 200 },
                new Data{ x= "Feb", low= 45, high= 135 },
                new Data{ x= "Mar", low= 19, high= 85 }, 
                new Data{ x= "Apr", low= null, high= 108 },
                new Data{ x= "May", low= 27, high= 80 },
                new Data{ x= "June",low= 84, high= 130 },
                new Data{ x= "Jul", low= 77, high=150 }, 
                new Data{ x= "Aug", low= null, high= 125 },
                new Data{ x= "Sep", low= 60, high= 155 },
                new Data{ x= "Oct", low= 60, high= 180 },
                new Data{ x= "Nov", low= 88, high= 180 },
                new Data{ x= "Dec", low= 84, high= 230 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public double high;
            public double low;
        }

Events

Series render

The seriesRender event allows you to customize series properties, such as data, fill, and name, before they are rendered on the chart.

<ejs-chart id="container" width="60%" seriesRender="changeColor">
  <e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
  <e-series-collection>
    <e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
      type="@Syncfusion.EJ2.Charts.ChartSeriesType.Hilo">
    </e-series>
  </e-series-collection>
</ejs-chart>

<script>
  function changeColor(args) {
      args.fill = '#ff6347';
  }
</script>
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
                new Data{ x= "Jan", low= 87, high= 200 },
                new Data{ x= "Feb", low= 45, high= 135 },
                new Data{ x= "Mar", low= 19, high= 85 }, 
                new Data{ x= "Apr", low= 31, high= 108 },
                new Data{ x= "May", low= 27, high= 80 },
                new Data{ x= "June",low= 84, high= 130 },
                new Data{ x= "Jul", low= 77, high=150 }, 
                new Data{ x= "Aug", low= 54, high= 125 },
                new Data{ x= "Sep", low= 60, high= 155 },
                new Data{ x= "Oct", low= 60, high= 180 },
                new Data{ x= "Nov", low= 88, high= 180 },
                new Data{ x= "Dec", low= 84, high= 230 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public double high;
            public double low;
        }

Point render

The pointRender event allows you to customize each data point before it is rendered on the chart.

<ejs-chart id="container" width="60%" pointRender="changeColor">
  <e-chart-primaryxaxis valueType="Category"></e-chart-primaryxaxis>
  <e-series-collection>
    <e-series dataSource="ViewBag.dataSource" xName="x" high="high" low="low"
      type="@Syncfusion.EJ2.Charts.ChartSeriesType.Hilo">
    </e-series>
  </e-series-collection>
</ejs-chart>

<script>
  function changeColor(args) {
    if (args.point.index % 2 !== 0) {
      args.fill = '#ff6347';
    }
    else {
      args.fill = '#009cb8';
    }
  }
</script>
public ActionResult Index()
        {
            List<Data> chartData = new List<Data>
            {
                new Data{ x= "Jan", low= 87, high= 200 },
                new Data{ x= "Feb", low= 45, high= 135 },
                new Data{ x= "Mar", low= 19, high= 85 }, 
                new Data{ x= "Apr", low= 31, high= 108 },
                new Data{ x= "May", low= 27, high= 80 },
                new Data{ x= "June",low= 84, high= 130 },
                new Data{ x= "Jul", low= 77, high=150 }, 
                new Data{ x= "Aug", low= 54, high= 125 },
                new Data{ x= "Sep", low= 60, high= 155 },
                new Data{ x= "Oct", low= 60, high= 180 },
                new Data{ x= "Nov", low= 88, high= 180 },
                new Data{ x= "Dec", low= 84, high= 230 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class Data
        {
            public string x;
            public double y;
            public double high;
            public double low;
        }

See Also