Suche // Search:

09.04.2010

FormCalc Diagramme Teil 3 - Gestapeltes Säulendiagramm
//
FormCalc Charts Pt.3 - Stacked Bar Charts

Dies ist ein Upgrade zum einfachen Säulendiagramm von neulich.
Hier werden nun aus verschiedenen Eingabewerten gestapelte Säulendiagramme generiert.
Dafür kommt eine Tabelle zum Einsatz, die es erlaubt sowohl Zeilen als auch Spalten hinzuzufügen.
Die Kalkulation der Säulen übernimmt auch hier ein verstecktes Feld "Trigger", dass mit FomCalc arbeitet.

This is an Upgrade of the simple bar chart I posted on the other day.
This one generates stacked bar charts from the input values.
Therefore it uses a table that allows to add rows and columns.
The calculations of the bars is done by a hidden field "trigger" with a FormCalc script.

FormCalc Script:
var nRows = Input.Table.ChartValues.instanceManager.count

_Chart.setInstances(nRows)
var nColumns = Input.Table.ChartValues[nRows -1].Col.instanceManager.count
Chart[*].Stack._Bar[*].setInstances(nColumns)
Chart[*].Labels._Label[*].setInstances(nColumns)


for i=0 upto nRows -1 step 1 do
for j=0 upto nColumns -1 step 1 do
var BarValue = Input.Table.ChartValues[i].Col[j].Amount


var nColor = Choose(j+1, "238,0,0", ;Red
"255,48,48", ;FireBrick
"255,99,71", ;Tomato
"255,127,80", ;Coral
"255,140,0", ;DarkOrange
"255,165,0", ;Orange
"255,215,0", ;Gold
"255,255,0", ;Yellow
;"238,238,0", ;Yellow2
"154,205,50") ;YellowGreen
Chart[i].Stack.Bar[j].BarGraph.value.rectangle.fill.color.value = nColor
Chart[i].Stack.Bar[j].BarGraph.value.rectangle.edge.color.value = nColor


var ChartMod = UnitValue(BarValue, "in") / 25.4
Chart[i].Stack.Bar[j].BarGraph.h = UnitValue(ChartMod, "in")
Chart[i].Labels.Label[j].BarValue.h = UnitValue(ChartMod, "in")
Chart[i].Labels.BarTotal = Input.Table.ChartValues[i].Sum
Chart[i].Labels.BarLabel = Input.Table.ChartValues[i].Label

if(Input.Table.ChartValues[i].Col[j].Amount >= 3) then
Chart[i].Labels.Label[j].BarValue.value.text.value = Input.Table.ChartValues[i].Col[j].Amount
else
Chart[i].Labels.Label[j].BarValue.value.text.value = ""
endif


var ContainerHeight = UnitValue(Chart.h, "in")
var ChartOffset = UnitValue(Input.Table.ChartValues[i].Sum, "in") / 25.4
Chart[i].Stack.y = ContainerHeight - ChartOffset
Chart[i].Labels.y = ContainerHeight - ChartOffset - UnitValue("5mm", "in")
endfor
endfor
Gestapeltes Säulendiagramm // Stacked Bar Chart:


Beispiel
//
Example:
https://files.acrobat.com/a/preview/2d351f73-093f-44fa-9881-2fbb04ed3dc8

4 Kommentare:

  1. I am signed in to Adobe.com and the link for the data requires me to sign in, but there is no where on the page to sign in. How do I get the XML data for this example?

    AntwortenLöschen
  2. Hi,

    I can' tell you why you can't login to Acrobat.com. The link above works for me, so the problem may be related to your region.
    Anyway, the XML data isn't neccessary to work with the chart, it only contains some sample data.

    AntwortenLöschen
  3. URLs dont' work for me either, even if I am loggged in adobe.com. Could you please provide those PDF samples in other way?

    I want to learn how to implement the graphs in LiveCycle Designer. Is it possible to do them with Javascript? All the code in my form is written in Javascript

    JC

    AntwortenLöschen
  4. Hi JC,

    I've updated the links, so you're now able to download the samples again.

    AntwortenLöschen