Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8812733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:40:18+00:00 2026-06-14T03:40:18+00:00

So I’m trying to use this javascript with my asp.net website https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart I have

  • 0

So I’m trying to use this javascript with my asp.net website https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart

I have an array in codebehind that has my data which i converted to a multidimensional datatable like this.

<in codebehind vb>
Public Property datat As DataTable

For outerIndex As Integer = 0 To 2
    Dim newRow As DataRow = table.NewRow()
    For innerIndex As Integer = 0 To 2
            newRow(innerIndex) = Array(outerIndex, innerIndex)
    Next
    table.Rows.Add(newRow)
Next

datat = table

<in asp>

function drawChart() {
    var data = <%=datat%>

I always get an error datatable not defined.

My new work

<in asp>

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
    google.load("visualization", "1", {packages:["corechart"]});
    google.setOnLoadCallback(drawcharts);
    function drawcharts() {
        var data = google.visualization.arrayToDataTable([
            ['X', 'MW'],
      [<%=mwtimepublic%>, <%=mwarraypublic%>]
        ]);

        var options = {
            title: 'MW Trend'
        };

        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        chart.draw(data, options);
    });
</script>

Public Function Dtable() As DataTable
Dim startdate As String
Dim enddate As String

    If FirstRun = False Then
        datat.Clear()
    End If

    If FirstRun = True Then
        FirstRun = False
        enddate = Date.Today
        startdate = DateAdd(DateInterval.Day, -20, Date.Today)
    Else
        enddate = TextBox2.Text
        startdate = TextBox1.Text
    End If

'<confidential code></confidentialcode>

    Dim mwaray(pdata.Count)
    Dim mwtime(pdata.Count)
    Dim table As New DataTable
    table.Columns.Add("X")
    table.Columns.Add("MW")
    Dim i As Integer
    Dim x As Integer
    For i = 1 To pdata.Count
        mwaray(i) = pdata(i).Value
        If mwaray(i) > upperlimit Then
            upperlimit = mwaray(i) + 50
        End If
    Next

    For i = 1 To pdata.Count
        mwtime(i) = "'" & pdata(i).TimeStamp.LocalDate.Month.ToString() & "/" & pdata(i).TimeStamp.LocalDate.Day.ToString() & "/" & pdata(i).TimeStamp.LocalDate.Year.ToString() & " " & pdata(i).TimeStamp.LocalDate.TimeOfDay.Hours.ToString() & ":" & pdata(i).TimeStamp.LocalDate.TimeOfDay.Minutes.ToString() & ":" & pdata(i).TimeStamp.LocalDate.TimeOfDay.Seconds.ToString() & "'"
    Next

    For i = 1 To pdata.Count
        mwarraypublic.Add(mwaray(i))
    Next

    For i = 1 To pdata.Count
        mwtimepublic.Add(mwtime(i))
    Next

End Function

I’m still not getting the chart to draw

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:40:19+00:00Added an answer on June 14, 2026 at 3:40 am

    I made a video on how to create a jquery ui autocomplete while getting an array to javascript from codebehind

    skip to 6:00 to see how I made the array
    http://www.youtube.com/watch?v=ULHSqoDHP-U&list=UUgtKyNvllU9E6c2Mi8OtzCQ&index=6&feature=plcp

    PageMethods.YourWebMethod(function(results){
      var data = resluts;
      //the rest of your code goes here...
    });
    

    update:


    Google actually converts an array of arrays into a datatable.
    In other words, you have to return an array of rows, and the rows them self are an array of column values.

    So in you code behind you do the following
    first import webservices

    Imports System.Web.Services
    

    then create your webmethod with a function that returns an arraylist

    <WebMethod()>
    Public Shared Function Dtable() As ArrayList
    dim table As New ArrayList
    Dim YourDataSetTable as new Dataset.YorDataTable
    'fill you table here
    
    'first get column names as the first row/array
    dim colNames as New ArrayList
    
    For Each col as DataColumn in YourDataSetTable.Columns
       colNames.Add(col.ColumnName)
    Next
    table.Add(colNames)
    
    'then on to the data
    For Each r as DataRow in YourDataSetTable .Rows
      dim colVals as New ArrayList
      For Each col as DataColumn in YourDataSetTable.Columns
        colVals.Add(r.Item(col.ColumnName))
      Next
      table.Add(colVals)
    Next
    Return table
    End Function
    

    Then in javascript

    PageMethods.Dtable(function(results){
      var data = resluts;
      //the rest of your code goes here...
    });
    

    make sure you have a script manager on the page with pagemethods enabled.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.