Expand my Community achievements bar.

How to specify an angle of a circle arc

Avatar

Level 2

I am trying to replicate radzmar contribution to draw a pie chart (see http://forums.adobe.com/message/4036372)

But I want to integrate in a form I already have and use only Javascript (not FormCalc)

I have stopped trying to specify properties of the arc circles.

If I write:

var Sweep = 120;

Page.PieChart.Output.Pie[0].Bow[0].value.resolveNode("#arc").sweepAngle = Sweep;

It does not wotk. I tried also

Page.PieChart.Output.Pie[0].Bow[0].resolveNode("value.#arc").sweepAngle = Sweep;

Page.PieChart.Output.Pie[0].Bow[0].value.resolveNode("#arc.sweepAngle") = Sweep;

But they do not work.

Any quick help about it?

Same applies to other properties as startAngle and edge.color.value

J. Carlos

7 Replies

Avatar

Level 10

Hi,

in JavaScript there is not such big difference to FormCalc.

But you cannot reference objects using the accessor [], except using the resolveNode method.

xfa.resolveNode("Page.PieChart.Output.Pie[0],Bow[0]").value.arc.sweepAngle = Sweep;

Keep in mind, that the resolveNode method is slower than FormCalc so you form can become very slow if you use a lot of arcs for the pie chart.

Avatar

Level 2

Thanks radzmar for your point: the reason I use javascript instead of FormCalc is because I want to use your pie chart sample to integrate in one of my PDFs. I made some calculations with Javascript, and I do not know how to mix both codes, so I decided to continue with Javascript only.

Now, with your correction, that statement works, though xfa.resolveNode makes my code more complex, because in the loop you created I have to make another one, because Bow[*] does not work.

Besides of that, I can not get radzmar piechart code (translated into Javascript) to work. I do not know how to upload my PDF so you can see the code. Anybody can help me to upload the file and share with the community?

JC

Avatar

Level 10

Hi,

a translation into JavaScript would be a complex task and unneccessary in my mind.

The charts are calculated with a single script in the object "Trigger", so there is no risk to mix it with other scripts in your form.

You only need to change the references (som expressions) where you want to get the data from.

If those referenced fields are calculated with javascript doesn't matter for the charts.

Avatar

Level 2

Radzmar, I was not able to integrate FormCalc and Javascript codes. Perhaps it is more clear if I share my sample form: https://workspaces.acrobat.com/?d=ipGSlX8SgNPeQbgkbuZ2Ng

My idea is that with some javascript function I can generate the data needed to insert in the chart. Then, I call a routine that "draws" all lines and arcs to create the graph.

As you can see, I adapted your FC code to JS, and I can get the chart legend, but cannot see the arcs.

Do you see where is the problem?

J. Carlos

Avatar

Level 10

Hi Carlos,

I get no access to your form.

Please make sure you shared it.

Avatar

Level 2

I clicked on "share the document" in my workspace: let's see if everybody can access it

JC

Avatar

Level 2

Well, anybody had a chance to check why I can not generate the pie chart in the attached document. I took again a look to it and I can not find where is the problem.

I'll appreciate your help!

J. Carlos