|
Decimal data types in setData |
Posted by Maurizio Porro on Dec-14-2018 07:33 |
|
Hello,
in a candlestick chart when I use
c.setData(timeStamps, highData, lowData, openData, closeData, volData, extraDays)
to manage real data parsed from a csv file from Yahoo Finance, I saw the type of data available for open, high, low, close are double[].
But how I can manage the data if they are decimal (1.34 ecc. ecc.) ??
I mean
double[] timeStamps = new double[noOfDays + 1];
decimal[] highData = new decimal[noOfDays + 1];
decimal[] lowData = new decimal[noOfDays + 1];
decimal[] openData = new decimal[noOfDays + 1];
decimal[] closeData = new decimal[noOfDays + 1];
double[] volData = new double[noOfDays + 1];
Thank you for the support.
Goodbye
Maurizio |
Re: Decimal data types in setData |
Posted by Peter Kwan on Dec-14-2018 15:39 |
|
Hi Maurizio,
From my understanding, a CSV file is a text file, so all the data are text strings. A text string can look like a number in human language, but a text string is not a number in programming language. For example, in C#, a text string in C# is of type "string", while a number can be of type "int", "double", etc..
To plot a chart, numbers are needed. You can parse the text strings into numbers using the methods of your programming language. For example, in C#, you can use Double.Parse or Double.TryParse to convert the text string into a number. See:
https://docs.microsoft.com/en-us/dotnet/api/system.double.parse?view=netframework-4.7.2
In Java, you can use Double.parseDouble
https://docs.oracle.com/javase/6/docs/api/java/lang/Double.html#parseDouble%28java.lang.String%29
Hope this can help.
Regards
Peter Kwan |
|