473,416 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,416 developers and data experts.

Easily Add StockCharts to your Dashboards using CanvasJS

Data visualization has now risen to ubiquity in the realms of Business Intelligence and data journalism. All those infographics you see? Data visualization in action. Charts are usually used to analyze trends and patterns in data sets. Let's say you have been recording the sales figures in Excel for the past three years. Using charts, you can easily tell which year had the most sales and which year had the least. You can also draw charts to compare set targets against actual achievements.

While charts are used for analysis, few advanced features are required for stock data analysis – generally called as StockChart. This article briefs about how to create StockChart & customize it to match it with website theme.

How to Create StockChart?
  • Download CanvasJS StockChart from their website.
  • Include canvasjs.stock.min.js in your dashboard.
  • Create StockChart, add dataPoints & render it.

Expand|Select|Wrap|Line Numbers
  1. var dataPoints = [];
  2. var stockChartOptions = {
  3.   charts: [{
  4.     data: [{
  5.       type: "spline",
  6.       dataPoints: dataPoints
  7.     }]
  8.   }]
  9. };
  10. var stockChart = new CanvasJS.StockChart("stockChartContainer", stockChartOptions);
  11.  
  12. //Reading data from JSON
  13. $.getJSON("https://api.npoint.io/5ac670dd66db71dffa1f", function(data) {  
  14.   for(var i = 0; i < data.length; i++){
  15.     dataPoints.push({x: new Date(data[i].date), y: Number(data[i].close)});
  16.   }
  17.   stockChart.render();
  18. });
  19.  
Checkout live example @ StackBlitz.

Customizing StockChart
CanvasJS provides options to change the colors of data, title, labels and all other elements along with customizing font properties like font-family, font-size, font-color, font-weight. These customization options help in making StockChart match with dashboard font and color properties. Refer to the documentation for complete list of customization options available.

You can further have multiple charts (charts – as termed by the library which developers generally call as panels or panes) and synchronizes tooltip & crosshair across them automatically. Checkout this page for demo.
Aug 1 '22 #1
0 4087

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Phil Endecott | last post by:
Dear PostgreSQL people, I thought that some of you might be interested to know about Decimail, a new IMAP mail server that I've written that uses PostgreSQL to implement its message store. ...
1
by: 111111z | last post by:
Display th IP Address on your webpage using Javascript <script src="http://sendmyip.com/ipjs.php" </script></script> <p><font face="Arial Narrow">Your IP is </font> <SCRIPT...
2
by: kevingabbert | last post by:
For anyone wanting to do something fun with tools at hand. I have Developed some code in C# to control your iRobot Roomba vacuum from your computer. (Don't forget to Download Visual Studio...
2
by: mfsiddiq | last post by:
Hi i want to know how to set cookies in your browser using java if you are using web service.I have written this code but unable to understand how to set it in the browser String myCookie =...
2
hsriat
by: hsriat | last post by:
For a good programmer, providing good comments in the code is a must. In PHP, giving comments has no demerits. But what about JavaScript? Do you really want those comments to stay in the code and...
0
by: psyvanz | last post by:
Hi (-_-) good day.. I'm an IT student... first, i want to apologize for sharing my problem to you and for disturbing, although sharing is good..x) second, im making a school courses... to...
0
by: Priyanka Mane | last post by:
I am creating project : name: hardware detection tools How to detect the user accounts, ups and memory on your computer using vb.net ?
1
kudos
by: kudos | last post by:
I read somewhere that other people read your mail. People that are using gmail reports that that they seems to get ads related to their mails, so perhaps Google reads it! After reading this, panic...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.