{"id":6509,"date":"2018-09-19T09:17:48","date_gmt":"2018-09-19T09:17:48","guid":{"rendered":"https:\/\/www.anychart.com\/blog\/?p=6509"},"modified":"2018-12-27T05:18:09","modified_gmt":"2018-12-27T05:18:09","slug":"current-price-indicator-custom-value-scale-calculation-javascript-stock-charts","status":"publish","type":"post","link":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/","title":{"rendered":"Current Price Indicator with Custom Value and Scale Calculation in JavaScript Stock Charts \u2014 Challenge AnyChart!"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone size-full wp-image-6518\" src=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi.png\" alt=\"Current Price Indicator with Custom Value and Scale Calculation in JavaScript Stock Charts \u2014 Challenge AnyChart!\" width=\"100%\" srcset=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi.png 960w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi-300x178.png 300w, https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi-768x455.png 768w\" sizes=\"(max-width: 960px) 100vw, 960px\" \/>Further inspired by noteworthy questions our <a href=\"https:\/\/www.anychart.com\/support\/\">Support Team<\/a> receives from customers, we resume the <a href=\"https:\/\/www.anychart.com\/blog\/category\/challenge-anychart\/\">Challenge AnyChart!<\/a> feature, demonstrating huge flexibility of our <a href=\"https:\/\/www.anychart.com\">JavaScript (HTML5) charting libraries<\/a> and explaining how exactly you can solve advanced data visualization tasks with the help of AnyChart. Today\u2019s tutorial is about JS stock charts, and more precisely, we&#8217;ll dive into how to draw the Current Price Indicator with a custom value and make it visible even when zooming and scrolling, by utilizing Axis Markers.<\/p>\n<p><!--more--><\/p>\n<h2>Data Visualization Task<\/h2>\n<p>The question a customer wanted us to answer\u00a0was as follows:<\/p>\n<blockquote><p><em><strong>How to visualize the CPI (Current Price Indicator) with a custom value in such a way that it is visible when scrolling or zooming?<\/strong><\/em><\/p><\/blockquote>\n<p>In fact, you can make such a stock chart using our <a href=\"https:\/\/www.anychart.com\/products\/anystock\/overview\/\">AnyStock JavaScript library<\/a>. In the <a href=\"https:\/\/www.anychart.com\/blog\/2018\/07\/10\/js-chart-libraries-new-features-8-3-0-anychart\/\">8.3.0 release of AnyChart JS Charts<\/a>, it received the new Axis Marker feature which will be helpful in this case, namely the <a href=\"https:\/\/api.anychart.com\/anychart.core.stock.Plot#lineMarker\" target=\"_blank\" rel=\"nofollow\">lineMarker()<\/a>\u00a0and\u00a0<a href=\"https:\/\/api.anychart.com\/anychart.core.stock.Plot#textMarker\" target=\"_blank\" rel=\"nofollow\">textMarker()<\/a>\u00a0methods.<\/p>\n<h2>Solution Overview<\/h2>\n<p>To begin with, draw an <a href=\"https:\/\/docs.anychart.com\/Basic_Charts\/OHLC_Chart\" target=\"_blank\" rel=\"nofollow\">open-high-low-close (OHLC) series<\/a> on the chart.<\/p>\n<p>After that, create a variable with a custom value, pass it to the line and text markers, and make them visible when scrolling\u00a0and zooming.<\/p>\n<h2>Axis Markers<\/h2>\n<p>The Axis Markers feature\u00a0makes it easy to create markers and set them up as\u00a0you want.<\/p>\n<p>The first thing\u00a0you need here is to\u00a0specify a custom value like this:<\/p>\n<pre><code class=\"javascript\">var markerValue = 8200;\r\n<\/code><\/pre>\n<p>Once the value is set, it should be passed to the marker&#8217;s settings:<\/p>\n<pre><code class=\"javascript\">var lineMarker = plot.lineMarker();\r\nlineMarker\r\n .value(markerValue)\r\n .scaleRangeMode('consider');\r\n\r\nvar textMarker = plot.textMarker();\r\ntextMarker\r\n .text(markerValue)\r\n .value(markerValue)\r\n<\/code><\/pre>\n<p>The\u00a0<a href=\"https:\/\/api.anychart.com\/anychart.core.axisMarkers.Line#scaleRangeMode\" target=\"_blank\" rel=\"nofollow\">scaleRangeMode(&#8216;consider&#8217;)<\/a>\u00a0method in the code snippet above makes the marker value considered in the scale calculation,\u00a0ensuring the marker is visible no matter what data range is selected.<\/p>\n<p>That\u2019s it! Here is a <a href=\"https:\/\/playground.anychart.com\/URIOQrDV\" target=\"_blank\" rel=\"nofollow\">JavaScript (HTML5) stock chart with\u00a0the custom value-based CPI<\/a>.<\/p>\n<p><iframe loading=\"lazy\" class=\"anychart-embed anychart-embed-URIOQrDV\" src=\"https:\/\/playground.anychart.com\/URIOQrDV\/iframe\" width=\"300\" height=\"150\" frameborder=\"0\" sandbox=\"allow-scripts allow-pointer-lock allow-same-origin allow-popups allow-modals allow-forms\" allowfullscreen=\"allowfullscreen\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-URIOQrDV{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<h2>Advanced Visualization of Custom Value-Based Current Price Indicator<\/h2>\n<p>Moreover, it is possible to calculate a custom value from data. For example, you can get it as the average of the last 10 \u2018close\u2019 values, starting from the last visible one:<\/p>\n<pre><code class=\"javascript\">\/\/ advance the iterator to the next position\r\n    while (iterator.advance()) {\r\n      queue.push(iterator.get(\"close\"));\r\n      \/\/ delete all values except the last 10 \r\n      if (queue.length &gt; 10) {\r\n        queue.shift();\r\n      }\r\n      var sum = 0;\r\n      \/\/ not enough data - don't draw the axis marker\r\n      if (queue.length &lt; 10) {\r\n        value = null;\r\n      }\r\n      else {\r\n        \/\/ calculate the marker value\r\n        for (var i = 0;i &lt; queue.length; i++){\r\n          sum = sum + queue[i];\r\n        }\r\n        value = (sum\/10).toFixed(2); \r\n      }\r\n    }\r\n    return value;\r\n  }\r\n<\/code><\/pre>\n<p>Since the formula includes only the last 10 values, you should set the maximum and minimum of the X scale so they properly display the value of the Current Price Indicator:<\/p>\n<pre><code class=\"javascript\">var max = xScale.getMaximum();\r\nvar min = xScale.getFullMinimum();\r\n<\/code><\/pre>\n<p>Check out the resulting interactive visualization below. You can modify this <a href=\"https:\/\/playground.anychart.com\/ApnKw3Ib\" target=\"_blank\" rel=\"nofollow\">JS stock chart sample with the CPI based on a custom value from data<\/a>\u00a0to your liking on the AnyChart Playground.<\/p>\n<p><iframe loading=\"lazy\" class=\"anychart-embed anychart-embed-ApnKw3Ib\" src=\"https:\/\/playground.anychart.com\/ApnKw3Ib\/iframe\" width=\"300\" height=\"150\" frameborder=\"0\" sandbox=\"allow-scripts allow-pointer-lock allow-same-origin allow-popups allow-modals allow-forms\" allowfullscreen=\"allowfullscreen\"><br \/>\n<\/iframe><br \/>\n<script type=\"text\/javascript\">(function(){\nfunction ac_add_to_head(el){\n\tvar head = document.getElementsByTagName('head')[0];\n\thead.insertBefore(el,head.firstChild);\n}\nfunction ac_add_style(css){\n\tvar ac_style = document.createElement('style');\n\tif (ac_style.styleSheet) ac_style.styleSheet.cssText = css;\n\telse ac_style.appendChild(document.createTextNode(css));\n\tac_add_to_head(ac_style);\n}\nac_add_style(\".anychart-embed-ApnKw3Ib{width:100%;height:600px;}\");\n})();<\/script><\/p>\n<p>For your reference,\u00a0the code is written below:<\/p>\n<pre><code class=\"javascript\">anychart.onDocumentReady(function () {\r\n  \/\/ create a data table, load and map the data\r\n  var dataTable = anychart.data.table();\r\n  dataTable.addData(get_dji_daily_short_data());\r\n  var mapping = dataTable.mapAs({'open': 1, 'high': 2, 'low':3, 'close':4});\r\n  \r\n  \/\/ create a stock chart\r\n  var chart = anychart.stock();\r\n\r\n  \/\/ create a plot\r\n  var plot = chart.plot();\r\n  \r\n  \/\/ create an OHLC series\r\n  plot.ohlc(mapping).name(\"Price\");\r\n\r\n  \/\/ get the marker value\r\n  var markerValue = getMarkerValue();\r\n\r\n  \/\/ create a line marker\r\n  var linemarker = plot.lineMarker();\r\n  linemarker\r\n    .value(markerValue)\r\n    .stroke('black', 1)\r\n    .zIndex(100)\r\n    .scaleRangeMode('consider');\r\n\r\n  \/\/ create a text marker\r\n  var textMarker = plot.textMarker();\r\n  textMarker\r\n    .text(markerValue||'')\r\n    .value(markerValue)\r\n    .align('left')\r\n    .anchor('left-bottom')\r\n    .padding(3)\r\n    .fontColor('black')\r\n    .zIndex(100);\r\n\r\n  \/\/ display the chart\r\n  chart.container(\"container\").draw();\r\n\r\n  \/\/ recalculate the axis marker value when scrolling\r\n  chart.scroller().listen(\"scrollerchange\", function (markerValue) {\r\n\t\/\/ get the new marker value\r\n    markerValue = getMarkerValue();\r\n    \r\n    \/\/ create a line marker\r\n    linemarker.value(markerValue);\r\n\r\n    \/\/ set the text marker value and text\r\n    textMarker.text(markerValue||'').value(markerValue);\r\n  });\r\n\r\n  \/\/ get the value for the axis marker\r\n  function getMarkerValue() {\r\n    var xScale = chart.xScale();\r\n    \/\/ get the start and end dates\r\n    var max = xScale.getMaximum();\r\n    var min = xScale.getFullMinimum();\r\n\r\n    var selectable = mapping.createSelectable();\r\n    \/\/ select a date range\r\n    selectable.select(min, max);\r\n\r\n    var queue = [];\r\n    var value = null;\r\n\r\n    \/\/ get the iterator \r\n    var iterator = selectable.getIterator();\r\n    \/\/ advance the iterator to the next position\r\n    while (iterator.advance()) {\r\n      queue.push(iterator.get(\"close\"));\r\n      \/\/ delete all values except the last 10 \r\n      if (queue.length &gt; 10) {\r\n        queue.shift();\r\n      }\r\n      var sum=0;\r\n      \/\/ not enough data - don't draw the axis marker\r\n      if (queue.length &lt; 10) {\r\n        value = null;\r\n      }\r\n      else {\r\n        \/\/ calculate the marker value\r\n        for (var i = 0;i &lt; queue.length; i++){\r\n          sum = sum + queue[i];\r\n        }\r\n        value = (sum\/10).toFixed(2); \r\n      }\r\n    }\r\n    return value;\r\n  }\r\n});\r\n<\/code><\/pre>\n<hr \/>\n<p>If you have unusual tasks or questions about visualization, please share them with us at <a href=\"mailto:support@anychart.com\" target=\"_blank\" rel=\"nofollow\">support@anychart.com<\/a> with &#8220;Challenge&#8221; in the subject line. Our <a href=\"https:\/\/www.anychart.com\/support\/\">Support Team<\/a> will be glad to solve them for you, showing the power of flexible <a href=\"https:\/\/www.anychart.com\/\">AnyChart JS Charts<\/a>.<\/p>\n<p>We hope this article about drawing\u00a0the Current Price Indicator with a custom value using the Axis Markers feature in AnyStock is helpful. Feel free to ask any questions, and stay tuned for the next <a href=\"https:\/\/www.anychart.com\/blog\/category\/challenge-anychart\/\">Challenge AnyChart!<\/a> tutorials on our blog.<\/p>\n<p><!-- SyntaxHighlighter --><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/default.min.css\"><link rel=\"stylesheet\" href=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/styles\/atom-one-light.min.css\"><script src=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/highlight.js\/9.12.0\/highlight.min.js\"><\/script><script>hljs.initHighlightingOnLoad();<\/script><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Further inspired by noteworthy questions our Support Team receives from customers, we resume the Challenge AnyChart! feature, demonstrating huge flexibility of our JavaScript (HTML5) charting libraries and explaining how exactly you can solve advanced data visualization tasks with the help of AnyChart. Today\u2019s tutorial is about JS stock charts, and more precisely, we&#8217;ll dive into [&hellip;]<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,18,263,8,280,22,19,23,13,20,4],"tags":[53,93,364,35,281,258,44,363,298,54,47,32,55,36,141,81,57,58,65,56,37,248,30,172],"class_list":["post-6509","post","type-post","status-publish","format-standard","hentry","category-anychart-charting-component","category-anystock","category-big-data","category-business-intelligence","category-challenge-anychart","category-charts-and-art","category-financial-charts","category-html5","category-javascript","category-stock-charts","category-tips-and-tricks","tag-anychart","tag-anystock","tag-axis-markers","tag-business-intelligence","tag-challenge","tag-charts","tag-charts-and-art","tag-current-price-indicator","tag-custom-technical-indicators","tag-data-visualization","tag-financial-charts","tag-html5","tag-html5-charts","tag-javascript","tag-javascript-charting","tag-javascript-charting-library","tag-javascript-charts","tag-js-chart","tag-js-charting","tag-js-charts","tag-stock-charts","tag-technical-indicators","tag-tips-and-tricks","tag-tutorial","wpautop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Current Price Indicator with Custom Value and Scale Calculation in JavaScript Stock Charts \u2014 Challenge AnyChart!<\/title>\n<meta name=\"description\" content=\"JS stock chart tutorial shows how to add the Current Price Indicator with a custom value and keep it visible when zooming &amp; scrolling, by using Axis Markers\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Current Price Indicator with Custom Value and Scale Calculation in JavaScript Stock Charts \u2014 Challenge AnyChart!\" \/>\n<meta property=\"og:description\" content=\"JS stock chart tutorial shows how to add the Current Price Indicator with a custom value and keep it visible when zooming &amp; scrolling, by using Axis Markers\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/\" \/>\n<meta property=\"og:site_name\" content=\"AnyChart News\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/AnyCharts\" \/>\n<meta property=\"article:published_time\" content=\"2018-09-19T09:17:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-12-27T05:18:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi.png\" \/>\n\t<meta property=\"og:image:width\" content=\"960\" \/>\n\t<meta property=\"og:image:height\" content=\"569\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Irina Maximova\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@AnyChart\" \/>\n<meta name=\"twitter:site\" content=\"@AnyChart\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Irina Maximova\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/\"},\"author\":{\"name\":\"Irina Maximova\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/c79061b5c43d09368b8d44b36842b058\"},\"headline\":\"Current Price Indicator with Custom Value and Scale Calculation in JavaScript Stock Charts \u2014 Challenge AnyChart!\",\"datePublished\":\"2018-09-19T09:17:48+00:00\",\"dateModified\":\"2018-12-27T05:18:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/\"},\"wordCount\":498,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi.png\",\"keywords\":[\"AnyChart\",\"AnyStock\",\"axis markers\",\"Business Intelligence\",\"challenge\",\"charts\",\"Charts and Art\",\"current price indicator\",\"custom technical indicators\",\"Data Visualization\",\"Financial charts\",\"HTML5\",\"html5 charts\",\"JavaScript\",\"javascript charting\",\"JavaScript charting library\",\"javascript charts\",\"js chart\",\"js charting\",\"js charts\",\"Stock charts\",\"technical indicators\",\"Tips and tricks\",\"tutorial\"],\"articleSection\":[\"AnyChart Charting Component\",\"AnyStock\",\"Big Data\",\"Business Intelligence\",\"Challenge AnyChart!\",\"Charts and Art\",\"Financial Charts\",\"HTML5\",\"JavaScript\",\"Stock Charts\",\"Tips and Tricks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/\",\"url\":\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/\",\"name\":\"Current Price Indicator with Custom Value and Scale Calculation in JavaScript Stock Charts \u2014 Challenge AnyChart!\",\"isPartOf\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi.png\",\"datePublished\":\"2018-09-19T09:17:48+00:00\",\"dateModified\":\"2018-12-27T05:18:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/c79061b5c43d09368b8d44b36842b058\"},\"description\":\"JS stock chart tutorial shows how to add the Current Price Indicator with a custom value and keep it visible when zooming & scrolling, by using Axis Markers\",\"breadcrumb\":{\"@id\":\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#primaryimage\",\"url\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi.png\",\"contentUrl\":\"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi.png\",\"width\":960,\"height\":569},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.anychart.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Current Price Indicator with Custom Value and Scale Calculation in JavaScript Stock Charts \u2014 Challenge AnyChart!\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#website\",\"url\":\"https:\/\/www.anychart.com\/blog\/\",\"name\":\"AnyChart News\",\"description\":\"AnyChart JS Charts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.anychart.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/c79061b5c43d09368b8d44b36842b058\",\"name\":\"Irina Maximova\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/023075cf0bac635343d009a289d4c3d32138b5a3890d10f09ed59755e59bc065?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/023075cf0bac635343d009a289d4c3d32138b5a3890d10f09ed59755e59bc065?s=96&r=g\",\"caption\":\"Irina Maximova\"},\"url\":\"https:\/\/www.anychart.com\/blog\/author\/irina-maximova\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Current Price Indicator with Custom Value and Scale Calculation in JavaScript Stock Charts \u2014 Challenge AnyChart!","description":"JS stock chart tutorial shows how to add the Current Price Indicator with a custom value and keep it visible when zooming & scrolling, by using Axis Markers","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/","og_locale":"en_US","og_type":"article","og_title":"Current Price Indicator with Custom Value and Scale Calculation in JavaScript Stock Charts \u2014 Challenge AnyChart!","og_description":"JS stock chart tutorial shows how to add the Current Price Indicator with a custom value and keep it visible when zooming & scrolling, by using Axis Markers","og_url":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/","og_site_name":"AnyChart News","article_publisher":"https:\/\/www.facebook.com\/AnyCharts","article_published_time":"2018-09-19T09:17:48+00:00","article_modified_time":"2018-12-27T05:18:09+00:00","og_image":[{"width":960,"height":569,"url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi.png","type":"image\/png"}],"author":"Irina Maximova","twitter_card":"summary_large_image","twitter_creator":"@AnyChart","twitter_site":"@AnyChart","twitter_misc":{"Written by":"Irina Maximova","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#article","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/"},"author":{"name":"Irina Maximova","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/c79061b5c43d09368b8d44b36842b058"},"headline":"Current Price Indicator with Custom Value and Scale Calculation in JavaScript Stock Charts \u2014 Challenge AnyChart!","datePublished":"2018-09-19T09:17:48+00:00","dateModified":"2018-12-27T05:18:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/"},"wordCount":498,"commentCount":0,"image":{"@id":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi.png","keywords":["AnyChart","AnyStock","axis markers","Business Intelligence","challenge","charts","Charts and Art","current price indicator","custom technical indicators","Data Visualization","Financial charts","HTML5","html5 charts","JavaScript","javascript charting","JavaScript charting library","javascript charts","js chart","js charting","js charts","Stock charts","technical indicators","Tips and tricks","tutorial"],"articleSection":["AnyChart Charting Component","AnyStock","Big Data","Business Intelligence","Challenge AnyChart!","Charts and Art","Financial Charts","HTML5","JavaScript","Stock Charts","Tips and Tricks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/","url":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/","name":"Current Price Indicator with Custom Value and Scale Calculation in JavaScript Stock Charts \u2014 Challenge AnyChart!","isPartOf":{"@id":"https:\/\/www.anychart.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#primaryimage"},"image":{"@id":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#primaryimage"},"thumbnailUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi.png","datePublished":"2018-09-19T09:17:48+00:00","dateModified":"2018-12-27T05:18:09+00:00","author":{"@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/c79061b5c43d09368b8d44b36842b058"},"description":"JS stock chart tutorial shows how to add the Current Price Indicator with a custom value and keep it visible when zooming & scrolling, by using Axis Markers","breadcrumb":{"@id":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#primaryimage","url":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi.png","contentUrl":"https:\/\/www.anychart.com\/blog\/wp-content\/uploads\/2018\/09\/customcpi.png","width":960,"height":569},{"@type":"BreadcrumbList","@id":"https:\/\/www.anychart.com\/blog\/2018\/09\/19\/current-price-indicator-custom-value-scale-calculation-javascript-stock-charts\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.anychart.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Current Price Indicator with Custom Value and Scale Calculation in JavaScript Stock Charts \u2014 Challenge AnyChart!"}]},{"@type":"WebSite","@id":"https:\/\/www.anychart.com\/blog\/#website","url":"https:\/\/www.anychart.com\/blog\/","name":"AnyChart News","description":"AnyChart JS Charts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.anychart.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/c79061b5c43d09368b8d44b36842b058","name":"Irina Maximova","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.anychart.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/023075cf0bac635343d009a289d4c3d32138b5a3890d10f09ed59755e59bc065?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/023075cf0bac635343d009a289d4c3d32138b5a3890d10f09ed59755e59bc065?s=96&r=g","caption":"Irina Maximova"},"url":"https:\/\/www.anychart.com\/blog\/author\/irina-maximova\/"}]}},"_links":{"self":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/6509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/comments?post=6509"}],"version-history":[{"count":18,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/6509\/revisions"}],"predecessor-version":[{"id":7153,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/posts\/6509\/revisions\/7153"}],"wp:attachment":[{"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/media?parent=6509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/categories?post=6509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anychart.com\/blog\/wp-json\/wp\/v2\/tags?post=6509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}