This section explains how to add markers to the sparklines.
To add marker to the sparkline, specify the visible
of markerSettings
as following values. The visible
will accept multiple values too.
The following code example shows enabling markers for all points.
//Initialize Sparkline component
var sparklineInstance = new ej.charts.Sparkline({
height: '200px',
width: '350px',
axisSettings: {
minX: -1, maxX: 7, maxY: 7, minY: -1
},
dataSource: [0, 6, 4, 1, 3, 2, 5],
markerSettings: {
visible: ['All']
}
});
//Render initialized Sparkline
sparklineInstance.appendTo("#element");
<!DOCTYPE html><html lang="en"><head>
<title>Essential JS 2 for Sparkline </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Essential JS 2 for Sparkline UI Control">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.1.35/ej2-charts/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/21.1.35/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container" style="margin-top: 15%;">
<div id="element" align="center"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
In sparkline, markers can be enabled for particular points such as the start, end, low, high, or negative. The following code examples shows enabling markers for the high and low points.
//Initialize Sparkline component
var sparklineInstance = new ej.charts.Sparkline({
height: '200px',
width: '350px',
axisSettings: {
minX: -1, maxX: 7, maxY: 7, minY: -1
},
dataSource: [3, 6, 4, 1, 3, 2, 5],
highPointColor: 'blue',
lowPointColor: 'red',
markerSettings: {
visible: ['High', 'Low']
}
});
//Render initialized Sparkline
sparklineInstance.appendTo("#element");
<!DOCTYPE html><html lang="en"><head>
<title>Essential JS 2 for Sparkline </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Essential JS 2 for Sparkline UI Control">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.1.35/ej2-charts/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/21.1.35/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container" style="margin-top: 15%;">
<div id="element" align="center"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Sparkline markers can be customized in terms of fill color, border color, width, opacity, and size. The following code example shows customizing marker’s fill, border, and size.
//Initialize Sparkline component
var sparklineInstance = new ej.charts.Sparkline({
height: '200px',
width: '350px',
axisSettings: {
minX: -1, maxX: 7, maxY: 7, minY: -1
},
dataSource: [3, 6, 4, 1, 3, 2, 5],
fill: 'blue',
markerSettings: {
visible: ['All'],
size: 5, fill: 'white', border: { color: 'blue', width: 2}
}
});
//Render initialized Sparkline
sparklineInstance.appendTo("#element");
<!DOCTYPE html><html lang="en"><head>
<title>Essential JS 2 for Sparkline </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Essential JS 2 for Sparkline UI Control">
<meta name="author" content="Syncfusion">
<link href="index.css" rel="stylesheet">
<link href="//cdn.syncfusion.com/ej2/21.1.35/ej2-charts/styles/material.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/21.1.35/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container" style="margin-top: 15%;">
<div id="element" align="center"></div>
</div>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>