ChartDirector - Professional charts for PB
ChartDirector - Professional charts for PB
Some time before, Danilo helped me to make the powerful Chartdirector component (http://www.advsofteng.com/) compatible with Purebasic.
With his explicit permission, I now want to share the include and sample files.
It is tested with PB 5.42 LTS and chart director version 5.11, both on Windows and Mac.
Note: there is a newer version of Chart director, but this may require to adapt the include file.
Possibly somebody of you have time to do this.
How to use:
Download the Chartdirector package for C++, version 5.1x from http://www.advsofteng.com/download_v511.html
This contains the required dll/lib/dylib
The source of the include can be downloaded from here:
http://www.transfernow.net/91l4o1e8f95k
Complete code is too huge to post there in the board, but probably somebody knows how to do this.
As mentioned, all credits for conversion work are entitled to Danilo !
Have fun,
Oliver
Edit: need to remove the code, for it was too large
With his explicit permission, I now want to share the include and sample files.
It is tested with PB 5.42 LTS and chart director version 5.11, both on Windows and Mac.
Note: there is a newer version of Chart director, but this may require to adapt the include file.
Possibly somebody of you have time to do this.
How to use:
Download the Chartdirector package for C++, version 5.1x from http://www.advsofteng.com/download_v511.html
This contains the required dll/lib/dylib
The source of the include can be downloaded from here:
http://www.transfernow.net/91l4o1e8f95k
Complete code is too huge to post there in the board, but probably somebody knows how to do this.
As mentioned, all credits for conversion work are entitled to Danilo !
Have fun,
Oliver
Edit: need to remove the code, for it was too large
Last edited by Oliver13 on Fri Apr 07, 2017 6:36 am, edited 3 times in total.
Re: ChartDirector - Professional charts for PB
Del
Last edited by Oliver13 on Fri Apr 07, 2017 6:33 am, edited 1 time in total.
Re: ChartDirector - Professional charts for PB
del
Last edited by Oliver13 on Fri Apr 07, 2017 6:35 am, edited 1 time in total.
Re: ChartDirector - Professional charts for PB
del
Last edited by Oliver13 on Fri Apr 07, 2017 6:34 am, edited 1 time in total.
Re: ChartDirector - Professional charts for PB
del
Last edited by Oliver13 on Fri Apr 07, 2017 6:35 am, edited 1 time in total.
Re: ChartDirector - Professional charts for PB
del
Last edited by Oliver13 on Fri Apr 07, 2017 6:34 am, edited 2 times in total.
Re: ChartDirector - Professional charts for PB
Deleted
Last edited by Oliver13 on Fri Apr 07, 2017 6:31 am, edited 2 times in total.
Re: ChartDirector - Professional charts for PB
del
Last edited by Oliver13 on Fri Apr 07, 2017 6:35 am, edited 2 times in total.
Re: ChartDirector - Professional charts for PB
del
Last edited by Oliver13 on Fri Apr 07, 2017 6:34 am, edited 2 times in total.
Re: ChartDirector - Professional charts for PB
Simple Bar Chart (1)
Original code (C++): http://www.advsofteng.com/doc/cdcpp.htm#simplebar.htm
Original code (C++): http://www.advsofteng.com/doc/cdcpp.htm#simplebar.htm
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure TheFirstProject()
Debug "TheFirstProject()"
DataSection
; The Data For the bar chart
TFP_ddat: : Data.d 85, 156, 179.5, 211, 123
; The labels For the bar chart
TFP_labels: : Data.i @"Mon", @"Tue", @"Wed", @"Thu", @"Fri"
EndDataSection
; Create a XYChart object of size 250 x 250 pixels
c.XYChart = New_XYChart(250, 250)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
; Set the plotarea at (30, 20) And of size 200 x 200 pixels
c\setPlotArea(30, 20, 200, 200)
; Add a bar chart layer using the given Data
c\addBarLayer(?TFP_ddat,5)
; Set the labels on the x axis.
xAxis.Axis = c\xAxis()
If Not xAxis : Debug "xAxis = 0" : ProcedureReturn : EndIf
xAxis\setLabels(?TFP_labels,5)
; Output the chart
c\makeChart(CD_PATH("output\001 - simplebar.png"))
; free up resources
delete(c)
EndProcedure
TheFirstProject()
Re: ChartDirector - Professional charts for PB
Sample: Polygon Bar Shapes
Original code (C++): http://www.advsofteng.com/doc/cdcpp.htm#polygonbar.htm
Original code (C++): http://www.advsofteng.com/doc/cdcpp.htm#polygonbar.htm
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Polygon_Bar_Shapes()
Debug "Polygon_Bar_Shapes()"
DataSection
; The data for the bar chart
data_036: : Data.d 85, 156, 179.5, 211, 123, 176, 195
; The labels for the bar chart
labels_036: : Data.i @"Square", @"Star(8)", @"Polygon(6)", @"Cross", @"Cross2", @"Diamond", @"Custom"
; The custom shape pattern
pattern1_036: : Data.l -500, 0, 0, 500, 500, 0, 500, 1000, 0, 500, -500, 1000
EndDataSection
; Create a XYChart object of size 500 x 280 pixels.
c.XYChart = New_XYChart(500, 280)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
; Set the plotarea at (50, 40) with alternating light grey (f8f8f8) / white
; (ffffff) background
c\setPlotArea(50, 40, 400, 200, $f8f8f8, $ffffff)
; Add a title to the chart using 14 pts Arial Bold Italic font
c\addTitle(" Bar Shape Demonstration", "arialbi.ttf", 14)
; Add a multi-color bar chart layer
layer.BarLayer = c\addBarLayer3(?data_036, 7, 0, 0)
If Not layer : Debug "layer = 0" : ProcedureReturn : EndIf
; Set layer to 3D with 10 pixels 3D depth
layer\set3D(10)
; Set bar shape to circular (cylinder)
layer\setBarShape(#Chart_CircleShape)
; Set the first bar (index = 0) to square shape
layer\setBarShape(#Chart_SquareShape, 0, 0)
; Set the second bar to 8-pointed star
layer\setBarShape(Chart_StarShape(8), 0, 1)
; Set the third bar to 6-sided polygon
layer\setBarShape(Chart_PolygonShape(6), 0, 2)
; Set the next 3 bars to cross shape, X shape and diamond shape
layer\setBarShape(Chart_CrossShape(), 0, 3)
layer\setBarShape(Chart_Cross2Shape(), 0, 4)
layer\setBarShape(#Chart_DiamondShape, 0, 5)
; Set the last bar to a custom shape, specified as an array of (x, y) points in
; normalized coordinates
layer\setBarShape2(?pattern1_036, 12, 0, 6)
; Set the labels on the x axis.
xAxis.Axis = c\xAxis()
If Not xAxis : Debug "xAxis = 0" : ProcedureReturn : EndIf
xAxis\setLabels(?labels_036, 7)
; Add a title to the y axis
yAxis.Axis = c\yAxis()
If Not yAxis : Debug "yAxis = 0" : ProcedureReturn : EndIf
yAxis\setTitle("Frequency")
; Add a title to the x axis
xAxis\setTitle("Shapes")
; Output the chart
c\makeChart(CD_PATH("output\036 - polygonbar.png"))
; free up resources
delete(c)
EndProcedure
Polygon_Bar_Shapes()
Re: ChartDirector - Professional charts for PB
Further samples:
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Uneven_Data_Points()
Debug "Uneven_Data_Points()"
; The Data For the chart
DataSection
UDP_data0Y: : Data.d 62, 69, 53, 58, 84, 76, 49, 61, 64, 77, 79
UDP_data1Y: : Data.d 36, 25, 28, 38, 20, 30, 27, 35, 65, 60, 40, 73, 62, 90, 75, 72
UDP_data2Y: : Data.d 25, 15, 30, 23, 32, 55, 45
UDP_labels: : Data.i @"Jan", @"Feb", @"Mar", @"Apr", @"May", @"Jun", @"Jul", @"Aug", @"Sep", @"Oct", @"Nov", @"Dec"
EndDataSection
; Data points which more unevenly spaced in time
Dim data0X.d(11)
data0X(0) = Chart_chartTime(2007, 1, 1)
data0X(1) = Chart_chartTime(2007, 1, 2)
data0X(2) = Chart_chartTime(2007, 1, 5)
data0X(3) = Chart_chartTime(2007, 1, 7)
data0X(4) = Chart_chartTime(2007, 1, 10)
data0X(5) = Chart_chartTime(2007, 1, 14)
data0X(6) = Chart_chartTime(2007, 1, 17)
data0X(7) = Chart_chartTime(2007, 1, 18)
data0X(8) = Chart_chartTime(2007, 1, 19)
data0X(9) = Chart_chartTime(2007, 1, 20)
data0X(10) = Chart_chartTime(2007, 1, 21)
data1Start.d = Chart_chartTime(2007, 1, 1)
data1End.d = Chart_chartTime(2007, 1, 16)
; Data points which are evenly spaced in another time range, in which the
; spacing is different from the above series
data2Start.d = Chart_chartTime(2007, 1, 9)
data2End.d = Chart_chartTime(2007, 1, 21)
; Create a XYChart object of size 600 x 400 pixels. Use a vertical gradient
; color from light Blue (99ccff) To white (ffffff) spanning the top 100 pixels
; As background. Set border To grey (888888). Use rounded corners. Enable soft
; drop shadow.
c.XYChart = New_XYChart(600, 400)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
c\setBackground( c\linearGradientColor(0, 0, 0, 100, $99ccff, $ffffff), $888888)
c\setRoundedFrame()
c\setDropShadow()
; Add a title using 18 pts Times New Roman Bold Italic font. Set top margin To
; 16 pixels.
t.TextBox = c\addTitle("Product Line Order Backlog", "timesbi.ttf", 18)
If Not t : Debug "t = 0" : ProcedureReturn : EndIf
t\setMargin(0, 0, 16,0)
; Set the plotarea at (60, 80) And of 510 x 275 pixels in size. Use transparent
; border And dark grey (444444) dotted grid lines
plotArea.PlotArea = c\setPlotArea(60, 80, 510, 275, -1, -1, #Chart_Transparent, c\dashLineColor($444444, $0101), -1)
If Not plotArea : Debug "plotArea = 0" : ProcedureReturn : EndIf
; Add a legend box where the top-center is anchored To the horizontal center of
; the plot area at y = 45. Use horizontal layout And 10 points Arial Bold font,
; And transparent background And border.
legendBox.LegendBox = c\addLegend(plotArea\getLeftX() + plotArea\getWidth() / 2, 45, #False, "arialbd.ttf", 10)
If Not legendBox : Debug "legendBox = 0" : ProcedureReturn : EndIf
legendBox\setAlignment(#Chart_TopCenter)
legendBox\setBackground(#Chart_Transparent, #Chart_Transparent)
; Set x-axis tick density To 75 pixels And y-axis tick density To 30 pixels.
; ChartDirector auto-scaling will use this As the guidelines when putting ticks
; on the x-axis And y-axis.
yAxis.Axis = c\yAxis()
If Not yAxis : Debug "yAxis = 0" : ProcedureReturn : EndIf
yAxis\setTickDensity(30)
xAxis.Axis = c\xAxis()
If Not xAxis : Debug "xAxis = 0" : ProcedureReturn : EndIf
xAxis\setTickDensity(75)
; Set all axes To transparent
xAxis\setColors(#Chart_Transparent)
yAxis\setColors(#Chart_Transparent)
; Set the x-axis margins To 15 pixels, so that the horizontal grid lines can
; extend beyond the leftmost And rightmost vertical grid lines
xAxis\setMargin(15, 15)
; Set axis label style To 8pts Arial Bold
xAxis\setLabelStyle("arialbd.ttf", 8)
yAxis\setLabelStyle("arialbd.ttf", 8)
yAxis2.Axis = c\yAxis2()
If Not yAxis2 : Debug "yAxis2 = 0" : ProcedureReturn : EndIf
yAxis2\setLabelStyle("arialbd.ttf", 8)
; Add axis title using 10pts Arial Bold Italic font
yAxis\setTitle("Backlog in USD millions", "arialbi.ttf", 10)
; Add the first Data series
layer0.LineLayer = c\addLineLayer2()
If Not layer0 : Debug "layer0 = 0" : ProcedureReturn : EndIf
dataset.Dataset = layer0\addDataSet(?UDP_data0Y, 11, $ff0000, "Quantum Computer")
If Not dataset : Debug "dataset = 0" : ProcedureReturn : EndIf
dataset\setDataSymbol(#Chart_GlassSphere2Shape, 11)
layer0\setXData( @data0X(0), ArraySize(data0X()) )
layer0\setLineWidth(3)
; Add the second Data series
layer1.LineLayer = c\addLineLayer2()
If Not layer1 : Debug "layer1 = 0" : ProcedureReturn : EndIf
dataset = layer1\addDataSet(?UDP_data1Y, 16, $00ff00, "Atom Synthesizer")
If Not dataset : Debug "dataset = 0" : ProcedureReturn : EndIf
dataset\setDataSymbol(#Chart_GlassSphere2Shape, 11)
layer1\setXData2(data1Start, data1End)
layer1\setLineWidth(3);
; Add the third Data series
layer2.LineLayer = c\addLineLayer2()
If Not layer2 : Debug "layer2 = 0" : ProcedureReturn : EndIf
dataset = layer2\addDataSet(?UDP_data2Y, 7, $ff6600, "Proton Cannon")
If Not dataset : Debug "dataset = 0" : ProcedureReturn : EndIf
dataset\setDataSymbol(#Chart_GlassSphere2Shape, 11)
layer2\setXData2(data2Start, data2End)
layer2\setLineWidth(3)
; Output the chart
c\makeChart(CD_PATH("output\062 - unevenpoints.png"))
; free up resources
delete (c)
EndProcedure
Uneven_Data_Points()
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Bubble_Chart_3D_2()
Debug "Bubble_Chart_3D_2()"
DataSection
; The XYZ points for the bubble chart
dataX0_084: : Data.d 170, 300, 1000, 1700
dataY0_084: : Data.d 16, 69, 16, 75
dataZ0_084: : Data.d 52, 105, 88, 140
dataX1_084: : Data.d 500, 1000, 1300
dataY1_084: : Data.d 40, 58, 85
dataZ1_084: : Data.d 140, 202, 84
EndDataSection
; Create a XYChart object of size 540 x 480 pixels
c.XYChart = New_XYChart(540, 480)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
; Set the plotarea at (70, 65) and of size 400 x 350 pixels. Turn on both
; horizontal and vertical grid lines with light grey color ($c0c0c0)
c\setPlotArea(70, 65, 400, 350, -1, -1, #Chart_Transparent, $c0c0c0, -1)
; Add a legend box at (70, 30) (top of the chart) with horizontal layout. Use 12
; pts Times Bold Italic font. Set the background and border color to
; Transparent.
legend.LegendBox = c\addLegend(70, 30, #False, "timesbi.ttf", 12)
If Not legend : Debug "legend = 0" : ProcedureReturn : EndIf
legend\setBackground(#Chart_Transparent)
; Add a title to the chart using 18 pts Times Bold Itatic font.
c\addTitle("Product Comparison Chart", "timesbi.ttf", 18)
; Add titles to the axes using 12 pts Arial Bold Italic font
yAxis.Axis = c\yAxis()
If Not yAxis : Debug "yAxis = 0" : ProcedureReturn : EndIf
yAxis\setTitle("Capacity (tons)", "arialbi.ttf", 12)
xAxis.Axis = c\xAxis()
If Not xAxis : Debug "xAxis = 0" : ProcedureReturn : EndIf
xAxis\setTitle("Range (miles)", "arialbi.ttf", 12)
; Set the axes line width to 3 pixels
xAxis\setWidth(3)
yAxis\setWidth(3)
; Add (dataX0, dataY0) as a scatter layer with red (ff3333) glass spheres, where
; the sphere size is modulated by dataZ0. This creates a bubble effect.
layer.ScatterLayer = c\addScatterLayer(?dataX0_084, 4, ?dataY0_084, 4, "Technology AAA", #Chart_GlassSphere2Shape, 15, $ff3333)
If Not layer : Debug "layer = 0" : ProcedureReturn : EndIf
layer\setSymbolScale(?dataZ0_084, 4)
; Add (dataX1, dataY1) as a scatter layer with blue (0000ff) glass spheres,
; where the sphere size is modulated by dataZ1. This creates a bubble effect.
layer = c\addScatterLayer(?dataX1_084, 3, ?dataY1_084, 3, "Technology BBB", #Chart_GlassSphere2Shape, 15, $0000ff)
If Not layer : Debug "layer = 0" : ProcedureReturn : EndIf
layer\setSymbolScale(?dataZ1_084, 3)
; Output the chart
c\makeChart(CD_PATH("output\084 - threedbubble2.png"))
; free up resources
delete(c)
EndProcedure
Bubble_Chart_3D_2()
Re: ChartDirector - Professional charts for PB
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Marks_and_Zones_2()
Debug "Marks_and_Zones_2()"
DataSection
; The data for the chart
data_115: : Data.d 50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, 59, 73, 77, 84, 82, 80, 84, 89
EndDataSection
; The labels for the chart. Note the "-" means a minor tick.
Dim labels.s(25)
For i = 0 To 24 : labels(i) = Str(i) : Next
labels( 0) = "0"+#LF$+"Jun 4"
labels(24) = "0"+#LF$+"Jun 5"
; Create a XYChart object of size 400 x 270 pixels
c.XYChart = New_XYChart(400, 270)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
; Set the plotarea at (80, 25) and of size 300 x 200 pixels. Use alternate color
; background ($eeeeee) and ($ffffff). Set border and grid colors to grey
; ($c0c0c0).
c\setPlotArea(50, 25, 300, 200, $eeeeee, $ffffff, $c0c0c0, $c0c0c0, $c0c0c0)
; Add a title to the chart using 14 pts Times Bold Italic font
c\addTitle("Server Monitor", "timesbi.ttf", 14)
; Add a title to the y axis
yAxis.Axis = c\yAxis()
If Not yAxis : Debug "yAxis = 0" : ProcedureReturn : EndIf
yAxis\setTitle("Server Load (MBytes)")
; Set the y axis width to 2 pixels
yAxis\setWidth(2)
; Set the labels on the x axis.
xAxis.Axis = c\xAxis()
If Not xAxis : Debug "xAxis = 0" : ProcedureReturn : EndIf
xAxis\setLabels(@labels(), ArraySize(labels()))
; Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining
; labels.
xAxis\setLabelStep(3, 1)
; Set the x axis width to 2 pixels
xAxis\setWidth(2)
; Add a horizontal red ($800080) mark line at y = 80
yMark.Mark = yAxis\addMark(80, $ff0000, "Critical Threshold Set Point")
If Not yMark : Debug "yMark = 0" : ProcedureReturn : EndIf
; Set the mark line width to 2 pixels
yMark\setLineWidth(2)
; Put the mark label at the top center of the mark line
yMark\setAlignment(#Chart_TopCenter)
; Add an orange ($ffcc66) zone from x = 18 to x = 20
xAxis\addZone(18, 20, $ffcc66)
; Add a vertical brown ($995500) mark line at x = 18
xMark1.Mark = xAxis\addMark(18, $995500, "Backup Start")
If Not xMark1 : Debug "xMark1 = 0" : ProcedureReturn : EndIf
; Set the mark line width to 2 pixels
xMark1\setLineWidth(2)
; Put the mark label at the left of the mark line
xMark1\setAlignment(#Chart_Left)
; Rotate the mark label by 90 degrees so it draws vertically
xMark1\setFontAngle(90)
; Add a vertical brown ($995500) mark line at x = 20
xMark2.Mark = xAxis\addMark(20, $995500, "Backup End")
If Not xMark2 : Debug "xMark2 = 0" : ProcedureReturn : EndIf
; Set the mark line width to 2 pixels
xMark2\setLineWidth(2)
; Put the mark label at the right of the mark line
xMark2\setAlignment(#Chart_Right)
; Rotate the mark label by 90 degrees so it draws vertically
xMark2\setFontAngle(90)
; Add a green ($00cc00) line layer with line width of 2 pixels
layer.LineLayer = c\addLineLayer(?data_115, 25, $00cc00)
If Not layer : Debug "layer = 0" : ProcedureReturn : EndIf
layer\setLineWidth(2)
; Output the chart
c\makeChart(CD_PATH("output\115 - markzone2.png"))
; free up resources
delete(c)
EndProcedure
Marks_and_Zones_2()
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Surface_Chart_3()
Debug "Surface_Chart_3()"
; The x and y coordinates of the grid
Dim dataX.d(21) : For i = 0 To 20 : dataX(i) = i-10 : Next
Dim dataY.d(21) : For i = 0 To 20 : dataY(i) = i-10 : Next
; The values at the grid points. In this example, we will compute the values
; using the formula z = Sin(x * x / 128 - y * y / 256 + 3) * Cos(x / 4 + 1 -
; Exp(y / 8))
Dim dataZ.d(ArraySize(dataX())*ArraySize(dataY()))
For yIndex = 0 To ArraySize(dataY())-1
y.d = dataY(yIndex)
For xIndex = 0 To ArraySize(dataX())-1
x.d = dataX(xIndex)
dataZ(yIndex * ArraySize(dataX()) + xIndex) = Sin(x * x / 128.0 - y * y / 256.0 + 3) * Cos(x / 4.0 + 1 - Exp(y / 8.0))
Next xIndex
Next yIndex
; Create a SurfaceChart object of size 750 x 600 pixels
c.SurfaceChart = New_SurfaceChart(750, 600)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
; Add a title to the chart using 20 points Times New Roman Italic font
c\addTitle("Surface Energy Density ", "timesi.ttf", 20)
; Set the center of the plot region at (380, 260), and set width x depth x
; height to 360 x 360 x 270 pixels
c\setPlotRegion(380, 260, 360, 360, 270)
; Set the elevation and rotation angles to 30 and 210 degrees
c\setViewAngle(30, 210)
; Set the perspective level to 60
c\setPerspective(60)
; Set the data to use to plot the chart
c\setData(@dataX(), ArraySize(dataX()), @dataY(), ArraySize(dataY()), @dataZ(), ArraySize(dataZ()))
; Spline interpolate data to a 80 x 80 grid for a smooth surface
c\setInterpolation(80, 80)
; Use semi-transparent black (c0000000) for x and y major surface grid lines.
; Use dotted style for x and y minor surface grid lines.
majorGridColor.l = $c0000000
minorGridColor.l = c\dashLineColor(majorGridColor, #Chart_DotLine)
c\setSurfaceAxisGrid(majorGridColor, majorGridColor, minorGridColor, minorGridColor)
; Set contour lines to semi-transparent white (80ffffff)
c\setContourColor($80ffffff)
; Add a color axis (the legend) in which the left center is anchored at (665,
; 280). Set the length to 200 pixels and the labels on the right side.
c\setColorAxis(665, 280, #Chart_Left, 200, #Chart_Right)
; Set the x, y and z axis titles using 12 points Arial Bold font
xAxis.Axis = c\xAxis() : If Not xAxis : Debug "xAxis = 0" : ProcedureReturn : EndIf
xAxis\setTitle("X Title"+#LF$+"Placeholder", "arialbd.ttf", 12)
yAxis.Axis = c\yAxis() : If Not yAxis : Debug "yAxis = 0" : ProcedureReturn : EndIf
yAxis\setTitle("Y Title"+#LF$+"Placeholder", "arialbd.ttf", 12)
zAxis.Axis = c\zAxis() : If Not zAxis : Debug "zAxis = 0" : ProcedureReturn : EndIf
zAxis\setTitle("Z Title Placeholder", "arialbd.ttf", 12)
; Output the chart
c\makeChart(CD_PATH("output\131 - surface3.jpg"))
; free up resources
delete(c)
EndProcedure
Surface_Chart_3()
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Scatter_Groups_3D()
Debug "Scatter_Groups_3D()"
; The random XYZ data for the first 3D scatter group
r0.RanSeries = New_RanSeries(7)
If Not r0 : Debug "r0 = 0" : ProcedureReturn : EndIf
*xData0 = r0\getSeries(@xData0Len.l, 100, 100, -10, 10)
*yData0 = r0\getSeries(@yData0Len.l, 100, 0, 0, 20)
*zData0 = r0\getSeries(@zData0Len.l, 100, 100, -10, 10)
; The random XYZ data for the second 3D scatter group
r1.RanSeries = New_RanSeries(4)
If Not r1 : Debug "r1 = 0" : ProcedureReturn : EndIf
*xData1 = r1\getSeries(@xData1Len.l, 100, 100, -10, 10)
*yData1 = r1\getSeries(@yData1Len.l, 100, 0, 0, 20)
*zData1 = r1\getSeries(@zData1Len.l, 100, 100, -10, 10)
; The random XYZ data for the third 3D scatter group
r2.RanSeries = New_RanSeries(8)
If Not r2 : Debug "r2 = 0" : ProcedureReturn : EndIf
*xData2 = r2\getSeries(@xData2Len.l, 100, 100, -10, 10)
*yData2 = r2\getSeries(@yData2Len.l, 100, 0, 0, 20)
*zData2 = r2\getSeries(@zData2Len.l, 100, 100, -10, 10)
; Create a ThreeDScatterChart object of size 800 x 520 pixels
c.ThreeDScatterChart = New_ThreeDScatterChart(800, 520)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
; Add a title to the chart using 20 points Times New Roman Italic font
c\addTitle("3D Scatter Groups ", "timesi.ttf", 20)
; Set the center of the plot region at (350, 240), and set width x depth x
; height to 360 x 360 x 270 pixels
c\setPlotRegion(350, 240, 360, 360, 270)
; Set the elevation and rotation angles to 15 and 30 degrees
c\setViewAngle(15, 30)
; Add a legend box at (640, 180)
c\addLegend(640, 180)
; Add 3 scatter groups to the chart with 9 pixels glass sphere symbols of red
; (ff0000), green (00ff00) and blue (0000ff) colors
c\addScatterGroup(*xData0, xData0Len, *yData0, yData0Len, *zData0, zData0Len, "Alpha", #Chart_GlassSphere2Shape, 9, $ff0000)
c\addScatterGroup(*xData1, xData1Len, *yData1, yData1Len, *zData1, zData1Len, "Beta" , #Chart_GlassSphere2Shape, 9, $00ff00)
c\addScatterGroup(*xData2, xData2Len, *yData2, yData2Len, *zData2, zData2Len, "Gamma", #Chart_GlassSphere2Shape, 9, $0000ff)
; Set the x, y and z axis titles
xAxis.Axis = c\xAxis() : If Not xAxis : Debug "xAxis = 0" : ProcedureReturn : EndIf
xAxis\setTitle("X-Axis Place Holder")
yAxis.Axis = c\yAxis() : If Not yAxis : Debug "yAxis = 0" : ProcedureReturn : EndIf
yAxis\setTitle("Y-Axis Place Holder")
zAxis.Axis = c\zAxis() : If Not zAxis : Debug "zAxis = 0" : ProcedureReturn : EndIf
zAxis\setTitle("Z-Axis Place Holder")
; Output the chart
c\makeChart(CD_PATH("output\140 - threedscattergroups.png"))
; free up resources
delete(r0)
delete(r1)
delete(r2)
delete(c)
EndProcedure
Scatter_Groups_3D()
Re: ChartDirector - Professional charts for PB
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Polar_Line_Chart()
Debug "Polar_Line_Chart()"
DataSection
; The data for the chart
data0_145: : Data.d 90, 25, 40, 55, 68, 44, 79, 85, 50
angles0_145: : Data.d 15, 60, 110, 180, 230, 260, 260, 310, 340
data1_145: : Data.d 80, 91, 66, 80, 92, 87
angles1_145: : Data.d 40, 65, 88, 110, 150, 200
EndDataSection
; Create a PolarChart object of size 460 x 500 pixels, with a grey (e0e0e0)
; background and 1 pixel 3D border
c.PolarChart = New_PolarChart(460, 500, $e0e0e0, $000000, 1)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
; Add a title to the chart at the top left corner using 15pts Arial Bold Italic
; font. Use a wood pattern as the title background.
title.TextBox = c\addTitle("Polar Line Chart Demo", "arialbi.ttf", 15)
If Not title : Debug "title = 0" : ProcedureReturn : EndIf
title\setBackground(c\patternColor2("wood.png"))
; Set center of plot area at (230, 280) with radius 180 pixels, and white
; (ffffff) background.
c\setPlotArea(230, 280, 180, $ffffff)
; Set the grid style to circular grid, with grids below the chart layers
c\setGridStyle(#False, #False)
; Add a legend box at top-center of plot area (230, 35) using horizontal layout.
; Use 10 pts Arial Bold font, with 1 pixel 3D border effect.
b.LegendBox = c\addLegend(230, 35, #False, "arialbd.ttf", 9)
If Not b : Debug "b = 0" : ProcedureReturn : EndIf
b\setAlignment(#Chart_TopCenter)
b\setBackground(#Chart_Transparent, #Chart_Transparent, 1)
; Set angular axis as 0 - 360, with a spoke every 30 units
aAxis.AngularAxis = c\angularAxis()
If Not aAxis : Debug "aAxis = 0" : ProcedureReturn : EndIf
aAxis\setLinearScale(0, 360, 30)
; Add a blue ($ff) line layer to the chart using (data0, angle0)
layer0.PolarLineLayer = c\addLineLayer(?data0_145, 9, $0000ff, "Close Loop Line")
If Not layer0 : Debug "layer0 = 0" : ProcedureReturn : EndIf
layer0\setAngles(?angles0_145, 9)
; Set the line width to 2 pixels
layer0\setLineWidth(2)
; Use 11 pixel triangle symbols for the data points
layer0\setDataSymbol(#Chart_TriangleSymbol, 11)
; Enable data label and set its format
layer0\setDataLabelFormat("({value},{angle})")
; Set the data label text box with light blue ($9999ff) backgruond color and 1
; pixel 3D border effect
ls.TextBox = layer0\setDataLabelStyle()
If Not ls : Debug "ls = 0" : ProcedureReturn : EndIf
ls\setBackground($9999ff, #Chart_Transparent, 1)
; Add a red ($ff0000) line layer to the chart using (data1, angle1)
layer1.PolarLineLayer = c\addLineLayer(?data1_145, 6, $ff0000, "Open Loop Line")
If Not layer1 : Debug "layer1 = 0" : ProcedureReturn : EndIf
layer1\setAngles(?angles1_145, 6)
; Set the line width to 2 pixels
layer1\setLineWidth(2)
; Use 11 pixel diamond symbols for the data points
layer1\setDataSymbol(#Chart_DiamondSymbol, 11)
; Set the line to open loop
layer1\setCloseLoop(#False)
; Enable data label and set its format
layer1\setDataLabelFormat("({value},{angle})")
; Set the data label text box with light red ($ff9999) backgruond color and 1
; pixel 3D border effect
ls = layer1\setDataLabelStyle()
If Not ls : Debug "ls = 0" : ProcedureReturn : EndIf
ls\setBackground($ff9999, #Chart_Transparent, 1)
; Output the chart
c\makeChart(CD_PATH("output\145 - polarline.png"))
; free up resources
delete(c)
EndProcedure
Polar_Line_Chart()
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Funnel_Chart()
Debug "Funnel_Chart()"
DataSection
; The data for the pyramid chart
data_159: : Data.d 156, 123, 211, 179
; The labels for the pyramid chart
labels_159: : Data.i @"Corporate Tax", @"Working Capital", @"Re-investment", @"Dividend"
; The colors for the pyramid layers
colors_159: : Data.l $66aaee, $eebb22, $cccccc, $cc88ff
EndDataSection
; Create a PyramidChart object of size 500 x 400 pixels
c.PyramidChart = New_PyramidChart(500, 400)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
; Set the funnel center at (200, 210), and width x height to 150 x 300 pixels
c\setFunnelSize(200, 210, 150, 300)
; Set the elevation to 5 degrees
c\setViewAngle(5)
; Set the pyramid data and labels
c\setData(?data_159, 4, ?labels_159, 4)
; Set the layer colors to the given colors
c\setColors(#Chart_DataColor, ?colors_159, 4)
; Leave 1% gaps between layers
c\setLayerGap(0.01)
; Add labels at the right side of the pyramid layers using Arial Bold font. The
; labels will have 3 lines showing the layer name, value and percentage.
c\setRightLabel("{label}"+#LF$+"US ${value}K"+#LF$+"({percent}%)", "arialbd.ttf")
; Output the chart
c\makeChart(CD_PATH("output\159 - funnel.png"))
; free up resources
delete(c)
EndProcedure
Funnel_Chart()
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Horizontal_Linear_Meter()
Debug "Horizontal_Linear_Meter()"
; The value to display on the meter
Protected value.d = 75.35
; Create an LinearMeter object of size 250 x 75 pixels, using silver background
; with a 2 pixel black 3D depressed border.
m.LinearMeter = New_LinearMeter(250, 75, Chart_silverColor(), 0, -2)
If Not m : Debug "m = 0" : ProcedureReturn : EndIf
; Set the scale region top-left corner at (15, 25), with size of 200 x 50
; pixels. The scale labels are located on the top (implies horizontal meter)
m\setMeter(15, 25, 220, 20, #Chart_Top)
; Set meter scale from 0 - 100, with a tick every 10 units
m\setScale(0, 100, 10)
; Set 0 - 50 as green (99ff99) zone, 50 - 80 as yellow (ffff66) zone, and 80 -
; 100 as red (ffcccc) zone
m\addZone(0, 50, $99ff99)
m\addZone(50, 80, $ffff66)
m\addZone(80, 100, $ffcccc)
; Add a blue (0000cc) pointer at the specified value
m\addPointer(value, $0000cc)
; Add a label at bottom-left (10, 68) using Arial Bold/8 pts/red (c00000)
m\addText(10, 68, "Temperature C", "arialbd.ttf", 8, $c00000, #Chart_BottomLeft)
; Add a text box to show the value formatted to 2 decimal places at bottom
; right. Use white text on black background with a 1 pixel depressed 3D border.
t.TextBox = m\addText(238, 70, m\formatValue(value, "2"), "arial.ttf", 8, $ffffff, #Chart_BottomRight)
If Not t : Debug "t = 0" : ProcedureReturn : EndIf
t\setBackground(0, 0, -1)
; Output the chart
m\makeChart(CD_PATH("output\169 - hlinearmeter.png"))
; free up resources
delete(m)
EndProcedure
Horizontal_Linear_Meter()
So, now enough for today...
Re: ChartDirector - Professional charts for PB
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Text_Styles_and_Colors()
Debug "Text_Styles_and_Colors()"
DataSection
; The data for the pie chart
data_022: : Data.d 25, 18, 15, 12, 8, 30, 35
; The labels for the pie chart
labels_022: : Data.i @"Labor", @"Licenses", @"Taxes", @"Legal", @"Insurance", @"Facilities", @"Production"
EndDataSection
; Create a PieChart object of size 480 x 300 pixels
c.PieChart = New_PieChart(480, 300)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
; Use a blue marble pattern as the background wallpaper, with a black border,
; and 1 pixel 3D border effect
c\setBackground(c\patternColor2("marble.png"), $000000, 1)
; Set the center of the pie at (150, 150) and the radius to 100 pixels
c\setPieSize(150, 150, 100)
; Add a title to the pie chart using Times Bold Italic/15 points/deep blue
; (0x000080) as font, with a wood pattern as the title background
title.TextBox = c\addTitle("Project Cost Breakdown", "timesbi.ttf", 15, $000080)
If Not title : Debug "title = 0" : ProcedureReturn : EndIf
title\setBackground(c\patternColor2("wood.png"))
; Draw the pie in 3D
c\set3D()
; Add a legend box using Arial Bold Italic/11 points font. Use a pink marble
; pattern as the background wallpaper, with a 1 pixel 3D border. The legend box
; is top-right aligned relative to the point (465, 70)
b.LegendBox = c\addLegend(465, 70, #True, "arialbi.ttf", 11)
If Not b : Debug "b = 0" : ProcedureReturn : EndIf
b\setBackground(c\patternColor2("marble2.png"), #Chart_Transparent, 1)
b\setAlignment(#Chart_TopRight)
; Set the default font for all sector labels to Arial Bold/8 pts/dark green
; (0x008000).
c\setLabelStyle("arialbd.ttf", 8, $008000)
; Set the pie data and the pie labels
c\setData(?data_022, 7, ?labels_022, 7)
; Explode the 3rd sector
c\setExplode(2, 40)
; Use Arial Bold/12 pts/red as label font for the 3rd sector
sector.Sector = c\sector(2)
If Not sector : Debug "sector = 0" : ProcedureReturn : EndIf
sector\setLabelStyle("arialbd.ttf", 12, $ff0000)
; Use Arial/8 pts/deep blue as label font for the 5th sector. Add a background
; box using the sector fill color (SameAsMainColor), with a black (0x000000)
; edge and 2 pixel 3D border.
sector = c\sector(4)
If Not sector : Debug "sector = 0" : ProcedureReturn : EndIf
t.TextBox = sector\setLabelStyle("arial.ttf", 8, $000080)
If Not t : Debug "t = 0" : ProcedureReturn : EndIf
t\setBackground(#Chart_SameAsMainColor, $000000, 2)
; Use Arial Italic/8 pts/light red (0xff9999) as label font for the 6th sector.
; Add a dark blue (0x000080) background box with a 2 pixel 3D border.
sector = c\sector(0)
If Not sector : Debug "sector = 0" : ProcedureReturn : EndIf
t = sector\setLabelStyle("ariali.ttf", 8, $ff9999)
If Not t : Debug "t = 0" : ProcedureReturn : EndIf
t\setBackground($000080, #Chart_Transparent, 2)
; Use Times Bold Italic/8 pts/deep green (0x008000) as label font for 7th
; sector. Add a yellow (0xFFFF00) background box with a black (0x000000) edge.
sector = c\sector(6)
If Not sector : Debug "sector = 0" : ProcedureReturn : EndIf
t = sector\setLabelStyle("timesbi.ttf", 8, $008000)
If Not t : Debug "t = 0" : ProcedureReturn : EndIf
t\setBackground($ffff00, $000000)
; Output the chart
c\makeChart(CD_PATH("output\022 - fontpie.jpg"))
; free up resources
delete(c)
EndProcedure
Text_Styles_and_Colors()
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Donut_Chart_3D()
Debug "Donut_Chart_3D()"
DataSection
; The data for the pie chart
ddat_014: : Data.d 20, 10, 15, 12
; The labels For the pie chart
labels_014: : Data.i @"Labor", @"Licenses", @"Facilities", @"Production"
; The colors to use for the sectors
colors_014: : Data.l $66aaee, $eebb22, $cccccc, $cc88ff
EndDataSection
; Create a PieChart object of size 600 x 320 pixels. Use a vertical gradient
; color from deep blue (000066) to blue (0000cc) as background. Use rounded
; corners of 20 pixels radius.
c.PieChart = New_PieChart(600, 320)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
c\setBackground(c\linearGradientColor(0, 0, 0, c\getHeight(), $000066, $0000cc))
c\setRoundedFrame($ffffff, 20)
; Add a title using 18 pts Times New Roman Bold Italic font in white (ffffff)
; color. Set top/bottom margins to 8 pixels.
title.TextBox = c\addTitle("Donut Chart Demonstration", "timesbi.ttf", 18, $ffffff)
If Not title : Debug "title = 0" : ProcedureReturn : EndIf
title\setMargin(0, 0, 8, 8)
; Add a separator line in white color just under the title
c\addLine(10, title\getHeight(), c\getWidth() - 11, title\getHeight(), $ffffff)
; Set donut center at (300, 170), and outer/inner radii as 120/60 pixels
c\setDonutSize(300, 170, 120, 60)
; Draw the pie in 3D with a pie thickness of 25 pixels
c\set3D(25)
; Set the pie data and the pie labels
c\setData(?ddat_014, 4, ?labels_014, 4)
; Set the sector colors
c\setColors(#Chart_DataColor, ?colors_014, 4)
; Use local gradient shading for the sectors
c\setSectorStyle(#Chart_LocalGradientShading)
; Set sector border color to same as fill color. Set label join line color to
; white (ffffff)
c\setLineColor(#Chart_SameAsMainColor, $ffffff)
; Use the side label layout method, with the labels positioned 16 pixels from
; the donut bounding box
c\setLabelLayout(#Chart_SideLayout, 16)
; Set the sector label format. The label consists of two lines. The first line
; is the sector name in Times Bold Italic font and is underlined. The second
; line shows the data value and percentage.
c\setLabelFormat("<*block,halign=left*><*font=timesbi.ttf,size=12,underline=1*>{label}<*/font*><*br*>US$ {value}K ({percent}%)")
; Set the label box background color the same as the sector color. Use soft
; lighting effect with light direction from right. Use rounded corners.
t.TextBox = c\setLabelStyle()
If Not t : Debug "t = 0" : ProcedureReturn : EndIf
t\setBackground(#Chart_SameAsMainColor, #Chart_Transparent, Chart_softLighting(#Chart_Right))
t\setRoundedCorners()
; Output the chart
c\makeChart(CD_PATH("output\014 - threeddonut.png"))
; free up resources
delete(c)
EndProcedure
Donut_Chart_3D()
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Multi_Color_Gantt_Chart()
Debug "Multi_Color_Gantt_Chart()"
; The tasks for the gantt chart
Dim labels.s(9)
labels(0) = "Market Research" : labels(1) = "Define Specifications"
labels(2) = "Overall Architecture" : labels(3) = "Project Planning"
labels(4) = "Detail Design" : labels(5) = "Software Development"
labels(6) = "Test Plan" : labels(7) = "Testing and QA"
labels(8) = "User Documentation"
; The task index, start date, end date and color for each bar
Dim taskNo.d(12)
taskNo( 0) = 0 : taskNo( 1) = 0 : taskNo( 2) = 1 : taskNo( 3) = 2
taskNo( 4) = 3 : taskNo( 5) = 4 : taskNo( 6) = 5 : taskNo( 7) = 6
taskNo( 8) = 6 : taskNo( 9) = 7 : taskNo(10) = 8 : taskNo(11) = 8
Dim startDate.d(12)
startDate( 0) = Chart_chartTime(2004, 8, 16) : startDate( 1) = Chart_chartTime(2004, 10, 4)
startDate( 2) = Chart_chartTime(2004, 8, 30) : startDate( 3) = Chart_chartTime(2004, 9, 13)
startDate( 4) = Chart_chartTime(2004, 9, 20) : startDate( 5) = Chart_chartTime(2004, 9, 27)
startDate( 6) = Chart_chartTime(2004, 10, 4) : startDate( 7) = Chart_chartTime(2004, 10, 4)
startDate( 8) = Chart_chartTime(2004, 10, 25) : startDate( 9) = Chart_chartTime(2004, 11, 1)
startDate(10) = Chart_chartTime(2004, 10, 18) : startDate(11) = Chart_chartTime(2004, 11, 8)
Dim endDate.d(12)
endDate( 0) = Chart_chartTime(2004, 8, 30) : endDate( 1) = Chart_chartTime(2004, 10, 18)
endDate( 2) = Chart_chartTime(2004, 9, 13) : endDate( 3) = Chart_chartTime(2004, 9, 27)
endDate( 4) = Chart_chartTime(2004, 10, 4) : endDate( 5) = Chart_chartTime(2004, 10, 11)
endDate( 6) = Chart_chartTime(2004, 11, 8) : endDate( 7) = Chart_chartTime(2004, 10, 18)
endDate( 8) = Chart_chartTime(2004, 11, 8) : endDate( 9) = Chart_chartTime(2004, 11, 22)
endDate(10) = Chart_chartTime(2004, 11, 1) : endDate(11) = Chart_chartTime(2004, 11, 22)
Dim colors.l(12)
colors( 0) = $00cc00 : colors( 1) = $00cc00 : colors( 2) = $00cc00
colors( 3) = $0000cc : colors( 4) = $0000cc : colors( 5) = $cc0000
colors( 6) = $cc0000 : colors( 7) = $0000cc : colors( 8) = $cc0000
colors( 9) = $cc0000 : colors(10) = $00cc00 : colors(11) = $cc0000
; Create a XYChart object of size 620 x 325 pixels. Set background color to
; light red ($ffcccc), with 1 pixel 3D border effect.
c.XYChart = New_XYChart(620, 325, $ffcccc, $000000, 1)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
; Add a title to the chart using 15 points Times Bold Itatic font, with white
; (ffffff) text on a dark red (800000) background
title.TextBox = c\addTitle("Mutli-Color Gantt Chart Demo", "timesbi.ttf", 15, $ffffff)
If Not title : Debug "title = 0" : ProcedureReturn : EndIf
title\setBackground($800000)
; Set the plotarea at (140, 55) and of size 460 x 200 pixels. Use alternative
; white/grey background. Enable both horizontal and vertical grids by setting
; their colors to grey (c0c0c0). Set vertical major grid (represents month
; boundaries) 2 pixels in width
plotarea.PlotArea = c\setPlotArea(140, 55, 460, 200, $ffffff, $eeeeee, #Chart_LineColor, $c0c0c0, $c0c0c0)
If Not plotarea : Debug "plotarea = 0" : ProcedureReturn : EndIf
plotarea\setGridWidth(2, 1, 1, 1)
; swap the x and y axes to create a horziontal box-whisker chart
c\swapXY()
; Set the y-axis scale to be date scale from Aug 16, 2004 to Nov 22, 2004, with
; ticks every 7 days (1 week)
yAxis.Axis = c\yAxis()
If Not yAxis : Debug "yAxis = 0" : ProcedureReturn : EndIf
yAxis\setDateScale(Chart_chartTime(2004, 8, 16), Chart_chartTime(2004, 11, 22), 86400 * 7)
; Set multi-style axis label formatting. Month labels are in Arial Bold font in
; "mmm d" format. Weekly labels just show the day of month and use minor tick
; (by using '-' as first character of format string).
yAxis\setMultiFormat2(Chart_StartOfMonthFilter(), "<*font=arialbd.ttf*>{value|mmm d}", Chart_StartOfDayFilter(), "-{value|d}")
; Set the y-axis to shown on the top (right + swapXY = top)
c\setYAxisOnRight()
; Set the labels on the x axis
xAxis.Axis = c\xAxis()
If Not xAxis : Debug "xAxis = 0" : ProcedureReturn : EndIf
xAxis\setLabels(@labels(), ArraySize(labels()))
; Reverse the x-axis scale so that it points downwards.
xAxis\setReverse()
; Set the horizontal ticks and grid lines to be between the bars
xAxis\setTickOffset(0.5)
; Add some symbols to the chart to represent milestones. The symbols are added
; using scatter layers. We need to specify the task index, date, name, symbol
; shape, size and color.
coor1.d = 1
date1.d = Chart_chartTime(2004, 9, 13)
c\addScatterLayer(@coor1, 1, @date1, 1, "Milestone 1", Chart_Cross2Shape(), 13, $ffff00)
coor2.d = 3
date2.d = Chart_chartTime(2004, 10, 4)
c\addScatterLayer(@coor2, 1, @date2, 1, "Milestone 2", Chart_StarShape(5), 15, $ff00ff)
coor3.d = 5
date3.d = Chart_chartTime(2004, 11, 8)
c\addScatterLayer(@coor3, 1, @date3, 1, "Milestone 3", #Chart_TriangleSymbol, 13, $ff9933)
; Add a multi-color box-whisker layer to represent the gantt bars
layer.BoxWhiskerLayer = c\addBoxWhiskerLayer2(@startDate(), ArraySize(startDate()), @endDate(), ArraySize(endDate()), 0,0, 0,0, 0,0, @colors(), ArraySize(colors()))
If Not layer : Debug "layer = 0" : ProcedureReturn : EndIf
layer\setXData(@taskNo(), ArraySize(taskNo()))
layer\setBorderColor(#Chart_SameAsMainColor)
; Divide the plot area height ( = 200 in this chart) by the number of tasks to
; get the height of each slot. Use 80% of that as the bar height.
layer\setDataWidth(200 * 4 / 5 / ArraySize(labels()))
; Add a legend box at (140, 265) - bottom of the plot area. Use 8 pts Arial Bold
; as the font with auto-grid layout. Set the width to the same width as the plot
; area. Set the backgorund to grey (dddddd).
legendBox.LegendBox = c\addLegend2(140, 265, #Chart_AutoGrid, "arialbd.ttf", 8)
If Not legendBox : Debug "legendBox = 0" : ProcedureReturn : EndIf
legendBox\setWidth(461)
legendBox\setBackground($dddddd)
; The keys for the scatter layers (milestone symbols) will automatically be
; added to the legend box. We just need to add keys to show the meanings of the
; bar colors.
legendBox\addKey("Market Team", $00cc00)
legendBox\addKey("Planning Team", $0000cc)
legendBox\addKey("Development Team", $cc0000)
; Output the chart
c\makeChart(CD_PATH("output\103 - colorgantt.png"))
; free up resources
delete(c)
EndProcedure
Multi_Color_Gantt_Chart()
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Scatter_Chart()
Debug "Scatter_Chart()"
DataSection
; The XY points for the scatter chart
dataX0_078: : Data.d 10, 15, 6, 12, 14, 8, 13, 13, 16, 12, 10.5
dataY0_078: : Data.d 130, 150, 80, 110, 110, 105, 130, 115, 170, 125, 125
dataX1_078: : Data.d 6, 12, 4, 3.5, 7, 8, 9, 10, 12, 11, 8
dataY1_078: : Data.d 65, 80, 40, 45, 70, 80, 80, 90, 100, 105, 60
EndDataSection
; Create a XYChart object of size 450 x 420 pixels
c.XYChart = New_XYChart(450, 420)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
; Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a light grey
; border ($c0c0c0). Turn on both horizontal and vertical grid lines with light
; grey color ($c0c0c0)
c\setPlotArea(55, 65, 350, 300, -1, -1, $c0c0c0, $c0c0c0, -1)
; Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12
; pts Times Bold Italic font. Set the background and border color to
; Transparent.
legend.LegendBox = c\addLegend(50, 30, #False, "timesbi.ttf", 12)
If Not legend : Debug "legend = 0" : ProcedureReturn : EndIf
legend\setBackground(#Chart_Transparent)
; Add a title to the chart using 18 pts Times Bold Itatic font.
c\addTitle("Genetically Modified Predator", "timesbi.ttf", 18)
; Add a title to the y axis using 12 pts Arial Bold Italic font
yAxis.Axis = c\yAxis()
If Not yAxis : Debug "yAxis = 0" : ProcedureReturn : EndIf
yAxis\setTitle("Length (cm)", "arialbi.ttf", 12)
; Add a title to the x axis using 12 pts Arial Bold Italic font
xAxis.Axis = c\xAxis()
If Not xAxis : Debug "xAxis = 0" : ProcedureReturn : EndIf
xAxis\setTitle("Weight (kg)", "arialbi.ttf", 12)
; Set the axes line width to 3 pixels
xAxis\setWidth(3)
yAxis\setWidth(3)
; Add an orange ($ff9933) scatter chart layer, using 13 pixel diamonds as
; symbols
c\addScatterLayer(?dataX0_078, 11, ?dataY0_078, 11, "Genetically Engineered", #Chart_DiamondSymbol, 13, $ff9933)
; Add a green ($33ff33) scatter chart layer, using 11 pixel triangles as
; symbols
c\addScatterLayer(?dataX1_078, 11, ?dataY1_078, 11, "Natural", #Chart_TriangleSymbol, 11, $33ff33)
; Output the chart
c\makeChart(CD_PATH("output\078 - scatter.png"))
; free up resources
delete(c)
EndProcedure
Scatter_Chart()
Code: Select all
XIncludeFile "ChartDirector.pbi"
Procedure Confidence_Band()
Debug "Confidence_Band()"
DataSection
; The XY data of the first data series
dataX_075: : Data.d 50, 55, 37, 24, 42, 49, 63, 72, 83, 59
dataY_075: : Data.d 3.6, 2.8, 2.5, 2.3, 3.8, 3.0, 3.8, 5.0, 6.0, 3.3
EndDataSection
; Create a XYChart object of size 450 x 420 pixels
c.XYChart = New_XYChart(450, 420)
If Not c : Debug "c = 0" : ProcedureReturn : EndIf
; Set the plotarea at (55, 65) and of size 350 x 300 pixels, with white
; background and a light grey border ($c0c0c0). Turn on both horizontal and
; vertical grid lines with light grey color ($c0c0c0)
c\setPlotArea(55, 65, 350, 300, $ffffff, -1, $c0c0c0, $c0c0c0, -1)
; Add a title to the chart using 18 point Times Bold Itatic font.
c\addTitle("Server Performance", "timesbi.ttf", 18)
; Add titles to the axes using 12 pts Arial Bold Italic font
yAxis.Axis = c\yAxis()
If Not yAxis : Debug "yAxis = 0" : ProcedureReturn : EndIf
yAxis\setTitle("Response Time (sec)", "arialbi.ttf", 12)
xAxis.Axis = c\xAxis()
If Not xAxis : Debug "xAxis = 0" : ProcedureReturn : EndIf
xAxis\setTitle("Server Load (TPS)", "arialbi.ttf", 12)
; Set the axes line width to 3 pixels
yAxis\setWidth(3)
xAxis\setWidth(3)
; Add a scatter layer using (dataX, dataY)
c\addScatterLayer(?dataX_075, 10, ?dataY_075, 10, "", #Chart_DiamondSymbol, 11, $008000)
; Add a trend line layer for (dataX, dataY)
trendLayer.TrendLayer = c\addTrendLayer2(?dataX_075, 10, ?dataY_075, 10, $008000)
If Not trendLayer : Debug "trendLayer = 0" : ProcedureReturn : EndIf
; Set the line width to 3 pixels
trendLayer\setLineWidth(3)
; Add a 95% confidence band for the line
trendLayer\addConfidenceBand(0.95, $806666ff)
; Add a 95% confidence band (prediction band) for the points
trendLayer\addPredictionBand(0.95, $8066ff66)
; Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 10
; pts Arial Bold Italic font. Set the background and border color to
; Transparent.
legendBox.LegendBox = c\addLegend(50, 30, #False, "arialbi.ttf", 10)
If Not legendBox : Debug "legendBox = 0" : ProcedureReturn : EndIf
legendBox\setBackground(#Chart_Transparent)
; Add entries to the legend box
legendBox\addKey("95% Line Confidence", $806666ff)
legendBox\addKey("95% Point Confidence", $8066ff66)
; Display the trend line parameters as a text table formatted using CDML
buffer.s = "<*block*>Slope"+#LF$+"Intercept"+#LF$+"Correlation"+#LF$+"Std Error<*/*> <*block*>"
buffer + StrD( trendLayer\getSlope() , 4) + " sec/tps"+#LF$
buffer + StrD( trendLayer\getIntercept() , 4) + " sec"+#LF$
buffer + StrD( trendLayer\getCorrelation(), 4) + #LF$
buffer + StrD( trendLayer\getStdError() , 4) + " sec<*/*>"
textbox.TextBox = c\addText(56, 65, buffer, "arialbd.ttf", 8)
If Not textbox : Debug "textbox = 0" : ProcedureReturn : EndIf
; Set the background of the text box to light grey, with a black border, and 1
; pixel 3D border
textbox\setBackground($c0c0c0, 0, 1)
; Output the chart
c\makeChart(CD_PATH("output\075 - confidenceband.png"))
; free up resources
delete(c)
EndProcedure
Confidence_Band()