Value Labels on Graphs

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for COM/ActiveX (v7)  /  Re: Value Labels on Graphs

DynamicPDF CoreSuite for COM/ActiveX (v7) Forum

 Nov 17 2014 11:41 AM
Is there a way to print the value of a column on a graph? I tried the following code, which seems like it should work based on the meager documentation:

    objSeries.AddValue rstChg!Consumption, rstChg!CurrentReadingDate, CStr(rstChg!Consumption)

However, every time it tries to execute this line I get error "Unable to cast object of type 'System.String' to type 'DynamicPDFforCOM.BarColumnValuePositionDataLabel'."

The documentation states that the DataLabel parameter is a Variant:

Syntax
Visual Basic
Public Sub AddValue( _
   ByVal Value As Single, _
   ByVal DateTime As Date, _
   Optional ByVal DataLabel As Variant, _
   Optional ByVal Color As Variant _
)
 

Parameters
Value
Value of the dateTime column series.
DateTime
Position of the dateTime column series.
DataLabel
DataLabel of the dateTime column series.
Color
Color of the dateTime column series.

Am I missing something?

Please add some full-featured graph examples to the documentation, and a little more explanation
 Nov 17 2014 1:13 PM
Posted by a ceTe Software moderator
Hello,

You are getting the error most likely because of using string object instead of a BarColumnValuePositionDataLabel object in the AddValue method. Please add only the series value and DateTime using AddValue method and then you can set the data label positions for the data points of the series using DataLabel property. Below is the code sample for it.

<!-- METADATA TYPE="typelib" UUID="DF9225FE-94A4-490d-8CAD-E8366CE621D3"-->
<%
    ' Create a PDF Document
    Dim document
    Set document = Server.CreateObject("DynamicPDF.Document")
    '  Create a Page and add it to the document
    Dim MyPage
    Set MyPage = document.AddPage()
    ' Create a chart
    Dim Chart
    Set Chart = MyPage.AddChart(0, 0, 400, 200)
    ' Create header titles and add it to the chart
    Dim MyTitle1
    Set MyTitle1 = Chart.AddHeaderTitle ("Website Visitors")
    Dim MyTitle2
    Set MyTitle2 = Chart.AddHeaderTitle ("Year - 2007")
    ' Create positions
    Dim p0
    p0 = DateSerial(2007, 1, 1)
    Dim p1
    p1 = DateSerial(2007, 2, 1)
    Dim p2
    p2 = DateSerial(2007, 3, 1)
    Dim p3
    p3 = DateSerial(2007, 4, 1)
    ' Create a date time column series and add value to it.
    Dim MyColumnSeries1
    Set MyColumnSeries1 = Chart.PrimaryPlotArea.AddDateTimeColumnSeries("Website A")
    MyColumnSeries1.AddValue 5, p0
    MyColumnSeries1.AddValue 7, p1
    MyColumnSeries1.AddValue 4, p2
    MyColumnSeries1.AddValue 3, p3
    ' Create a date time column series and add value to it.
    Dim MyColumnSeries2
    Set MyColumnSeries2 = Chart.PrimaryPlotArea.AddDateTimeColumnSeries("Website B")
    MyColumnSeries2.AddValue 4, p0
    MyColumnSeries2.AddValue 2, p1
    MyColumnSeries2.AddValue 5, p2
    MyColumnSeries2.AddValue 8, p3
    ' Create a date time column series and add value to it.
    Dim MyColumnSeries3
    Set MyColumnSeries3 = Chart.PrimaryPlotArea.AddDateTimeColumnSeries("Website C")
    MyColumnSeries3.AddValue 2, p0
    MyColumnSeries3.AddValue 4, p1
    MyColumnSeries3.AddValue 6, p2
    MyColumnSeries3.AddValue 9, p3
           
    ' Create a value position data label
    Dim MyValuePositionDataLabel
    Set MyValuePositionDataLabel = MyColumnSeries1.GetBarColumnValuePositionDataLabel(True)
    MyColumnSeries1.DataLabel = MyValuePositionDataLabel
    MyColumnSeries2.DataLabel = MyValuePositionDataLabel
    MyColumnSeries3.DataLabel = MyValuePositionDataLabel

    ' Add a title to the yaxis
    Dim MyTitle3
    Set MyTitle3 = MyColumnSeries1.YAxis.AddTitle ("Viewers (in millions)")
    ' Set label list format for the axislabels
    MyColumnSeries1.XAxis.LabelFormat = "MMM"
    ' Draw the PDF document
    document.DrawToWeb
%>

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 3:13 PM.