Smoothed Line Chart
<h2>Customizable line tension</h2>
Line series has two very easy settings that can control how line smoothing algorithm works: <code>tensionX</code> and <code>tensionY</code>.
This allows tailoring smoothed line to suit your needs and data.
[amcharts2_button href="https://www.amcharts.com/docs/v4/concepts/axes/axis-ranges/"]More about smoothed lines[/amcharts2_button]
<h2>Axis ranges</h2>
Axis ranges is another powerful feature of amCharts 4. Besides other uses, it allows defining a range on any axis. Any visual property of the series, that falls within this specific range, will be overridden with specific values.
[amcharts2_button href="https://www.amcharts.com/docs/v4/concepts/axes/axis-ranges/"]More about axis ranges[/amcharts2_button]
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
/**
* ---------------------------------------
* This demo was created using amCharts 4.
*
* For more information visit:
* https://www.amcharts.com/
*
* Documentation is available at:
* https://www.amcharts.com/docs/v4/
* ---------------------------------------
*/
// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end
// Create chart instance
var chart = am4core.create("chartdiv", am4charts.XYChart);
chart.paddingRight = 20;
// Add data
chart.data = [{
"year": "1950",
"value": 31
}, {
"year": "1951",
"value": 31
}, {
"year": "1952",
"value": 29
}, {
"year": "1953",
"value": 29
}, {
"year": "1954",
"value": 31
}, {
"year": "1955",
"value": 30
}, {
"year": "1956",
"value": 29
}, {
"year": "1957",
"value": 29
}, {
"year": "1958",
"value": 33
}, {
"year": "1959",
"value": 33
}, {
"year": "1960",
"value": 33
}, {
"year": "1961",
"value": 29
}, {
"year": "1962",
"value": 29
}, {
"year": "1963",
"value": 29
}, {
"year": "1964",
"value": 29
}, {
"year": "1965",
"value": 29
}, {
"year": "1966",
"value": 29
}, {
"year": "1967",
"value": 29
}, {
"year": "1968",
"value": 29
}, {
"year": "1969",
"value": 29
}];
// Create axes
var categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
categoryAxis.dataFields.category = "year";
categoryAxis.renderer.minGridDistance = 50;
categoryAxis.renderer.grid.template.location = 0.5;
categoryAxis.startLocation = 0.5;
categoryAxis.endLocation = 0.5;
// Create value axis
var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
valueAxis.baseValue = 0;
// Create series
var series = chart.series.push(new am4charts.LineSeries());
series.dataFields.valueY = "value";
series.dataFields.categoryX = "year";
series.strokeWidth = 2;
series.tensionX = 0.77;