Results 1 to 2 of 2

Thread: chart in html table

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Posts
    24

    Question chart in html table

    Anyone know how to put a chart inside an html table? I would think its would be easy but I cant seem to get it to work.

    Below is an example of a working chart, and then a copy of the exact same code inside a tabel that wont show up.


    This works, it displays the chart
    <!-- OS versions chart starts here -->

    <%
    dim osver()
    dim osvercnt()
    dim mycount
    'this section counts all os versions
    SQL_query = "SELECT * FROM osverqry"

    Set RS = MyConn.Execute(SQL_query)
    mycount = 0
    WHILE NOT RS.EOF
    mycount = mycount + 1
    redim preserve osver(mycount)
    redim preserve osvercnt(mycount)

    'save the value to the array
    osver(mycount) = RS("osversion")
    osvercnt(mycount) = RS("countofosversion")

    RS.MoveNext
    WEND
    %>

    <OBJECT CLASSID="clsid:0002E500-0000-0000-C000-000000000046" id=ChartSpace WIDTH="23%" HEIGHT="70%"></OBJECT>

    <SCRIPT language=vbscript>
    set c = ChartSpace.Constants

    'Clear the Chartspace
    ChartSpace.Clear
    ChartSpace.Border.Color = c.chColorNone

    'Create a new chart with a legend and a title
    set oChart = ChartSpace.Charts.Add()
    oChart.HasLegend = True
    oChart.Legend.Position = c.chLegendPositionBottom
    oChart.HasTitle = True

    'Set the Chart type to the selected chart type's long value
    nChartType = 18 ' 18 is a pie chart
    oChart.Type = nChartType

    'set the categories and values
    dim mycat(<%=mycount%>)
    dim myval(<%=mycount%>)

    <%for x = 0 to UBound(osver, 1)-1%>
    mycat(<%=x%> ) = "<%=osver(x+1)%>"
    <%next 'x%>

    <%for x = 0 to UBound(osver, 1)-1%>
    myval(<%=x%> ) = "<%=osvercnt(x+1)%>"
    <%next 'x%>

    'assign the data to the chart
    With oChart.SeriesCollection.Add
    .SetData c.chDimCategories, c.chDataLiteral, mycat
    .SetData c.chDimValues, c.chDataLiteral, myval
    '.plotarea.Interior.Color = RGB(240, 240, 10)

    'set color for each point
    'we may not know number of points so this micht need to be in a loop
    '.Points.Item(0).Interior.Color = RGB(250, 0, 150)
    '.Points.Item(1).Interior.Color = RGB(150, 0, 150)

    set oLabels = .DataLabelsCollection.Add
    oLabels.HasValue = true
    oLabels.HasPercentage = true
    oLabels.Interior.Color = RGB(255, 255, 255)
    End With
    oChart.Title.Caption = "Operating System Types"
    </script>

    <!-- OS versions chart ends here -->



    This does not work, the table is displed but the chart doesnt show

    <table border="1" width="100%">
    <tr>
    <td width="25%">


    <!-- OS versions chart starts here -->

    <%
    dim osver()
    dim osvercnt()
    dim mycount
    'this section counts all os versions
    SQL_query = "SELECT * FROM osverqry"

    Set RS = MyConn.Execute(SQL_query)
    mycount = 0
    WHILE NOT RS.EOF
    mycount = mycount + 1
    redim preserve osver(mycount)
    redim preserve osvercnt(mycount)

    'save the value to the array
    osver(mycount) = RS("osversion")
    osvercnt(mycount) = RS("countofosversion")

    RS.MoveNext
    WEND
    %>

    <OBJECT CLASSID="clsid:0002E500-0000-0000-C000-000000000046" id=ChartSpace WIDTH="23%" HEIGHT="70%"></OBJECT>

    <SCRIPT language=vbscript>
    set c = ChartSpace.Constants

    'Clear the Chartspace
    ChartSpace.Clear
    ChartSpace.Border.Color = c.chColorNone

    'Create a new chart with a legend and a title
    set oChart = ChartSpace.Charts.Add()
    oChart.HasLegend = True
    oChart.Legend.Position = c.chLegendPositionBottom
    oChart.HasTitle = True

    'Set the Chart type to the selected chart type's long value
    nChartType = 18 ' 18 is a pie chart
    oChart.Type = nChartType

    'set the categories and values
    dim mycat(<%=mycount%>)
    dim myval(<%=mycount%>)

    <%for x = 0 to UBound(osver, 1)-1%>
    mycat(<%=x%> ) = "<%=osver(x+1)%>"
    <%next 'x%>

    <%for x = 0 to UBound(osver, 1)-1%>
    myval(<%=x%> ) = "<%=osvercnt(x+1)%>"
    <%next 'x%>

    'assign the data to the chart
    With oChart.SeriesCollection.Add
    .SetData c.chDimCategories, c.chDataLiteral, mycat
    .SetData c.chDimValues, c.chDataLiteral, myval
    '.plotarea.Interior.Color = RGB(240, 240, 10)

    'set color for each point
    'we may not know number of points so this micht need to be in a loop
    '.Points.Item(0).Interior.Color = RGB(250, 0, 150)
    '.Points.Item(1).Interior.Color = RGB(150, 0, 150)

    set oLabels = .DataLabelsCollection.Add
    oLabels.HasValue = true
    oLabels.HasPercentage = true
    oLabels.Interior.Color = RGB(255, 255, 255)
    End With
    oChart.Title.Caption = "Operating System Types"
    </script>

    <!-- OS versions chart ends here -->


    </td>

  2. #2
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    No..... no code tags.... can't parse easy enough.... attention span failing... page reverting..... *poof*
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width