【问题标题】:How to create chart bar with lines in jQuery如何在jQuery中创建带有线条的图表栏
【发布时间】:2018-01-07 06:14:16
【问题描述】:

我想创建一些图表栏+线,但我不知道如何组合两个图表。

我想像这张图片一样吧

谢谢,希望有人能帮我解决问题

【问题讨论】:

标签: javascript jquery bar-chart


【解决方案1】:

这个https://jsfiddle.net/nu7cx100/怎么样

window.onload = function () {
    	var chart = new CanvasJS.Chart("chartContainer",{              
    		title:{
    			text: "Grafik Riwayat PKPT"
    		},
    		axisX:{
    			valueFormatString: "####",
    			interval: 1
    		},
    		axisY:[{
    			title: "Linear Scale",
    			lineColor: "#369EAD",
    			titleFontColor: "#369EAD",
    			labelFontColor: "#369EAD"
    		}],
    		axisY2:[{
    			title: "Linear Scale",
    			lineColor: "#7F6084",
    			titleFontColor: "#7F6084",
    			labelFontColor: "#7F6084"
    		}],
    
    	data: [
    	{
    		type: "column",
    		showInLegend: true,
    		//axisYIndex: 0, //Defaults to Zero
    		name: "ANNGGARAN",
    		xValueFormatString: "####",
    		dataPoints: [
    			{ x: 2006, y: 60 },
    			{ x: 2007, y: 20 },
    			{ x: 2008, y: 50 },
    			{ x: 2009, y: 70 },
    			{ x: 2010, y: 10 },
    			{ x: 2011, y: 50 },
    			{ x: 2012, y: 50 },
    			{ x: 2013, y: 20 },
    			{ x: 2014, y: 20 }
    		]
    	},
    	{
    		type: "line",
    		showInLegend: true,
    		axisYIndex: 1, //Defaults to Zero
    		name: "KEGIATAN",
    		xValueFormatString: "####",
    		dataPoints: [
    			{ x: 2006, y: 15 },
    			{ x: 2007, y: 3 },
    			{ x: 2008, y: 20 },
    			{ x: 2009, y: 10 },
    			{ x: 2010, y: 15 },
    			{ x: 2011, y: 10 },
    			{ x: 2012, y: 20 },
    			{ x: 2013, y: 20 },
    			{ x: 2014, y: 2 }
    		]
    	}
    	]
    	});
    
    	chart.render();
    }
    <script type="text/javascript" src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="https://canvasjs.com/assets/script/jquery.canvasjs.min.js"></script>
    <div id="chartContainer" style="height: 300px; width: 100%;"></div>

它使用 canvasjs 希望这会有所帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多