Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Pls help

data:[
jQuery("#chartId").jqchart({url: 'jqchart.ashx'})
]
Posted

You don't do it through jQuery. It runs through C#. You could fire off your C# code from jquery but the approach you have here is not going to work. Server side code has to run.
 
Share this answer
 
Comments
Roopa 10064853 15-Jul-13 0:38am    
ok sir thank u pls do help me how to do in client side i have written in server side so that i can check
ZurdoDev 15-Jul-13 7:39am    
You'll need to post more information about what you are doing. It sounds like you just need to refresh your page.
Roopa 10064853 15-Jul-13 8:25am    
public partial class Default6 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

[WebMethod]
//public static string GetData(int userid)
public static List GetData()
{
List dataList = new List();

MySqlConnection con = new MySqlConnection("Server=localhost;Port=3306;Database=projecttt;UID=root;Pwd=techsoft;pooling=false");
string s = string.Empty;
s = "select name,marks from jqchart";
string s1= "select count(name) from jqchart";
int s2 = Convert.ToInt32(s1);
{
MySqlCommand cmd = new MySqlCommand(s, con);
{
con.Open();
cmd.ExecuteNonQuery();
string name;
int marks;
MySqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
//for (int i = 0; i < s2; i++)
{
dataList.Add(new Data(name, marks));

}

return dataList.ToList();
}

}

//dataList.Add(new Data("Column 1", 100));
//dataList.Add(new Data("Column 2", 75));
//dataList.Add(new Data("Column 3", 50));
//dataList.Add(new Data("Column 4", 25));
//return dataList;

}
public class Data
{
public string ColumnName = "";
public int Value = 0;

public Data(string columnName, int value)
{
ColumnName = columnName;
Value = value;
}
}
}

ASPX Page

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', { packages: ['corechart'] });
</script>
<%--simple chart--%>
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: 'Default6.aspx/GetData',
data: {},
success:
function (response) {
drawVisualization(response.d);
}

});
})

function drawVisualization(dataValues) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Column Name');
data.addColumn('number', 'Column Value');

for (var i = 0; i < dataValues.length; i++) {
data.addRow([dataValues[i].ColumnName, dataValues[i].Value]);
}

new google.visualization.PieChart(document.getElementById('visualization')).
draw(data, { title: " JQuery Charts Example" });
}

</script>
<body>

<div id="visualization" style="width: 600px; height: 400px;"></div>

</body>
My aspx page

XML
<script src="Scripts/jqchart.js" type="text/javascript"></script>
<%--Changes chart --%>
<script type="text/javascript">
    $(function () {
        var chart;
        $(document).ready(function () {

            // Radialize the colors
            Highcharts.getOptions().colors = $.map(Highcharts.getOptions().colors, function (color) {
                return {
                    radialGradient: {
                        cx: 0.5,
                        cy: 0.3,
                        r: 0.7
                    },
                    stops: [
[0, color],
[1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
]
                };
            });
            // Build the chart
            chart = new Highcharts.Chart(
{
    chart:
{
    renderTo: 'container',
    fill: false,
    plotBackgroundColor: null,
    plotBorderWidth: null,
    plotShadow: false
},
    title: {
        text: 'Techsoft Technologies Bangalore, 2013'
    },
    tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage}%</b>',
        percentageDecimals: 1
    },
    highlighter: {
        show: true,
        sizeAdjust: 7.5
    },
    plotOptions: {
        pie:
{
    allowPointSelect: true,
    cursor: 'pointer',
    dataLabels:
{
    enabled: true,
    color: '#000000',
    connectorColor: '#000000',
    formatter: function () {
        return '<b>' + this.point.name + '</b>: ' + this.percentage + ' %';
    }
}
}
    },
    series: [
{
    type: 'pie',
    name: 'Strength',

    data: [
       ['Firefox', 45.0],
    ['IE', 26.8],
    {
        name: 'Chrome',
        y: 12.8,
            ////sliced: true,
        selected: true
    },
    ['Safari', 8.5],
    ['Opera', 6.2],
    ['Others', 0.7]


]
}
]
});
        });
    });
</script>
<body>
 <script src="Scripts/high.js" type="text/javascript"></script>
 <script src="Scripts/high1.js" type="text/javascript"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto">
</div>
</body>



My CS page

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using MySql.Data.MySqlClient;
using System.Web.Script.Serialization;
using System.Web.UI.DataVisualization;
using System.Data;

public partial class Default5 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    [WebMethod]
    //public static string GetData(int userid)
    public static List<Data> GetData()
    {

        List<Data> dataList = new List<Data>();

        MySqlConnection con = new MySqlConnection("Server=localhost;Port=3306;Database=projecttt;UID=root;Pwd=techsoft;pooling=false");
        string s = string.Empty;
        s = "select name,marks from jqchart";
        //string s1 = "select count(name) from jqchart";
        //int s2 = Convert.ToInt32(s1);
        {
            MySqlCommand cmd = new MySqlCommand(s, con);
            {
                con.Open();
                cmd.ExecuteNonQuery();
                //string name;
                //int marks;
                MySqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                //for (int i = 0; i < s2; i++)
                {
                    string a = dr[0].ToString();
                    string b = dr[1].ToString();
                    dataList.Add(new Data(a, int.Parse(b)));

                }

                return dataList;

            }

        }

        //dataList.Add(new Data("Column 1", 100));
        //dataList.Add(new Data("Column 2", 75));
        //dataList.Add(new Data("Column 3", 50));
        //dataList.Add(new Data("Column 4", 25));
        //return dataList;   
    }
    public class Data
    {
        public string ColumnName = "";
        public int Value = 0;

        public Data(string columnName, int value)
        {
            ColumnName = columnName;
            Value = value;
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900