- Sparkline border
- Sparkline padding
- Sparkline area customization
- Sparkline theme
Contact Support
Appearance
17 Feb 20229 minutes to read
The appearance of the sparkline can be customized using margin, container Area border, and container Area background.
Sparkline border
The containerArea border
of the sparkline is used to render border to cover sparkline area.
The following code example shows the sparkline with overall border.
@using Syncfusion.EJ2;
<div class="spark" align="center">
<ejs-sparkline id="sparkline" loaded="loaded" height="200px" width="350px" type="@SparklineType.Area" dataSource="ViewBag.sparkData">
<e-sparkline-containerarea>
<e-sparkline-containerarea-border color='#033e96' width="2"></e-sparkline-containerarea-border>
</e-sparkline-containerarea>
<e-sparkline-border color= 'red' width="1"></e-sparkline-border>
</ejs-sparkline>
</div>
<style>
.spark {
border: 1px solid rgb(209, 209, 209);
border-radius: 2px;
width: 100%;
height: 100%;
}
</style>
<script>
function loaded(args)
{
window.sparkline = args.sparkline;
args.sparkline.loaded = null;
args.sparkline.refresh();
}
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;
namespace EJ2_Core_Application.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
ViewBag.sparkData = new int[] { 3, 6, 4, 1, 3, 2, 5 };
return View();
}
}
}
Sparkline padding
Padding is used to specify padding value between container and sparkline. By default, padding value of the sparkline is 5. Sparkline padding
values are specified by the left, right, top, and bottom.
The following code example shows the sparkline with overall padding is set to 20.
@using Syncfusion.EJ2;
<div class="spark" align="center">
<ejs-sparkline id="sparkline" loaded="loaded" height="200px" width="350px" type="@SparklineType.Area" dataSource="ViewBag.sparkData">
<e-sparkline-containerarea>
<e-sparkline-containerarea-border color='#033e96' width="2"></e-sparkline-containerarea-border>
</e-sparkline-containerarea>
<e-sparkline-padding left="20" right="20" bottom="20" top="20"></e-sparkline-padding>
<e-sparkline-border color= 'red' width="1"></e-sparkline-border>
</ejs-sparkline>
</div>
<style>
.spark {
border: 1px solid rgb(209, 209, 209);
border-radius: 2px;
width: 100%;
height: 100%;
}
</style>
<script>
function loaded(args)
{
window.sparkline = args.sparkline;
args.sparkline.loaded = null;
args.sparkline.refresh();
}
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;
namespace EJ2_Core_Application.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
ViewBag.sparkData = new int[] { 3, 6, 4, 1, 3, 2, 5 };
return View();
}
}
}
Sparkline area customization
The background color of the sparkline area can be customized using the containerArea background
color. By default, the sparkline background color is transparent
.
@using Syncfusion.EJ2;
<div class="spark" align="center">
<ejs-sparkline id="sparkline" loaded="loaded" height="200px" width="350px" type="@SparklineType.Area" dataSource="ViewBag.sparkData">
<e-sparkline-containerarea>
<e-sparkline-containerarea-border color='#033e96' width="2"></e-sparkline-containerarea-border>
</e-sparkline-containerarea>
<e-sparkline-padding left="20" right="20" bottom="20" top="20"></e-sparkline-padding>
<e-sparkline-border color= 'red' width="2"></e-sparkline-border>
</ejs-sparkline>
</div>
<style>
.spark {
border: 1px solid rgb(209, 209, 209);
border-radius: 2px;
width: 100%;
height: 100%;
}
</style>
<script>
function loaded(args)
{
window.sparkline = args.sparkline;
args.sparkline.loaded = null;
args.sparkline.refresh();
}
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;
namespace EJ2_Core_Application.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
ViewBag.sparkData = new int[] { 3, 6, 4, 1, 3, 2, 5 };
return View();
}
}
}
Sparkline theme
Datalabel and track line colors of the sparkline will be changed based on theme. For example, for dark theme, the color of datalabel and track line should be white; for light theme, their value should be black. The possible values for sparkline theme are Material
, Fabric
, Bootstrap
, and Highcontrast
.
The following code example shows the color for datalabel and track line is set to white for dark theme.
@using Syncfusion.EJ2;
<div class="spark" align="center">
<ejs-sparkline id="sparkline" loaded="loaded" height="200px" width="350px" type="@SparklineType.Line" theme= 'Highcontrast' dataSource="ViewBag.sparkData">
<e-sparkline-containerarea>
<e-sparkline-containerarea-border color='#033e96' width="2"></e-sparkline-containerarea-border>
</e-sparkline-containerarea>
<e-sparkline-axissettings minX= "-1" maxX= "7"></e-sparkline-axissettings>
<e-sparkline-border color= 'transparent' width="2"></e-sparkline-border>
</ejs-sparkline>
</div>
<style>
.spark {
border: 1px solid rgb(209, 209, 209);
border-radius: 2px;
width: 100%;
height: 100%;
}
</style>
<script>
function loaded(args)
{
window.sparkline = args.sparkline;
args.sparkline.loaded = null;
args.sparkline.refresh();
}
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;
namespace EJ2_Core_Application.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
ViewBag.sparkData = new int[] { 3, 6, 4, 1, 3, 2, 5 };
return View();
}
}
}