|
Ayuda con Grafico Waterfall |
Posted by Boris on Oct-28-2011 20:34 |
|
Amigos:
Pueden ayudarme con un gr?fico waterfall.
Necesito que el grafico NO me totalice sino que vaya desde un punto a otro.
adjunto:
No se como configurar el Boxtop y BoxBottom para que me tome el primer valor del array
y el ultimo.
' The top side of the bars in a waterfall chart is the accumulated data. We use the
' ChartDirector ArrayMath utility to accumulate the data. The "total" is handled by
' inserting a zero point at the end before accumulation (after accumulation it will
' become the total).
boxTop = cd.ArrayMath(data).insert2(0, 1).acc().result()
' The botom side of the bars is just the top side of the previous bar. So we shifted
' the top side data to obtain the bottom side data.
boxBottom = cd.ArrayMath(boxTop).shift(1, 0).result()
' The last point (total) is different. Its bottom side is always 0.
'boxBottom(UBound(boxBottom)) = 0
' Create a XYChart object of size 500 x 280 pixels. Set background color to light
' blue (ccccff), with 1 pixel 3D border effect.
Set c = cd.XYChart(750, 500, &Hccccff, &H000000, 1)
' Add a title to the chart using 13 points Arial Bold Itatic font, with white
' (ffffff) text on a deep blue (0x80) background
Call c.addTitle("Variaci?n Mensual", "arialbi.ttf", 12, &Hffffff _
).setBackground(&H000080)
' Set the plotarea at (55, 50) and of size 430 x 215 pixels. Use alternative
' white/grey background.
Call c.setPlotArea(80, 50, 650, 275, &Hffffff, &Heeeeee)
' Set the labels on the x axis using Arial Bold font
Call c.xAxis().setLabels(labels).setFontStyle("arial.ttf")
Call c.xAxis().setLabelStyle("arial.ttf",7,,45)
' Set the x-axis ticks and grid lines to be between the bars
Call c.xAxis().setTickOffset(0.5)
' Use Arial Bold as the y axis label font
Call c.yAxis().setLabelStyle("arial.ttf",7)
' Add a title to the y axis
Call c.yAxis().setTitle("CLP ($ pesos)")
' Add a multi-color box-whisker layer to represent the waterfall bars
Set layer = c.addBoxWhiskerLayer2(boxTop, boxBottom)
' Put data labels on the bars to show the cash flow using Arial Bold font
Call layer.setDataLabelFormat("{={top}-{bottom}}M")
Call layer.setDataLabelStyle("arial.ttf").setAlignment(cd.Center)
' output the chart
Response.ContentType = "image/png"
Response.BinaryWrite c.makeChart2(cd.PNG)
Response.End
%> |
Re: Ayuda con Grafico Waterfall |
Posted by Boris on Oct-28-2011 23:40 |
|
Please help me
|
Re: Ayuda con Grafico Waterfall |
Posted by Peter Kwan on Oct-29-2011 01:14 |
|
Hi Boris,
As I am not familiar with Spanish, I am not too sure if I understand your question, but I will try my best.
In your case, if you do not need to have the last bar (the total), you may remove the "insert2(0, 1)" code which inserts the last bar.
boxTop = cd.ArrayMath(data).acc().result()
boxBottom = cd.ArrayMath(boxTop).shift(1, 0).result()
The boxBottom of the first bar is boxBottom(0). The boxTop of the first bar is boxTop(0). The boxBottom of the last bar is boxBottom(Ubound(boxBottom)). The boxTop of the last bar is boxTop(Ubound(boxTop)).
For example:
boxBottom(0) = boxTop(0)
Hope this can help.
Regards
Peter Kwan |
Re: Ayuda con Grafico Waterfall |
Posted by Boris on Oct-29-2011 02:18 |
|
Thanks Peter.
Please see the image
This is the graph I need to do.
I have the dates, running from the monthly 2010 to 2011 monthly
Tell me how to graph.
thanks
|
Re: Ayuda con Grafico Waterfall |
Posted by Peter Kwan on Oct-30-2011 23:46 |
|
Hi Boris,
I think the original Waterfall chart sample code in ChartDirector is already what you need. No modification is needed.
What you need is to input the data the code expects. In the sample code, the last value (the value for "Monthly 2011") is automatically computed. So you do not need to include in it your data.
If your data must contain the last value for "Monthly 2011", please remove it from your data array before passing the data to ChartDirector. For example:
'Remove last value from data, assuming data is a dynamic array
ReDim Preserve data(UBound(data) - 1)
or
'Remove last value from the data array
data = cd.ArrayMath(data).trim(0, Ubound(data)).result()
Hope this can help.
Regards
Peter Kwan |
Re: Ayuda con Grafico Waterfall |
Posted by Boris on Nov-02-2011 21:14 |
|
Thank you very much Peter.
The graph is fine now. |
Re: Ayuda con Grafico Waterfall |
Posted by Boris Villacen on Nov-08-2011 04:01 |
|
Hello Peter:
how I can change the label on the chart with the actual value of the point.
Thank
Boris
|
Re: Ayuda con Grafico Waterfall |
Posted by Boris Villacen on Nov-08-2011 23:28 |
|
Peter:
place the points with values in the graph, only the last value I can not carry it, not in the
array is a total value.
code attached,
thanks.
Boris
|
Re: Ayuda con Grafico Waterfall |
Posted by Boris Villacen on Nov-08-2011 23:32 |
|
' Put data labels on the bars to show the cash flow using Arial Bold font
Call layer.addExtraField(data)
Call layer.setDataLabelFormat("{={field0}/1000000|2.,}")
Call layer.setDataLabelStyle("arial.ttf, 8").setAlignment(cd.Bottom) |
Re: Ayuda con Grafico Waterfall |
Posted by Peter Kwan on Nov-09-2011 00:32 |
|
Hi Boris,
In the original sample code in ChartDirector, we use ={top}-{bottom}. So for your case, may be you can try:
Call layer.setDataLabelFormat("{=({top}-{bottom})/1000000|2.,}")
Call layer.setDataLabelStyle("arial.ttf, 8").setAlignment(cd.Bottom)
Hope this can help.
Regards
Peter Kwan |
Re: Ayuda con Grafico Waterfall |
Posted by Boris Villacen on Nov-09-2011 01:00 |
|
Excellent, works perfect.
Thank you very much Peter |
|