ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  unable to see proper charts
Posted by AC on Dec-10-2020 17:25
Attachments:
Hi Peter,

Earlier, my charts were working properly, but since I started using another machine with display resolution of 1920x1080 everything went wrong. I am attaching the image. Both
machine's OS is Windows 10 with VB 6.0 (yup you read right... its VB6.0)
Capture.jpg

  Re: unable to see proper charts
Posted by AC on Dec-10-2020 21:25
Hi Peter,

I am trying to transit to VB.net, a tough task for me at this age, as I was very much familiar with VB6. I successfully installed the demo for .net in VS 2015.

I have successfully plotted the OHLC Chart. Now while plotting a candlestick chart, I encountered an error. I am fetching data from Access. Below is the code marked with the line generating error.


            cmd = New OleDbCommand(sql, con)
            reader = cmd.ExecuteReader()
            Do While reader.Read()
                dtStr = reader(0)                     ### Error Line
                op(i) = reader(1).ToString()
                hi(i) = reader(2).ToString()


Error Message - Unable to cast object of type 'System.DateTime' to type 'System.String[]'

To set the dates as labels "dtStr" is used.

Regards
AC

  Re: unable to see proper charts
Posted by Peter Kwan on Dec-10-2020 21:45
Hi AC,

The image you attached seems to have some distortions, so I am not sure if it is the exact image you see on your screen. I seems some lines are missing (eg. one vertical and one horizontal grid lines are missing). I suspect some other lines are missing too, which causes the text to become hard to read. This may be the exact image on your screen, or it may be cause by post processing of the screen shot. (Have you resized the image when saving it or processing it?) Also, the image is in saved in JPG and have a lot JPG (which is visible when you examine the image pixel by pixel).

Anyway, for your case, I suspect the issue is due to high DPI scaling. On your Windows 10, please go to "Settings => System => Display", and check if the "Scale and Layout" is set to 100%. If it is not, please change it to 100%, and the VB6 program again. If this solves the problem, then we know the problem is due to the scale factor configuration.

VB6 is not high DPI aware. When you use VB6 is a display that is scaled larger than 100%, the OS may try to resize the VB6 display. The text may be redrawn in a larger font, but for image, it may just get stretched. (The entire chart is considered as an image.) Stretching an image makes it to look blurred. In absolute terms, the chart may not look blurrer compared to the old screen, because the high DPI blurring is compensated by the the new higher resolution screen. However, it will look blurrer than other text on the screen.

High DPI should not cause any missing lines. If the chart really has missing lines as display on the screen, it may be cause by other issues.

I assume you are looking at a screen that connects to the computer directly, and not using remote desktop or similar technologies. The remote desktop may add another source of distortion to the image.

I known in many other high DPI aware development environments, it is possible to develop a program to operate better in high DPI. I have not investigated how to do it in VB6 though.

Regards
Peter Kwan

  Re: unable to see proper charts
Posted by AC on Dec-10-2020 23:36
Hi Peter,

Thanks a lot for your reply.

The image is as it is, an exact copy of what I am able to see on my machine. No remote desktop.

Even saving to PNG didn't worked.

You are right. It seems to be the DPI issue. I have shifted to VB.net. I have mentioned in the second thread of this post. But, seems having some other issues with it. Tried some basic examples using VB.net. They worked extremely well. I don't have much experience with VB.net. No issues, google and you are here to help me out. :)

Regards
AC

  Re: unable to see proper charts
Posted by Peter Kwan on Dec-11-2020 00:07
Hi AC,

Are you trying to use the Candlestick chart sample code, or is it a FinanceChart?

https://www.advsofteng.com/doc/cdnet.htm#candlestick.htm
https://www.advsofteng.com/doc/cdnet.htm#finance2.htm

In VB, if the code expects a text string, but you pass it something else, VB may be able to convert it to a text string. In contrast, VB.NET is a strongly typed language. The data type must match.

In the Candlestick sample code, the labels array are text strings. If you read data from a database, the data type depends on your database schema. Your error message seems to suggest that your database returns a DateTime object (probably because in the database schema the column is of a Date/Time type). If dtStr is a String object, then the data type does not match, and hence the error. In this case, you must convert the DateTime to a text string before assigning it to dtStr.

dtStr = reader(0).ToString()

There are many ways to convert a DateTime to a text string. You may want to more clearly specify which format to use. See:

https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tostring?view=netframework-4.8

Regards
Peter Kwan

  Re: unable to see proper charts
Posted by AC on Dec-11-2020 02:15
Hi Peter,

I am using -

https://www.advsofteng.com/doc/cdnet.htm#candlestick.htm

Yes the field in the Database is Date/Time type.

Earlier I had used -

dtStr = reader(0).ToString()

and got -

Value type of 'String' cannot be converted to 'String()'

Won't allow to build now..

Also tried all the formats mentioned in the Microsoft's link... But resulted in the above error with little difference.


Regards
AC

  Re: unable to see proper charts
Posted by AC on Dec-11-2020 02:32
Hi Peter,


It was my fault. I corrected it. It should have been written as -

dtStr(i) = reader(0).ToString()

instead of -

dtStr = reader(0).ToString()

A silly mistake. :)


Regards
AC