These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Attaching variable graph to PDF

osvaldo.rincon@...
Registered: Apr 3 2011
Posts: 1
Answered

I need to create a PDF form with a line graph that auto inputs various points based on seperate number fields from within the PDF. I was wondering if that was even possible before i attemp such a thing. I can do this in excel but would prefer a pdf format, as it is not editable by the end user. Thanks for any input.

-waldo-

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Accepted Answer
Hi,

I developed several chart types in LiveCycle Designer.
Check them out here: FormCalc Charts

You can download a sample file under: Acrobat.com

Line chart:
The script to calculate the chart is written in FormCalc:

  1. var Check = RenderChart.value
  2. if (Check eq "true") then
  3. var Factor
  4. var MaxInput = Max(Input.Table.ChartValues[*].Col[*].Amount)
  5. var Fmin
  6. var Fmax
  7. for f = 0 upto 9950 step 50 do
  8. Fmin = f
  9. Fmax = Fmin + 50
  10. if (Within(MaxInput, Fmin, Fmax) eq 1) then
  11. Factor = 1 / (Fmax / 100)
  12. endif
  13. endfor
  14.  
  15. var nRows = Input.Table.ChartValues.instanceManager.count
  16. var nColumns = Input.Table.ChartValues[nRows -1].Col.instanceManager.count
  17. _Chart.setInstances(nColumns + 1)
  18.  
  19. var GraphValue
  20. var GraphLabel
  21. var PrevGraphValue
  22. var GraphDiff
  23. var LineStart
  24. var ContainerHeight
  25. var Offset
  26.  
  27. for R=0 upto nRows -1 step 1 do
  28. for C=0 upto nColumns -1 step 1 do
  29. Chart[C].layout = "tb"
  30. Chart[C]._Line.setInstances(nRows)
  31. Chart[C]._Label.setInstances(nRows)
  32. Chart[C].layout = "position"
  33. ContainerHeight = UnitValue(Chart[C].hLines.h, "in")
  34. Chart[C].Line[R].y = ContainerHeight
  35. GraphValue = Input.Table.ChartValues[R].Col[C].Amount
  36. Chart[C].Line[R].presence = "visible"
  37. Chart[C].Label[R].presence = "visible"
  38. Chart[0].Line[R].presence = "invisible"
  39.  
  40. if(C eq 0) then
  41. PrevGraphValue = 0
  42. LineStart = ContainerHeight
  43. else
  44. PrevGraphValue = Input.Table.ChartValues[R].Col[C-1].Amount
  45. LineStart = UnitValue(Chart[C-1].Line.LineGraph.y, "mm")
  46. endif
  47.  
  48. for y = 10 downto 0 step 1 do
  49. Output.yAxis.Mark[y].Mark.value.text.value = Round((10 - y) * 10 / Factor)
  50. endfor
  51.  
  52. var nColor = Choose(R+1, ;Instance (+1) = position in this list
  53. "238,0,0",
  54. "255,99,71",
  55. "255,127,80",
  56. "255,140,0",
  57. "255,165,0",
  58. "255,215,0",
  59. "255,255,0",
  60. "238,238,0",
  61. "154,205,50",
  62. "69,139,0",
  63. "0,139,0",
  64. "0,139,69",
  65. "69,139,116",
  66. "82,139,139",
  67. "0,139,139",
  68. "0,134,139")
  69.  
  70. Chart[C].Line[R].LineGraph.value.line.edge.color.value = nColor
  71. Input.Table.ChartValues[R].Color.Color.value.rectangle.fill.color.value = nColor
  72.  
  73. GraphDiff = GraphValue - PrevGraphValue
  74. Chart[C].Line[R].LineGraph.h = UnitValue(Abs(GraphDiff), "in") / 25.4 * Factor
  75. Chart[C].Label[R].LineValue.value.text.value = GraphValue
  76. GraphLabel = Input.Table.ChartValues[R].Label
  77. Chart[C].Label[R].LineValue.assist.toolTip.value = GraphLabel
  78.  
  79. if(GraphDiff >= 0) then
  80. Chart[C].Line[R].LineGraph.value.#line.slope = "/"
  81. else
  82. Chart[C].Line[R].LineGraph.value.#line.slope = "\"
  83. endif
  84.  
  85. if(c eq 0) then
  86. Offset = ContainerHeight - UnitValue(Abs(GraphDiff), "in") / 25.4 * Factor
  87. Chart[C].Line[R].y = Offset
  88. Chart[C].Label[R].y = Offset
  89. else
  90. if(GraphDiff >= 0) then
  91. Offset = ContainerHeight - GraphValue / 25.4 * Factor
  92. Chart[C].Line[R].y = Offset
  93. Chart[C].Label[R].y = Offset
  94. else
  95. Offset = ContainerHeight - (GraphValue + Abs(GraphDiff)) / 25.4 * Factor
  96. Chart[C].Line[R].y = Offset
  97. Chart[C].Label[R].y = ContainerHeight - (GraphValue / 25.4) * Factor
  98. endif
  99. endif
  100. endfor
  101. endfor
  102. endif
  103. RenderChart.value = "false"

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs