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

Message ListMessage List     Post MessagePost Message

  ExtraField in JavaScript
Posted by Thiago on Sep-03-2019 00:48
Exists any way to get the extra Field using JavaScript?

  Re: ExtraField in JavaScript
Posted by Peter Kwan on Sep-03-2019 18:39
Hi Thiago,

Yes. There is an example "Javascript Clickable Chart" included in ChartDirector that uses a number of extra fields. It demonstrates one way to access the extra fields with Javascript.

As I am not sure which programming language you are using, I just include a link to the code that comes with ChartDirector for .NET below. Similar code is available in other programming languages edition of ChartDirector as well.

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

Regards
Peter Kwan

  Re: ExtraField in JavaScript
Posted by Thiago on Sep-04-2019 23:16
Thanks for Answer, I have a another question...

Have any way to use JavaScript TrankCursor and Zoom In Zoom Out With MultiChart?

  Re: ExtraField in JavaScript
Posted by Peter Kwan on Sep-06-2019 01:58
Attachments:
Hi Thiago,

Yes, provided the charts are stacked in a MultiChart (instead of positioned side by side or randomly.).

I have just modified the original "Zooming and Scrolling with Track Line" sample code (attached with this message). The original sample code shows one chart with 3 lines. I split the lines into two charts in a MultiChart and the Zooming and Scrolling works normally.

For the track line, the original sample code draws a track line in one chart. I modified it to include a loop to draw the track line for each of the charts in the MultiChart.

A financial chart is in fact a MultiChart. You can refer to the "Finance Chart Track Line" as a reference about how to iterate the charts and draw the track lines.

Regards
Peter Kwan
multi_zoomscrolltrack.aspx
multi_zoomscrolltrack.aspx

17.89 Kb

  Re: ExtraField in JavaScript
Posted by Thiago on Sep-07-2019 02:04
I look the JavaScript console and see have this error:

Uncaught TypeError: Cannot read property 'lt6' of undefined
Uncaught TypeError: Cannot read property 'x' of undefined


And not working the trackLine And Zoom.

  Re: ExtraField in JavaScript
Posted by Thiago on Sep-07-2019 02:22
I'm syncDateAxisWithViewPort for both Single Chart, and setChartModel for the MultiChart. It`s correctly?

I'm using one line chart and 2 bar chart.
Using Java.

  Re: ExtraField in JavaScript
Posted by Peter Kwan on Sep-09-2019 14:39
Hi Thiago,

Yes, you are correct.

For the syncDateAxisWithViewPort, it applies to any XYChart that needs to zoom/scroll. In the sample code, there is only one x-axis scale, that means all these charts must use the same scale and have the same x-coordinates (eg. all must use the same array for Layer.setXData).

For the setChartModel, it should be applied to the MultiChart.

Regards
Peter Kwn

  Re: ExtraField in JavaScript
Posted by Peter Kwan on Sep-09-2019 14:35
Attachments:
Hi Thiago,

For the errors, are you using the exact sample code I attached in my last post, or have you modified them?

To avoid uncertainties, I have attached the Javascript library cdjcv.js file I am using. Please create a new directory in your web site, and put only the multi_zoomscrolltrack.aspx and the attached cdjcv.js in that directory, and access that multi_zoomscrolltrack.aspx. This ensures it is using the unmodified multi_zoomscrolltrack.aspx and also the cdjcv.js. The new directory in your site ensures the testing will not be affected by browser cache.

Regards
Peter Kwan
cdjcv.js
cdjcv.js

73.17 Kb

  Re: ExtraField in JavaScript
Posted by Thiago on Sep-09-2019 21:50
Hi Peter,

If I using your code its works with no problem, but in my code the TrankLine its works in the first Chart, the others not work and the data of the others show in the first.

  Re: ExtraField in JavaScript
Posted by Peter Kwan on Sep-09-2019 22:36
Hi Thiago,

Are you using the track line code in my example, which is specifically modified to support the MultiChart? Comparing with the basic XYChart track line code, there are the following differences:

(a) For the MultiChart, we need to add an extra loop to iterate the XYChart objects and draw tracks on them one by one.

(b) For each XYChart, all drawing coordinates need to be transformed to be relative to the  MultiChart. It is because the track line is actually drawing on the "viewer.Chart" surface, which is the MultiChart. That's why in my code, there are "+ c.getAbsOffsetY()" for the y-coordinates used for drawing. If you leave out the offset, the track line will not be drawn at the correct position.

Regards
Peter Kwan

  Re: ExtraField in JavaScript
Posted by Thiago on Sep-11-2019 22:33
Hi Peter,

IT WOOOORKS!!!!! LOL

I don't saw the loop on the JavaScript, so it didn't work, I did implement the correct JavaScript and it worked.

Thanks for Help