Suche // Search:

Posts mit dem Label Flash-Surrogate werden angezeigt. Alle Posts anzeigen
Posts mit dem Label Flash-Surrogate werden angezeigt. Alle Posts anzeigen

04.01.2011

FormCalc Diagramme Teil 6 - Blasendiagramm
//
FormCalc Charts Pt.6 - Bubble Chart

Heute gibt's nochmal ein neues Diagramm von mir - das Blasendiagramm (oder auch Scatter Plot genannt).
Es hat wie die vorherigen Beispiele auch die Möglichkeit Werte von 0 bis 10000 darzustellen und sich entsprechend zu skalieren.
Im Unterschied zu den bisherigen Beispielen, wird hier neben der Y-Achse auch die X-Achse dynamisch angepasst.

Zum Darstellen mehrerer Blasen, die sich ggf. auch überlappen können, wird wieder ein positioniertes Layout verwendet, bei dem mittels eines Tricks wieder mehrere Instanzen eines Teilformulars hinzugefügt bzw. gelöscht werden können.

Die Blasen zeigen jeweils den Wert für die Größe aus der Eingabetabelle an, wobei sich die Schriftgröße entsprechend der Blasengröße ändert.

Aktualierung:
Für die Blasengröße kann nun ein Mindestwert (in Zoll) angegeben werden, sodass diese im Diagramm nicht zu klein dargestellt werden.


Once more a new chart from me - the bubble chart (or scatter plot).
Like the previous examples it can display values between 0 and 10000 and scale automatically.
The diffrence in this example is, that it can dynamically adapt both, the Y and X-axis.

To display multiple bubbles which possibly can overlay each other, we use a positioned layout, where we can add or remove instances of subforms with a trick.

Each bubble shows the value of the size from the input table, where the font size changes analog to the bubble size.

Update:
For the bubble size you now can define a minimum value (inch size), so the bubble don't get rendered to small in the chart.


FormCalc-Skript – Aktualisierte Version 1.2
//
FormCalc script – Updated version 1.2
func Render(Flag) do
 if (Flag eq "true") then 
  var FactorX  
  var FactorY  
  var FactorS  
  var MaxInputX = Max(Input.Table.ChartValues[*].AmountX)
  var MaxInputY = Max(Input.Table.ChartValues[*].AmountY)
  var MaxInputS = Max(Input.Table.ChartValues[*].AmountS)
  var Fmin
  var FmaxX
  var FmaxY
  var FmaxS
  var MinPlotSize = 0.10 
  var Control = "Plotsizes:"
 
  for Fmin = 0 upto 9950 step 50 do
   FmaxX = Fmin + 50
   if (Within(MaxInputX, Fmin, FmaxX) eq 1) then
    FactorX = 1 / (FmaxX / 100)
   endif
   FmaxY = Fmin + 50
   if (Within(MaxInputY, Fmin, FmaxY) eq 1) then
    FactorY = 1 / (FmaxY / 100)
   endif
   FmaxS = Fmin + 50
   if (Within(MaxInputS, Fmin, FmaxS) eq 1) then
    FactorS = 1 / (FmaxS / 100)
   endif
  endfor
 
  var nRows = Input.Table.ChartValues.instanceManager.count 

  var GraphLabel   
  var ContainerHeight  
  var ContainerWidth   
  var ValueX
  var ValueY
  var ValueS
  var OffsetX
  var OffsetY
  var PlotSize
 
  for r=0 upto nRows -1 step 1 do
   Chart.layout = "tb"
   Chart._Plot.setInstances(nRows)
   Chart._Label.setInstances(nRows)
   Chart.layout = "position"
   ContainerHeight = UnitValue(Chart.Raster.h, "in")
   ContainerWidth = UnitValue(Chart.Raster.w, "in")
   Chart.Plot[r].y = ContainerHeight  
    
   ValueX = Input.Table.ChartValues[r].AmountX
   ValueY = Input.Table.ChartValues[r].AmountY
   ValueS = Input.Table.ChartValues[r].AmountS
   Chart.Plot[r].presence = "visible"
   Chart.Label[r].presence = "visible"

   for x = 0 upto 9 step 1 do
    Output.Chart.xAxis.Mark[x].Mark.value.text.value = Round((1 + x) * 10 / FactorX)
    Output.Chart.xAxis.y = ContainerHeight 
   endfor 
   for y = 10 downto 0 step 1 do
    Output.yAxis.Mark[y].Mark.value.text.value = Round((10 - y) * 10 / FactorY)
   endfor 

   var nColor = Choose(r+1,     
        "238,0,0",   
        "255,99,71", 
        "255,127,80",  
        "255,140,0",  
        "255,165,0",  
        "255,215,0", 
        "255,255,0",  
        "238,238,0",  
        "154,205,50",  
        "69,139,0",  
        "0,139,0",  
        "0,139,69",  
        "69,139,116",
        "82,139,139", 
        "0,139,139", 
        "0,134,139", 
        "83,134,139",
        "102,139,139", 
        "104,131,139", 
        "108,123,139") 

   Chart.Plot[r].Bubble.value.arc.edge.color.value = nColor
   Chart.Plot[r].Bubble.value.arc.fill.color.value = nColor
   Input.Table.ChartValues[r].Color.value.rectangle.fill.color.value = nColor
   GraphLabel = Input.Table.ChartValues[r].Label
   Chart.Label[r].BubbleValue.assist.toolTip.value = GraphLabel

   PlotSize = (ValueS / 150) * FactorS
   if (PlotSize >= MinPlotSize) then
    Chart.Plot[r].Bubble.h =  PlotSize
    Chart.Plot[r].Bubble.w =  PlotSize 
    Chart.Label[r].BubbleValue.h =  PlotSize
    Chart.Label[r].BubbleValue.w =  PlotSize 
   else 
    Chart.Plot[r].Bubble.h = MinPlotSize
    Chart.Plot[r].Bubble.w = MinPlotSize
    Chart.Label[r].BubbleValue.h = MinPlotSize
    Chart.Label[r].BubbleValue.w = MinPlotSize
   endif
   
   OffsetX = UnitValue(ValueX, "in") / 25.4 * FactorX  
   OffsetY = ContainerHeight - UnitValue(ValueY, "in") / 25.4 * FactorY 

   Chart.Plot[r].x =  OffsetX 
   Chart.Plot[r].y =  OffsetY 
   Chart.Label[r].x = OffsetX 
   Chart.Label[r].y = OffsetY 
   
   Chart.Label[r].BubbleValue.value.text.value = ValueS
  endfor

 endif
 RenderChart.value = "false" 
endfunc

Render(RenderChart.value)

Blasendiagramm - mit automatischer Skalierung
//
Bubble chart - with automatic scaling




Beispiel-Formular
//
Example form
https://workspaces.acrobat.com/app.html#d=71mOKqbTBCQOGuBLaSBndg

22.12.2010

FormCalc Diagramme Teil 4-V2 - Liniendiagramm
//
FormCalc Chart Pt.4-V2 - Line Charts

Liniendiagramme sind alles andere als einfach in Designer herzustellen, aber dass es geht habe ich ja schon vor einiger Zeit gezeigt.
Die Version hatte allerdings einige Einschränkungen.
So mussten alle möglicherweise genutzten Liniem schon während der Design-Phase eingefügt werden, da es nur mit einem positionierten Layout möglich ist, Element übereinander zu legen.
Mittels eines Tricks ist das nun nicht mehr nötig.
Dafür genügen schon 4 Zeilen Code.
Kurz gesagt, sagen wir dem Formular erst, dass das Teilformular "Chart" fließend ist, was uns ermöglich von den eingeschlossenen Teilformulare "Line" und "Label" neue Instanzen anzulegen.
Dannach wird das Teilformular einfach wieder auf positioniert gesetzt, fertig.

Chart[j].layout = "tb"
Chart[j]._Line.setInstances(nRows)
Chart[j]._Label.setInstances(nRows)
Chart[j].layout = "position"

Des Weiteren ist das Diagramm auch nicht mehr auf einen kleine Darstellungsbereich beschränkt.
Mittels eines Faktors kann es Werte zwischen 0 und 10.000 dynamisch darstellen.


Line Charts aren't easy to realize in Designer, but a while ago I showed that it is still possible.
Well that version hat some restrictions.
One was, that all possibly used lines already had to added in the design phase, because only a positioned layout allows to lay element on top of each other.
With a small trick this isn't neccessary anymore.
Four lines of code are enough to do this.
In short, we tell the form that the subform "Chart" is flowing, which allows us to add more instances of the wrapped subforms "Line" und "Label".
After that, we reset the subform to positioned, done!

Chart[j].layout = "tb"
Chart[j]._Line.setInstances(nRows)
Chart[j]._Label.setInstances(nRows)
Chart[j].layout = "position"

Aditionally it is now possible to use the chart in a large value range.
With the use of a factor ist can display values between 0 and 10.000 dynamically.



Alte Hierarchie des Formulars - Jedes eventuell benötigte Objekt muss bereits vorhanden sein
//
Old hierarchy of the form - Every possibly needed object has to be already present

Neue Hierarchie des Formulars - Jedes Objekt ist erstmal nur einmalig vorhanden
//
New hierarchy of the form - Every object initially occurs only once


Neues FormCalc-Skript
//
New FormCalc script

var Check = RenderChart.value
if (Check eq "true") then
var Factor
var MaxInput = Max(Input.Table.ChartValues[*].Col[*].Amount)
var Fmin
var Fmax
for f = 0 upto 9950 step 50 do
Fmin = f
Fmax = Fmin + 50
if (Within(MaxInput, Fmin, Fmax) eq 1) then
Factor = 1 / (Fmax / 100)
endif
endfor

var nRows = Input.Table.ChartValues.instanceManager.count
var nColumns = Input.Table.ChartValues[nRows -1].Col.instanceManager.count
_Chart.setInstances(nColumns + 1)

var GraphValue
var GraphLabel
var PrevGraphValue
var GraphDiff
var LineStart
var ContainerHeight
var Offset

for r=0 upto nRows -1 step 1 do
for c=0 upto nColumns -1 step 1 do
Chart[c].layout = "tb"
Chart[c]._Line.setInstances(nRows)
Chart[c]._Label.setInstances(nRows)
Chart[c].layout = "position"
ContainerHeight = UnitValue(Chart[c].hLines.h, "in")
Chart[c].Line[r].y = ContainerHeight
GraphValue = Input.Table.ChartValues[r].Col[c].Amount
Chart[c].Line[r].presence = "visible"
Chart[c].Label[r].presence = "visible"
Chart[0].Line[r].presence = "invisible"

if(c eq 0) then
PrevGraphValue = 0
LineStart = ContainerHeight
else
PrevGraphValue = Input.Table.ChartValues[r].Col[c-1].Amount
LineStart = UnitValue(Chart[c-1].Line.LineGraph.y, "mm")
endif

for y = 10 downto 0 step 1 do
Output.yAxis.Mark[y].Mark.value.text.value = Round((10 - y) * 10 / Factor)
endfor

var nColor = Choose(r+1, ;Instance (+1) = position in this list
"238,0,0", ;Red
"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
"69,139,0", ;Chartreuse
"0,139,0", ;Green
"0,139,69", ;SpringGreen
"69,139,116", ;Aquamarine
"82,139,139", ;DarkSlateGray
"0,139,139", ;Cyan
"0,134,139") ;Turquoise
Chart[c].Line[r].LineGraph.value.line.edge.color.value = nColor
Input.Table.ChartValues[r].Color.Color.value.rectangle.fill.color.value = nColor

GraphDiff = GraphValue - PrevGraphValue
Chart[c].Line[r].LineGraph.h = UnitValue(Abs(GraphDiff), "in") / 25.4 * Factor
Chart[c].Label[r].LineValue.value.text.value = GraphValue
GraphLabel = Input.Table.ChartValues[r].Label
Chart[c].Label[r].LineValue.assist.toolTip.value = GraphLabel

if(GraphDiff >= 0) then
Chart[c].Line[r].LineGraph.value.#line.slope = "/"
else
Chart[c].Line[r].LineGraph.value.#line.slope = "\"
endif

if(c eq 0) then
Offset = ContainerHeight - UnitValue(Abs(GraphDiff), "in") / 25.4 * Factor
Chart[c].Line[r].y = Offset
Chart[c].Label[r].y = Offset
else
if(GraphDiff >= 0) then
Offset = ContainerHeight - GraphValue / 25.4 * Factor
Chart[c].Line[r].y = Offset
Chart[c].Label[r].y = Offset
else
Offset = ContainerHeight - (GraphValue + Abs(GraphDiff)) / 25.4 * Factor
Chart[c].Line[r].y = Offset
Chart[c].Label[r].y = ContainerHeight - (GraphValue / 25.4) * Factor
endif
endif
endfor
endfor
endif
RenderChart.value = "false"




Liniendiagramm - mit automatischer Größenanpassung
//
Line chart - with auto-resizing


Beispiel // Example
https://files.acrobat.com/a/preview/a3e6c8e5-5311-4219-a6f7-d7a2f2259d50

20.12.2010

FormCalc Diagramme Teil 5 - Automatisch vergrößerndes, gestapeltes Säulendiagramm
//
FormCalc Charts Pt.5 - Auto-resizing, stacked Bar Charts

Dies ist eine Weiterentwicklung von dem gestapelten Säulendiagramm, dass ich vor einiger Zeit geposted habe.
Bei dem alten Beispiel störte mich die Beschränkung auf einen bestimmten Wertebereich.
War dieser nicht ausreichend groß dimensioniert, wuchs das Diagramm mitunter oben aus dem Darstellungsbereich heraus.

Mit einer kleinen Ergänzung im Berechnungsalgoritmus ist dies nun aber kein Problem mehr.

Mittels eines Faktors kann der Wertbereich beliebig groß definiert werden.
Dafür prüft eine For-Schreife, ob das größte aller Gesamtergebnisse innerhalb eines bestimmten Bereichs liegt.
Trifft dies zu, wird dann ein Faktor anhand dieses Wertes berechnet, der später in die Berechnung der Balken einbezogen wird.

Des Weiteren wird eine Formularvariable "RenderChart" verwendet, die verhindert, dass der Trigger das Diagramm auch neu berechnet, wenn gar keine Änderung an den Eingabedaten vorliegt.
Mit einem If-Ausdruck wird das ganze Berechnungsskript umfasst und nur dann ausgeführt, wenn die Formvariable den Wert "true" hat.


This is an upgrade of the stacked bar chart I've posted a while ago.
In this old example I get bothered by the limitation of the range of values.
If it was to small the chart began to grow out of the displaying area.

But, with a small addition to the algorithm I was able to solve this problem.

With the use of a factor the range of values can be as large as you like.
Therefor a for-loop is used, which checks if the largest of all total results is within a specific range.
If so, the factor will be calculated by this value and later reused to calculate the bars.

In addition a form variable "RenderChart" is used to suppress a recalculation of the charts if there has been no changes to the input values.
With an if-expression which surrounds the whole calculation script, the script is only executed if the form variable has the value "true".

FormCalc-Skript
//
FormCalc script:

var Check = RenderChart.value
if (Check eq "true") then
var Factor
var MaxInput = Max(Input.Table.ChartValues[*].Sum)
var Fmin
var Fmax
for f = 0 upto 9950 step 50 do
Fmin = f
Fmax = Fmin + 50
if (Within(MaxInput, Fmin, Fmax) eq 1) then
Factor = 1 / (Fmax / 100)
endif
endfor

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
for y = 10 downto 0 step 1 do
Output.yAxis.Mark[y].Mark.value.text.value = Round((10 - y) * 10 / Factor)
endfor

var nColor = Choose( j + 1, ;Instance (+1) = position in this list
"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

if (BarValue > 0) then
Chart[i].Stack.Bar[j].presence = "visible"
else
Chart[i].Stack.Bar[j].presence = "invisible"
endif

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

if(BarValue * Factor >= 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 MoveHeight = UnitValue(Input.Table.ChartValues[i].Sum, "in") / 25.4 * Factor
Chart[i].Stack.y = ContainerHeight - MoveHeight
Chart[i].Labels.y = ContainerHeight - MoveHeight - UnitValue("5mm", "in")
endfor
endfor
endif


Beispiele gestapelter Balkendiagramme
//
Stacked Bar Charts Examples

Wertebereich 0 - 150 // Range of values 0 - 150


Wertebereich 0 - 550 // Range of values 0 - 550



Wertebereich 0 - 1300 // Range of values 0 - 1300




Bespiel-Formular
//
Sample form:
https://files.acrobat.com/a/preview/d9eaad0a-fea0-4303-8fd4-74a24fadb6fc