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 6140187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:05:06+00:00 2026-05-23T18:05:06+00:00

what i need to do is load my pie data chart created with extjs4

  • 0

what i need to do is load my pie data chart created with extjs4 with data from my database
the store accept this data ,so i need to return my data in format that look like this:

var data = [{ name: "Low", data1: "20", data2: "54", data3: "63", data4: "12" },
 { name: "Moderate", data1: "2", data2: "74", data3: "13", data4: "25" },
 { name: "Critical", data1: "42", data2: "17", data3: "3", data4: "20" },
 { name: "High", data1: "25", data2: "14", data3: "23", data4: "52"}];

so im trying to do this in c# with json.net, i created a class.cs and put my queries to get the data i need :

namespace charts
{
public class lineChartClass
{
    public String piedata()
    {     
{//..my queries in here..//}
   double[] data = new double[4] ;
        //data = "{ name: \"Low\", data1: " + lowtotal + "}" + ",{ name: \"Moderate\", data1: " + moderatetotal + "}" + ",{ name: \"Critical\", data1: " + criticaltotal + "}" + ",{ name: \"High\", data1: " + hightotal + "}";
       data[0]=lowtotal;
       data[1] = moderatetotal;
       data[2] = criticaltotal;
       data[3] = hightotal;
        return data;



    }//eo piedata
}
    public class ChartItem
    {
        public string Name { get; set; }

        public string Data1 { get; set; }


    }

}

and created my handler.ashx to convert to json:

namespace charts {
public class lineChartData : IHttpHandler
{
    static string ConvertToJson()
    {
     List<ChartItem> chartItems = new List<ChartItem>();

        chartItems.Add(new ChartItem() { Name = "Low", Data1 = json[0].ToString() });
        chartItems.Add(new ChartItem() { Name = "Moderate", Data1 = json[1].ToString() });
        chartItems.Add(new ChartItem() { Name = "Critical", Data1 = json[2].ToString() });
        chartItems.Add(new ChartItem() { Name = "High", Data1 = json[3].ToString() });
        string result = new JavaScriptSerializer().Serialize(chartItems);
        return result;

    }
} 
}

then in my chart.js i call it like this:

var obj= new lineChartData();

window.store1 = Ext.create('Ext.data.JsonStore', {
fields: ['name', 'dat1', 'data2', 'data3', 'data4'],
data: obj.ConvertToJson()//generateData()
});

but i get this error:

Uncaught ReferenceError: lineChartData is not defined
lineChartData.ashxGET http://localhost/lineChartData.ashx?proxy 500 (Internal Server Error)

im just starting with c# and extjs and dont know how to use json.net

thanks in advance for ur time

  • 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-05-23T18:05:08+00:00Added an answer on May 23, 2026 at 6:05 pm

    Why don’t you use standard versions of JSON serialization tools at both client-side and server-side.
    ASP.NET has JavaScriptSerializer class & JavaScript has JSON object (native in ECMAScript 5 and a plugin for older versions, written by Douglas Crockford).

    To convert and Object to JSON at server, you can use:

    string objectJson = new JavaScriptSerializer().Serialize(yourObject);
    

    To serialize object to JSON at client-side, you can use:

    string objectJson = JSON.stringify(yourObject);
    

    To deserialize a JSON string into an object in client-side, you can use:

    var yourObject = JSON.parse(objectJson);
    

    Thus you can have a class to represent your chart item at server:

    public class ChartItem
    {
        public string Name {get;set;}
    
        public string Data1 {get;set;}
    
        public string Data2 {get;set;}
    
        public string Data3 {get;set;}
    
        public string Data4 {get;set;}
    }
    

    and use it in your `ConvertToJson’ method as follow:

    List<ChartItem> chartItems = new List<ChartItem>();
    // add as many item as you wish to this list
    chartItems.Add(new ChartItem(){ Name = "Something", Data1 = "data1", Data2 = "data2", Data3 = "data3", Data4 = "data4 });
    string result = new JavaScriptSerialize().Serialize(chartItems);
    return result;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to load data from different remote database into our own database. I
I need to load a model, existing of +/- 20 tables from the database
I need to load (int) data from file. New line separates different data so
I need to load some properties into a Spring context from a location that
I need to load some text (shader code) from a file that is placed
Need to load data from a single file with a 100,000+ records into multiple
Need to load data from a single file with a 100,000+ records into multiple
I need load external resources from another server like css, template, data... but I
I need to load an xslt from a database and hold it in memory
I need to load data from source table to Flat file detination(txt). For example

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.