Click here to Skip to main content
15,885,546 members
Articles / Programming Languages / Javascript

D3.js Crash Course

Rate me:
Please Sign up or sign in to vote.
4.98/5 (24 votes)
15 Jan 2013CPOL8 min read 149.9K   2.1K   85  
Learn how to visualize data generated by an ASP.Net HTTP handler using D3.js
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Web;

namespace Harlinn.d3.Introduction.Types
{
    public class ProductionData
    {
        DateTime timeStamp;
        double oil; 
        double gas; 
        double ngl; 
        double condensate; 
        double oe; 
        double water;

        public ProductionData()
        { }

        public ProductionData(string text)
        {
            string[] data = text.Split(',');
            int year = int.Parse(data[0]);
            int month = int.Parse(data[1]);

            timeStamp = new DateTime(year, month, 1);

            oil = double.Parse(data[2],CultureInfo.InvariantCulture);
            gas = double.Parse(data[3],CultureInfo.InvariantCulture);
            ngl = double.Parse(data[4],CultureInfo.InvariantCulture);
            condensate = double.Parse(data[5],CultureInfo.InvariantCulture);
            oe = double.Parse(data[6],CultureInfo.InvariantCulture);
            water = double.Parse(data[7],CultureInfo.InvariantCulture);
        }

        public static string CsvHeader
        {
            get
            {
                return "timeStamp,oil,gas,ngl,condensate,oe,water";
            }
        }


        public override string ToString()
        {
            string result = timeStamp.Year.ToString() + "-" + timeStamp.Month.ToString() + "," +
                oil.ToString(CultureInfo.InvariantCulture) + "," +
                gas.ToString(CultureInfo.InvariantCulture) + "," +
                ngl.ToString(CultureInfo.InvariantCulture) + "," +
                condensate.ToString(CultureInfo.InvariantCulture) + "," +
                oe.ToString(CultureInfo.InvariantCulture) + "," +
                water.ToString(CultureInfo.InvariantCulture);
            return result;
        }


        public DateTime TimeStamp
        {
            get
            {
                return timeStamp;
            }
            set
            {
                if (timeStamp == value)
                    return;
                timeStamp = value;
            }
        }
        public double Oil
        {
            get
            {
                return oil;
            }
            set
            {
                if (oil == value)
                    return;
                oil = value;
            }
        }
        public double Gas
        {
            get
            {
                return gas;
            }
            set
            {
                if (gas == value)
                    return;
                gas = value;
            }
        }
        public double Ngl
        {
            get
            {
                return ngl;
            }
            set
            {
                if (ngl == value)
                    return;
                ngl = value;
            }
        }
        public double Condensate
        {
            get
            {
                return condensate;
            }
            set
            {
                if (condensate == value)
                    return;
                condensate = value;
            }
        }
        public double Oe
        {
            get
            {
                return oe;
            }
            set
            {
                if (oe == value)
                    return;
                oe = value;
            }
        }
        public double Water
        {
            get
            {
                return water;
            }
            set
            {
                if (water == value)
                    return;
                water = value;
            }
        }



    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Architect Sea Surveillance AS
Norway Norway
Chief Architect - Sea Surveillance AS.

Specializing in integrated operations and high performance computing solutions.

I’ve been fooling around with computers since the early eighties, I’ve even done work on CP/M and MP/M.

Wrote my first “real” program on a BBC micro model B based on a series in a magazine at that time. It was fun and I got hooked on this thing called programming ...

A few Highlights:

  • High performance application server development
  • Model Driven Architecture and Code generators
  • Real-Time Distributed Solutions
  • C, C++, C#, Java, TSQL, PL/SQL, Delphi, ActionScript, Perl, Rexx
  • Microsoft SQL Server, Oracle RDBMS, IBM DB2, PostGreSQL
  • AMQP, Apache qpid, RabbitMQ, Microsoft Message Queuing, IBM WebSphereMQ, Oracle TuxidoMQ
  • Oracle WebLogic, IBM WebSphere
  • Corba, COM, DCE, WCF
  • AspenTech InfoPlus.21(IP21), OsiSoft PI


More information about what I do for a living can be found at: harlinn.com or LinkedIn

You can contact me at espen@harlinn.no

Comments and Discussions