Amchart(九)曲线图

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhuoganliwanjin/article/details/84999547
<!DOCTYPE html>
<html>
  <head>
    	<meta charset="UTF-8" />
    	<title>曲线图</title>
    	<link rel="stylesheet" href="index.css" />
  </head>
  	<body>
    		<div id="chartdiv"></div>
				<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>
    		<script>
    				am4core.useTheme(am4themes_animated);

						var chart = am4core.create("chartdiv", am4charts.XYChart);
						
						chart.data = [{
						  "country": "One",
						  "value": 3025
						}, {
						  "country": "Two",
						  "value": 1882
						}, {
						  "country": "Three",
						  "value": 1809
						}, {
						  "country": "Four",
						  "value": 1322
						}, {
						  "country": "Five",
						  "value": 1122
						}, {
						  "country": "Six",
						  "value": -1114
						}, {
						  "country": "Seven",
						  "value": -984
						}, {
						  "country": "Eight",
						  "value": 711
						}, {
						  "country": "Nine",
						  "value": 665
						}, {
						  "country": "Ten",
						  "value": -580
						}, {
						  "country": "Eleven",
						  "value": 443
						}, {
						  "country": "Twelve",
						  "value": 441
						}];
						
						
						var categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
						categoryAxis.renderer.grid.template.location = 0;
						categoryAxis.dataFields.category = "country";
						categoryAxis.renderer.minGridDistance = 40;
						
						var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
						
						var series = chart.series.push(new am4charts.CurvedColumnSeries());
						series.dataFields.categoryX = "country";
						series.dataFields.valueY = "value";
						series.tooltipText = "{valueY.value}"
						series.columns.template.strokeOpacity = 0;
						
						series.columns.template.fillOpacity = 0.75;
						
						var hoverState = series.columns.template.states.create("hover");
						hoverState.properties.fillOpacity = 1;
						hoverState.properties.tension = 0.5;
						
						chart.cursor = new am4charts.XYCursor();
						
						// Add distinctive colors for each column using adapter
						series.columns.template.adapter.add("fill", function (fill, target) {
						  return chart.colors.getIndex(target.dataItem.index);
						});
						
						chart.scrollbarX = new am4core.Scrollbar();
				</script>
  	</body>
</html>

 Amchart全部示例 github地址 别忘了点个小星星 

猜你喜欢

转载自blog.csdn.net/zhuoganliwanjin/article/details/84999547
今日推荐