ComponentOne WebChart 8.0 for ActiveX
Interactive Runtime Only Pages

By adding a form, a little server-side script and a client control, it is possible to make the chart renderings user controlled. The following code demonstrates such interaction. The code is available in /WebChart8/details/runquery.asp.

Example Title
Copy Code
<!-- #INCLUDE VIRTUAL="/WebChart8/Include/VBS/color.inc" -->
<!-- #INCLUDE VIRTUAL="/WebChart8/Include/VBS/2dconst.inc" -->
<!-- #INCLUDE VIRTUAL="/WebChart8/Include/VBS/2dgentag.inc" -->

<html>
<body>

<%
  Private Sub gen_select_entry(selector, value, label)
    Response.Write("<OPTION value=""" & value & """")
    If Request.Form(selector).Count > 0 Then
      If Request.Form(selector) = value Then
        Response.Write(" selected")
      End If
    Else
      If value = "White" Then
        Response.Write(" selected")
      End If
    End If
    Response.Write("> " & label & Chr(10))
  End Sub
%>


<form action="runquery.asp" method="post" id=form1 name=form1>
  <big>
    <strong>
      Chart Background Color:
      <select name="selBgColor" size=1 onchange="form1.submit()">
        <% Call gen_select_entry("selBgColor", "Wheat", "Wheat") %>
        <% Call gen_select_entry("selBgColor", "Brown", "Brown") %>
        <% Call gen_select_entry("selBgColor", "AquaMarine", "AquaMarine") %>
        <% Call gen_select_entry("selBgColor", "White", "White") %>
      </select>
    </strong>
  </big>
</form>

<p>Text above the chart</p>

<br>
<%
  Dim Chart2D1
  Set Chart2D1 = Server.CreateObject("C1Chart2D8.ASPComponent")

  Sub Chart2D1_Load()
    With Chart2D1
      .Width = 254
      .Height = 205
      .IsBatched = True

      .ChartGroups(1).ChartType = oc2dTypeBar

      Select Case(Request.Form("selBgColor"))
        Case "Wheat"
          .Interior.BackgroundColor = 11788021

        Case "Brown"
          .Interior.BackgroundColor = 2763429

        Case "AquaMarine"
          .Interior.BackgroundColor = 13959039

        Case Else
          .Interior.BackgroundColor = 16777215
      End Select

      .IsBatched = False
    End With
  End Sub

  Call Chart2D1_Load()

  Call OlectraChart2D_GenerateTag_PNG(Chart2D1, "Chart2D1")
%>

<br>

<p>Text below the chart</p>

</body>
</html>

This version of the ASP page has added a form and a client-side selector. Based upon the selector value, the chart background color is modified. Additionally, the Chart Object has been renamed and the GenerateTag call has been changed to OlectraChart2D_GenerateTag_PNG(), so the rendering is always in the form of a PNG file.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback