• Demos
    • JavaScript Charts
    • JavaScript StockCharts
  • Download/NPM
    • Download CanvasJS
    • Install via NPM
  • Integrations
    Front End Technology Samples
    • React Charts
    • Angular Charts
    • Vue.js Charts New!
    • jQuery Charts
    • Dashboards
    Server Side Technology Samples
    • PHP Charts
    • Python Charts New!
    • ASP.NET MVC Charts
    • Spring MVC Charts
    • JSP Charts
  • License
  • Blog
  • Docs
    • Chart Documentation
    • StockChart Documentation
  • Support Forum
    • Chart Support
    • StockChart Support
  • My Account
My Account
  • KEY FEATURES
    • Chart with Index Label
    • Multi Series Chart
    • Chart with Zooming & Panning
    • Synchronized Charts
    • Chart with Animation
    • Chart With Image Overlay
    • Chart with Secondary Axis
    • Chart with Null Data
    • Chart with Dynamic Data
    • Column Chart with Reversed Axis
    • Chart with Logarithmic Axis
    • Chart using JSON Data
    • Performance With 50,000 Data Points
    • Draggable Column Chart
    • Chart with Axis / Scale Break
    • Chart with Crosshair
    • Chart with Customized Legends
    • Drilldown Chart
    • Responsive Chart
    • Chart with Axis Labels & Ticks inside Plot Area
    • Sync ToolTip across Multiple Charts
  • LINE CHARTS
    • Line Chart
    • Dashed Line Chart
    • Multi Series Line Chart
    • Line Chart with Zoom and Pan
    • Line Chart with Data Marker
    • Line Chart with Logarithmic Axis
    • Line Chart with Axis / Scale Break
    • Line Chart with Multiple Axes
    • Spline Chart
    • Multi Series Spline Chart
    • Dynamic Spline Chart
    • Spline Chart with Secondary Axis
    • Spline Chart with Legends
    • Step Line Chart
    • Multi Series Step Line Chart with Null Data
  • AREA CHARTS
    • Area Chart
    • Multi Series Area Charts
    • Spline Area Chart
    • Multi Series Spline Area Charts
    • Step Area Chart
    • Range Area Chart
    • Multi Series Range Area Charts
    • Range Spline Area Chart
    • Stacked Area Chart
    • Stacked Area 100% Chart
    • Stacked Area 100% Chart with Date-Time Axis
  • COLUMN & BAR CHARTS
    • Column Chart
    • Column Charts with Multiple Axes
    • Bar Chart
    • Multi Series Bar Chart
    • Bar Chart with Axis / Scale Break
    • Range Column Chart
    • Multi Series Range Column Chart
    • Stacked Column Chart
    • Stacked Column 100% Chart
    • Range Bar Chart
    • Stacked Bar Chart
    • Stacked Bar 100% Chart
    • Waterfall Chart
    • Multi Series Waterfall Chart
    • Waterfall Chart with Custom Colors
  • PIE & FUNNEL CHARTS
    • Pie Chart
    • Pie Chart with Legends
    • Pie Chart with Custom Radius
    • Doughnut Chart
    • Doughnut Chart with Custom Inner Radius
    • Funnel Chart
    • Funnel Chart with Custom Neck
    • Inverted Funnel Chart
    • Pyramid Chart
    • Pyramid Chart with Values represented by Area
    • Pyramid Chart With Index Labels Placed Inside
  • FINANCIAL CHARTS
    • Candlestick Chart
    • Multi Series Candlestick Chart
    • Combination of Candlestick & Line Chart
    • OHLC Chart
    • OHLC Chart from JSON Data using AJAX
  • SCATTER & BUBBLE CHARTS
    • Scatter / Point Chart
    • Multi Series Scatter / Point Chart
    • Scatter Chart with Custom Markers
    • Bubble Chart
    • Bubble Chart with Zoom & Pan
    • Bubble Chart with Custom Markers
  • BOX & WHISKER CHARTS
    • Box And Whisker Chart
    • Box and Whisker Chart with Color Customization
    • Box And Whisker Chart with Outliers
  • COMBINATION CHARTS
    • Error Chart
    • Error Line Chart
    • Error Bar Chart
    • Pareto Chart
    • Pareto Chart with Index / Data Label
    • Combination of Range Area and Line Charts
    • Combination of Column, Line and Area Chart
    • Combination of OHLC and Line Chart
  • DYNAMIC CHARTS
    • Dynamic / Live Column Chart
    • Dynamic / Live Line Chart
    • Dynamic / Live Multi Series Chart
  • ANGULAR, REACT, VUE.JS, JQUERY
    • Angular Charts
    • React Charts
    • Vue.js Charts
    • jQuery Charts
  • SERVER SIDE TECHNOLOGIES
    • ASP.NET MVC Charts
    • PHP Charts
    • Python Charts
    • JSP Charts
    • Spring MVC Charts

JavaScript Line Charts with Multiple Axes

Download JavaScript Chart Samples
  • JavaScript Chart Samples
  • React Chart Samples
  • Angular Chart Samples
  • Vue.js Chart Samples
  • jQuery Chart Samples
  • PHP Chart Samples
  • Python Django Chart Samples
  • ASP.NET Chart Samples
  • JSP Chart Samples
  • Spring MVC Chart Samples
  • Dashboard Samples
  • JavaScript StockChart Samples

Line Chart supports plotting of two or more scales in the chart. This feature is really useful when plotting values in a graph that vary widely from one data series to another and is supported in all other graph with axis. Given example shows Line Chart which uses multiple Y-axis to represent different scales. It also contains source code that you can edit in-browser or save to run it locally.

Try Editing The Code

Download Copy JSFiddle
window.onload = function () {
	var chart = new CanvasJS.Chart("chartContainer", {
	title:{
		text: "Weekly Revenue Analysis for First Quarter"
	},
	axisY:[{
		title: "Order",
		lineColor: "#C24642",
		tickColor: "#C24642",
		labelFontColor: "#C24642",
		titleFontColor: "#C24642",
		includeZero: true,
		suffix: "k"
	},
	{
		title: "Footfall",
		lineColor: "#369EAD",
		tickColor: "#369EAD",
		labelFontColor: "#369EAD",
		titleFontColor: "#369EAD",
		includeZero: true,
		suffix: "k"
	}],
	axisY2: {
		title: "Revenue",
		lineColor: "#7F6084",
		tickColor: "#7F6084",
		labelFontColor: "#7F6084",
		titleFontColor: "#7F6084",
		includeZero: true,
		prefix: "$",
		suffix: "k"
	},
	toolTip: {
		shared: true
	},
	legend: {
		cursor: "pointer",
		itemclick: toggleDataSeries
	},
	data: [{
		type: "line",
		name: "Footfall",
		color: "#369EAD",
		showInLegend: true,
		axisYIndex: 1,
		dataPoints: [
			{ x: new Date(2017, 00, 7), y: 85.4 }, 
			{ x: new Date(2017, 00, 14), y: 92.7 },
			{ x: new Date(2017, 00, 21), y: 64.9 },
			{ x: new Date(2017, 00, 28), y: 58.0 },
			{ x: new Date(2017, 01, 4), y: 63.4 },
			{ x: new Date(2017, 01, 11), y: 69.9 },
			{ x: new Date(2017, 01, 18), y: 88.9 },
			{ x: new Date(2017, 01, 25), y: 66.3 },
			{ x: new Date(2017, 02, 4), y: 82.7 },
			{ x: new Date(2017, 02, 11), y: 60.2 },
			{ x: new Date(2017, 02, 18), y: 87.3 },
			{ x: new Date(2017, 02, 25), y: 98.5 }
		]
	},
	{
		type: "line",
		name: "Order",
		color: "#C24642",
		axisYIndex: 0,
		showInLegend: true,
		dataPoints: [
			{ x: new Date(2017, 00, 7), y: 32.3 }, 
			{ x: new Date(2017, 00, 14), y: 33.9 },
			{ x: new Date(2017, 00, 21), y: 26.0 },
			{ x: new Date(2017, 00, 28), y: 15.8 },
			{ x: new Date(2017, 01, 4), y: 18.6 },
			{ x: new Date(2017, 01, 11), y: 34.6 },
			{ x: new Date(2017, 01, 18), y: 37.7 },
			{ x: new Date(2017, 01, 25), y: 24.7 },
			{ x: new Date(2017, 02, 4), y: 35.9 },
			{ x: new Date(2017, 02, 11), y: 12.8 },
			{ x: new Date(2017, 02, 18), y: 38.1 },
			{ x: new Date(2017, 02, 25), y: 42.4 }
		]
	},
	{
		type: "line",
		name: "Revenue",
		color: "#7F6084",
		axisYType: "secondary",
		showInLegend: true,
		dataPoints: [
			{ x: new Date(2017, 00, 7), y: 42.5 }, 
			{ x: new Date(2017, 00, 14), y: 44.3 },
			{ x: new Date(2017, 00, 21), y: 28.7 },
			{ x: new Date(2017, 00, 28), y: 22.5 },
			{ x: new Date(2017, 01, 4), y: 25.6 },
			{ x: new Date(2017, 01, 11), y: 45.7 },
			{ x: new Date(2017, 01, 18), y: 54.6 },
			{ x: new Date(2017, 01, 25), y: 32.0 },
			{ x: new Date(2017, 02, 4), y: 43.9 },
			{ x: new Date(2017, 02, 11), y: 26.4 },
			{ x: new Date(2017, 02, 18), y: 40.3 },
			{ x: new Date(2017, 02, 25), y: 54.2 }
		]
	}]
});
chart.render();

function toggleDataSeries(e) {
	if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
		e.dataSeries.visible = false;
	} else {
		e.dataSeries.visible = true;
	}
	e.chart.render();
}

}                                

Chart Customizations

You can attach data series to a secondary axis by using the axisXType / axisYType property. You can also select index of axis for each data series using axisXIndex and axisYIndex. Other frequently used customization options are shared, showInLegend, etc.

Quick Links

  • Chart Docs
  • StockChart Docs
  • About Us
  • FAQs

Server Side Technologies

  • ASP.NET MVC Charts
  • PHP Charts
  • JSP Charts
  • Spring MVC Charts

Front Side Technologies

  • JavaScript Charts
  • jQuery Charts
  • React Charts
  • Angular Charts
  • JavaScript StockCharts

Contact

  • Fenopix, Inc.
  • 2093 Philadelphia Pike,
  • #5678, Claymont,
  • Delaware 19703
  • United States Of America

©2025 Fenopix Privacy Policy Cookies Policy Careers