Multiple Value Axes in amCharts 4

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="./amcharts4/core.js"></script>
<script src="./amcharts4/charts.js"></script>
<script src="./amcharts4/maps.js"></script>
<script src="./amcharts4/themes/animated.js"></script>
<div style="width: 100%;max-height: 500px;height: 100vh;" id="chartdiv"></div>
<script>
	am4core.ready(function() {
		// Themes begin
		am4core.useTheme(am4themes_animated);
		// Themes end

		// Create chart instance
		var chart = am4core.create("chartdiv", am4charts.XYChart);

		// Increase contrast by taking evey second color
		chart.colors.step = 2;

		// Add data
		chart.data = generateChartData();

		// Create axes
		var dateAxis = chart.xAxes.push(new am4charts.DateAxis());
		dateAxis.renderer.minGridDistance = 50;
		dateAxis.renderer.labels.template.location = 0.0001;
		dateAxis.baseInterval = {
			 "timeUnit": "second",
			 "count": 1
		}

		// Create series
		function createAxisAndSeries(field, name, opposite, bullet, numberFormat) {
		  var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
		  if(chart.yAxes.indexOf(valueAxis) != 0){
			valueAxis.syncWithAxis = chart.yAxes.getIndex(0);
		  }
		  
		  var series = chart.series.push(new am4charts.LineSeries());
		  series.dataFields.valueY = field;
		  series.dataFields.dateX = "date";
		  series.strokeWidth = 2;

		  series.yAxis = valueAxis;
		  series.name = name;

		  if(field == "T0"){
			series.tooltipText = " {date.formatDate('YYYY-MM-dd hh:mm')} \n {name}: [red bold]{valueY}°C[/]";
			series.stroke = am4core.color("red");
			
		  }else if(field == "RH"){
			series.tooltipText = " {date.formatDate('YYYY-MM-dd hh:mm')} \n {name}: [blue bold]{valueY}%[/]"; 
			series.stroke = am4core.color("blue");
		  }

		  series.tensionX = 0.8;
		  series.showOnInit = true;
		
		  var interfaceColors = new am4core.InterfaceColorSet();
		  
		  switch(bullet) {
			case "RH":
			 var bullet = series.bullets.push(new am4charts.CircleBullet());
				bullet.circle.strokeWidth = 2;
				bullet.circle.radius = 4;
				bullet.circle.fill = am4core.color("#fff");
				bullet.circle.stroke = am4core.color("blue");
				var bullethover1 = bullet.states.create("hover");
				bullethover1.properties.scale = 1.3;	
				valueAxis.title.text = "相對濕度 (%)";
				break;
			case "T0":
				// Make bullets grow on hover
				var bullet = series.bullets.push(new am4charts.CircleBullet());
				bullet.circle.strokeWidth = 2;
				bullet.circle.radius = 4;
				bullet.circle.fill = am4core.color("#fff");
				bullet.circle.stroke = am4core.color("red");
				var bullethover1 = bullet.states.create("hover");
				bullethover1.properties.scale = 1.3;
				valueAxis.title.text = "氣溫 (°C)";
	
				break;
			default:
				var bullet = series.bullets.push(new am4charts.CircleBullet());
				bullet.circle.stroke = interfaceColors.getFor("background");
				bullet.circle.strokeWidth = 2;
				break;
			} 
			valueAxis.renderer.line.strokeOpacity = 1;
			valueAxis.renderer.line.strokeWidth = 2;
			valueAxis.renderer.line.stroke = series.stroke;
			valueAxis.renderer.labels.template.fill = series.stroke;
			valueAxis.renderer.opposite = opposite;
			valueAxis.numberFormatter = new am4core.NumberFormatter();
			valueAxis.numberFormatter.numberFormat = numberFormat; 
		}
		createAxisAndSeries("T0", "氣溫", true, "T0", "#°C");
		createAxisAndSeries("RH", "相對濕度", false, "RH", "#'%'");
	
		// Add legend
		chart.legend = new am4charts.Legend();

		// Add cursor
		chart.cursor = new am4charts.XYCursor();
		chart.dateFormatter.inputDateFormat = "yyyy-MM-dd H:m";
		
		chart.scrollbarX = new am4core.Scrollbar();
		chart.scrollbarX.parent = chart.bottomAxesContainer;

		// Enable export
		chart.exporting.menu = new am4core.ExportMenu();
    chart.exporting.menu.items[0].icon = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIi";
		// chart.exporting.menu.container = document.getElementById("tools");

		// generate some random data, quite different range
		function generateChartData() {
			var chartData = [];
			chartData.push({date: "2020-03-04 00:00",RH: "78.7",T0: "20",});
			chartData.push({date: "2020-03-04 00:01",RH: "78.8",T0: "20",});
			chartData.push({date: "2020-03-04 00:02",RH: "79.1",T0: "20",});
			chartData.push({date: "2020-03-04 00:03",RH: "79.1",T0: "20",});
			chartData.push({date: "2020-03-04 00:04",RH: "78.9",T0: "20",}); 
			return chartData;
		}
	}); // end am4core.ready()

	$(document).ready(function(){
		$("g[aria-labelledby='id-66-title']").hide();
	})
</script>

Ouput:
multiple-value-axes-in-amcharts-4

298 thoughts on “Multiple Value Axes in amCharts 4

  1. Pingback: cialis otc

  2. Pingback: online cialis

  3. Pingback: Order viagra us

  4. Pingback: Buy brand viagra

  5. Pingback: cialis 20 mg

  6. Pingback: cialis 5mg price

  7. Pingback: cialis without a doctor prescription

  8. Pingback: viagra 100mg

  9. Pingback: viagra 50mg

  10. Pingback: viagra 50mg

  11. Pingback: erection pills online

  12. Pingback: cheap erectile dysfunction

  13. Pingback: buy erection pills

  14. Pingback: buy cialis generic

  15. Pingback: walmart pharmacy

  16. Pingback: canadian pharmacy

  17. Pingback: Buy cialis online

  18. Pingback: cialis generic

  19. Pingback: levitra for sale

  20. Pingback: order levitra

  21. Pingback: levitra

  22. Pingback: real money casino games

  23. Pingback: online casino games

  24. Pingback: viagra online prescription

  25. Pingback: online casino real money usa

  26. Pingback: real money online casino

  27. Pingback: payday advance

  28. Pingback: loan online

  29. Pingback: quick cash loans

  30. Pingback: viagra pills

  31. Pingback: cialis buy

  32. Pingback: cialis generic

  33. Pingback: generic cialis

  34. Pingback: 20 cialis

  35. Pingback: 20 cialis

  36. Pingback: real money casino

  37. Pingback: play online casino real money

  38. Pingback: online casino real money usa

  39. Pingback: canada viagra

  40. Pingback: viagra buy

  41. Pingback: order viagra

  42. Pingback: tadalafil 20 mg

  43. Pingback: viagra generic

  44. Pingback: cheap viagra

  45. Pingback: buy viagra online

  46. Pingback: cheap sildenafil

  47. Pingback: generic cialis

  48. Pingback: viagra online for sale

  49. Pingback: drugs without prescription

  50. Pingback: reputable canadian online pharmacy

  51. Pingback: viagra sans ordonnance en pharmacie

  52. Pingback: cialis online

  53. Pingback: canadian pharmacy viagra

  54. Pingback: cialis

  55. Pingback: buy viagra

  56. Pingback: erection pills online

  57. Pingback: viagra

  58. Pingback: ED Pills

  59. Pingback: buy cialis online

  60. Pingback: buy cialis canada

  61. Pingback: cialisorgcom

  62. Pingback: buy cialis online

  63. Pingback: cialisorgcom

  64. Pingback: best online viagra

  65. Pingback: amoxicillin 250 mg price in india

  66. Pingback: 5mg cialis

  67. Pingback: generic viagra fast shipping

  68. Pingback: viagra soft gel capsules

  69. Pingback: buy levitra fast delivery

  70. Pingback: personal loans for bad credit

  71. Pingback: viagra 88

  72. Pingback: sildenafil tabs 20mg

  73. Pingback: buy levitra online

  74. Pingback: Cost of viagra

  75. Pingback: female viagra capsules in india

  76. Pingback: sildenafil 90mg

  77. Pingback: order cialis from canada

  78. Pingback: indian generic viagra

  79. Pingback: Usa viagra sales

  80. Pingback: generic viagra canadian

  81. Pingback: Real viagra pharmacy prescription

  82. Pingback: cialis generic uk

  83. Pingback: help writing essays for scholarships

  84. Pingback: generic cialis

  85. Pingback: essay help writing

  86. Pingback: dissertation editing

  87. Pingback: essay writing services recommendations

  88. Pingback: viagra

  89. Pingback: thesis proposal writing service

  90. Pingback: buying a research paper for college

  91. Pingback: write my statistics paper

  92. Pingback: Buy viagra canada

  93. Pingback: generic viagra

  94. Pingback: canada online pharmacy

  95. Pingback: buy Doxycyline

  96. Pingback: cialis orders paypal paid

  97. Pingback: natural ed treatments

  98. Pingback: cialis for daily use

  99. Pingback: order generic cialis

  100. Pingback: generic viagra without a doctor prescription

  101. Pingback: canadian pharmacies shipping usa

  102. Pingback: where can i buy zithromax in canada

  103. Pingback: generic viagra

  104. Pingback: viagra without doctor prescription

  105. Pingback: cheap erectile dysfunction pills online

  106. Pingback: no 1 canadian pharcharmy online

  107. Pingback: buy medication without an rx

  108. Pingback: canada pharmacy

  109. Pingback: Zovirax

  110. Pingback: canada pharmacies prescription drugs

  111. Pingback: best canadian online pharmacy

  112. Pingback: canadian online pharmacies

  113. Pingback: online pharmacy canada

  114. Pingback: viagra cialis

  115. Pingback: amoxicillin in india

  116. Pingback: buy amoxicillin 500mg uk

  117. Pingback: 175mg benadryl

  118. Pingback: claritin d where to buy

  119. Pingback: discount viagra

  120. Pingback: viagra no prescription

  121. Pingback: buy zithromax 500mg online

  122. Pingback: how much is amoxicillin prescription

  123. Pingback: canadian drugs pharmacy

  124. Pingback: Google

  125. Pingback: sildenafil

  126. Pingback: cialis daily

  127. Pingback: order cialis online no prescription reviews

  128. Pingback: ordering cialis online australia

  129. Pingback: cialis 20 mg best price

  130. Pingback: generic cialis

  131. Pingback: cialis brand name without prescription

  132. Pingback: cialis for daily use

  133. Pingback: gayhub

  134. Pingback: buy cialis insurance

  135. Pingback: viagra Without a Doctor Prescription

  136. Pingback: wwwfreecialispills

  137. Pingback: 1xbet ug

  138. Pingback: ejaculating dong

  139. Pingback: anal suppositories

  140. Pingback: 샌즈카지노

  141. Pingback: safe buy cialis

  142. Pingback: 우리카지노

  143. Pingback: 코인카지노

  144. Pingback: TransHub

  145. Pingback: hq porner

  146. Pingback: sildenafil 110 mg

  147. Pingback: ordering viagra online is it legal

  148. Pingback: order tramadol online

  149. Pingback: canadian pharmacy online cialis

  150. Pingback: generic cialis 20 mg tadalafil

  151. Pingback: buy cialis online europe

  152. Pingback: viagra generic

  153. Pingback: GayHub

  154. Pingback: Belgian malinois puppies for sale

  155. Pingback: Mining

  156. Pingback: generic tadalafil

  157. Pingback: buy cialis canadian

  158. Pingback: buy cialis toronto

  159. Pingback: MILF Porn

  160. Pingback: pills erectile dysfunction

  161. Pingback: lytxccnh

  162. Pingback: Online Advertising

  163. Pingback: pills for erection

  164. Pingback: what happens when you take two viagra

  165. Pingback: waar bestaat viagra uit

  166. Pingback: online pharmacy viagra

  167. Pingback: zithromax how to take

  168. Pingback: lasix side effects

  169. Pingback: avant consulting

  170. Pingback: 샌즈카지노

  171. Pingback: 메리트카지노

  172. Pingback: buy nitrofurantoin generic

  173. Pingback: 코인카지노

  174. Pingback: buy ciplox generic

  175. Pingback: myambutol price

  176. Pingback: anaimmi

  177. Pingback: freight travel

  178. Pingback: cbd for anxiety

  179. Pingback: best cbd gummies

  180. Pingback: cbd for dogs

  181. Pingback: buy cialis with paypal

  182. Pingback: best prostate vibrator

  183. Pingback: cialis vs levitra

  184. Pingback: green maeng da kratom

  185. Pingback: white maeng da kratom

  186. Pingback: taking cialis soft tabs

  187. Pingback: viagra

  188. Pingback: working visa

  189. Pingback: buy cialis

  190. Pingback: cialis 5mg tablet

  191. Pingback: essay writing service

  192. Pingback: buy cbd oil

  193. Pingback: write my research paper for me cheap

  194. Pingback: i need help writing my essay

  195. Pingback: software buy

  196. Pingback: application essay help

  197. Pingback: cialis 20mg for sale

  198. Pingback: argumentative essay business ethics

  199. Pingback: Purchase Weed Online

  200. Pingback: how much does cialis cost with insurance

  201. Pingback: مزاداتي عمان

  202. Pingback: BUY PERCOCET TABLETS ONLINE

  203. Pingback: masturbation boys

  204. Pingback: Idaho Fake driver's license

  205. Pingback: Can I buy Hydrocodone online

  206. Pingback: buy kratom online

  207. Pingback: kratom for anxiety

  208. Pingback: cialis 20mg for sale

  209. Pingback: 우리카지노

  210. Pingback: 퍼스트카지노

  211. Pingback: online cricket betting sites in indian rupees

  212. Pingback: buy prescription drugs

  213. Pingback: buy cialis with paypal

  214. Pingback: cialis 20mg for sale

  215. Pingback: viagra from canada

  216. Pingback: Great Dane puppies for sale

  217. Pingback: amoxil 250mg

  218. Pingback: buy furosemide 40 mg uk

  219. Pingback: viagra cost

  220. Pingback: azithromycin over the counter nz

  221. Pingback: Outsourcing Agency

  222. Pingback: ivermectin pills

  223. Pingback: cheap viagra online

  224. Pingback: ventolin proventil

  225. Pingback: safestore auto

  226. Pingback: pc app free download

  227. Pingback: download apk app for pc

  228. Pingback: order viagra online

  229. Pingback: apps download for windows 7

  230. Pingback: viagra over the counter walmart

  231. Pingback: generic zithromax 500mg india

  232. Pingback: viagra over the counter

  233. Pingback: doxycycline and depression

  234. Pingback: prednisolone ophthalmic drops

  235. Pingback: singapore divorce lawyer

  236. Pingback: clomid at 40

  237. Pingback: dapoxetine (generic priligy

  238. Pingback: christiandogma

  239. Pingback: diflucan otc

  240. Pingback: magnesium synthroid

  241. Pingback: Massachusetts Fake driver's license

  242. Pingback: help with essay

  243. Pingback: order ed pills

  244. Pingback: unique wall art

  245. Pingback: phd thesis writing

  246. Pingback: Buy Opana Online

  247. Pingback: reviews for essay writing services

  248. Pingback: MAGIC MUSHROOM GROW KIT

  249. Pingback: dissertation help online

  250. Pingback: zithromax online no prescription

  251. Pingback: help me write a thesis statement

  252. Pingback: https://trippydelics.ca

  253. Pingback: 32 neurontin

  254. Pingback: pay to write my essay

  255. Pingback: buy zithromax 500mg online

  256. Pingback: click here

  257. Pingback: Pc hilfe rapperswil

  258. Pingback: propecia dht

  259. Pingback: Herbal incense

  260. Pingback: write my social work essay

  261. Pingback: Herbal incense

  262. Pingback: paying someone to write a paper

  263. Pingback: Furniture

  264. Pingback: guns for sale craigslist

  265. Pingback: shipping container accessories

  266. Pingback: cialis black

  267. Pingback: canadapharmacy.com

  268. Pingback: meds from india

  269. Pingback: Canada services

  270. Pingback: virtual visa card buy with bitcoin

  271. Pingback: neurontin substitutes

  272. Pingback: metformin usage

  273. Pingback: Buy THC Weed in Europe

  274. Pingback: zoloft vs paxil

  275. Pingback: shipping container office

  276. Pingback: 24 awg wire

  277. Pingback: plaquenil and arava

  278. Pingback: virtual card buy

  279. Pingback: cialis canadian pharmacy

  280. Pingback: ed pills

  281. Pingback: Pharmacy in Canada

  282. Pingback: delta 8 THC near me

  283. Pingback: canadian pharmacy online

  284. Pingback: viagra prescription

  285. Pingback: Workshop aggregator

  286. Pingback: guns for sale online

  287. Pingback: 20mg generic cialis

  288. Pingback: buy heroin online

  289. Pingback: clomiphene for sale

  290. Pingback: tadalafil tablets

  291. Pingback: amoxicillin 500mg cost

  292. Pingback: Vidalista 20mg

  293. Pingback: psilocybe cubensis

  294. Pingback: siamese kittens for sale near me

  295. Pingback: price of metformin 850 mg

  296. Pingback: Commercial Kitchen Cleaning Company UK

  297. Pingback: Guns for sale

  298. Pingback: SEO Services USA

發表迴響