0

I am using flot charts and I am having trouble setting the data from my database source. I have a query which comes out with the below:

 ReadDate    Actual      Average
2011-01-12  107132.150  45311.823
2011-01-13  90576.574   46980.152
2011-01-14  89244.989   47226.490

I want to plot this data on a flot graph where the x-axis is the read date, actual is series one and average is series 2. At the moment I am trying to create the expected object as below from this C# List(). The expected structure of the data flot expects is:

var data = [{
    // actual
    data: [[1, 30], [2, 40]],
    color: '#8bc12c',
    points: { radius: 4, fillColor: '#8bc12c' }
},
    // average
    data: [[1, 30], [2, 40]],
    color: '#8bc12c',
    points: { radius: 4, fillColor: '#8bc12c' }
},

You will see this part called data: [[1, 30], [2, 40]] is where I am struggling, here is my C# code:

Decimal[][,] arrays = {
                new Decimal[,] {

                    {1, 30}, 
                    {2, 40}
                },
                 new Decimal[,] {

                    {1, 30}, 
                    {2, 40}
                }
            };

Please see the variances below:

enter image description here

I have to build this object dynamically from the data source. Any help or guidance would be appreciated on this also. Thanks in advance

CR41G14
  • 5,464
  • 5
  • 43
  • 64
  • 1
    How are you creating the JSON string in your C# application? Are you using the built-in .NET JSON serializer? Alternatively, you could use [JSON.NET](http://james.newtonking.com/projects/json-net.aspx), which gives you more control over how the JSON is created. – Dan Jun 12 '13 at 07:57
  • What version of .net are you using, if its 4.5 theres also the JsonValue class. Try this link may help you: http://stackoverflow.com/questions/9573119/how-to-parse-json-without-json-net-library – jjay225 Jun 12 '13 at 09:37
  • This might help you as well - http://stackoverflow.com/questions/14364512/ajax-data-to-flot-chart-in-correct-format – Blake Jun 12 '13 at 14:28

0 Answers0