Line With Custom Bullets
<h2>Anything can be a bullet</h2>
Besides pre-defined shapes, bullet can be anything in amCharts 4 - an SVG image or path, static image, another complex shape - even another chart.
[amb href="https://www.amcharts.com/docs/v4/concepts/bullets/"]More information about bullets[/amb]
by Rogério Saraceni
September 19, 2019
HTML
<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/charts.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/animated.js"></script>
<div id="chartdiv"></div>
CSS
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
#chartdiv {
width: 100%;
height: 500px;
}
JavaScript
// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end
// Create chart instance
var chart = am4core.create("chartdiv", am4charts.XYChart);
chart.autoMargins = false;
chart.marginLeft = 0;
chart.marginRight = 0;
chart.marginBottom = 0;
chart.marginTop = 0;
// Add data
chart.data = [{
"semana": "Semana - 5",
"download": 200
}, {
"semana": "Semana - 4",
"download": 250
}, {
"semana": "Semana - 3",
"download": 190
}, {
"semana": "Semana - 2",
"download": 185
}, {
"semana": "Semana - 1",
"download": 280
}];
// Create axes
var categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
categoryAxis.tooltip.disabled = true;
categoryAxis.renderer.labels.template.disabled = true;
categoryAxis.renderer.grid.template.disabled = true;
categoryAxis.dataFields.category = "semana";
// Create value axis
var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
valueAxis.tooltip.disabled = true;
valueAxis.renderer.line.opacity = 0;
valueAxis.renderer.ticks.template.disabled = true;
valueAxis.renderer.labels.template.disabled = true;
valueAxis.renderer.grid.template.disabled = true;
valueAxis.min = 0;
// Create series
var lineSeries = chart.series.push(new am4charts.LineSeries());
lineSeries.dataFields.valueY = "download";
lineSeries.dataFields.categoryX = "semana";
lineSeries.name = "Downloads";
lineSeries.strokeWidth = 1;
lineSeries.strokeDasharray = 3;
lineSeries.stroke = "#5D89A8"
var bullet = lineSeries.bullets.push(new am4charts.CircleBullet());
bullet.circle.radius = 3;
bullet.circle.strokeWidth = 3;
bullet.circle.fill = "#5D89A8"
bullet.tooltipText = "{categoryX} : {valueY}";