PDA

View Full Version : [CLOSED] Chart examples data bind



speedstepmem4
Oct 07, 2015, 6:15 AM
Hello,


We are trying to add the chart in our application, but most of the examples data fill from following functions




<%# Ext.Net.Examples.ChartData.GenerateData() %>



where can we find this?

Daniil
Oct 07, 2015, 12:28 PM
Hi @speedstepmem4,

Please use:

using System;
using System.Collections.Generic;
using System.Globalization;

namespace Ext.Net.Examples
{
public class ChartData
{
public string Name
{
get;
set;
}

public double Data1
{
get;
set;
}

public double Data2
{
get;
set;
}

public double Data3
{
get;
set;
}

public double Data4
{
get;
set;
}

public double Data5
{
get;
set;
}

public double Data6
{
get;
set;
}

public double Data7
{
get;
set;
}

public double Data8
{
get;
set;
}

public double Data9
{
get;
set;
}

public static List<ChartData> GenerateData()
{
return ChartData.GenerateData(12, 20);
}

public static List<ChartData> GenerateData(int n)
{
return ChartData.GenerateData(n, 20);
}

public static List<ChartData> GenerateData(int n, int floor)
{
List<ChartData> data = new List<ChartData>(n);
Random random = new Random();
double p = (random.NextDouble() * 11) + 1;

for (int i = 0; i < n; i++)
{
data.Add(new ChartData
{
Name = CultureInfo.InvariantCulture.DateTimeFormat.MonthN ames[i % 12],
Data1 = Math.Floor(Math.Max(random.NextDouble() * 100, floor)),
Data2 = Math.Floor(Math.Max(random.NextDouble() * 100, floor)),
Data3 = Math.Floor(Math.Max(random.NextDouble() * 100, floor)),
Data4 = Math.Floor(Math.Max(random.NextDouble() * 100, floor)),
Data5 = Math.Floor(Math.Max(random.NextDouble() * 100, floor)),
Data6 = Math.Floor(Math.Max(random.NextDouble() * 100, floor)),
Data7 = Math.Floor(Math.Max(random.NextDouble() * 100, floor)),
Data8 = Math.Floor(Math.Max(random.NextDouble() * 100, floor)),
Data9 = Math.Floor(Math.Max(random.NextDouble() * 100, floor))
});
}

return data;
}

public static List<ChartData> GenerateDataNegative()
{
return ChartData.GenerateDataNegative(12, 20);
}

public static List<ChartData> GenerateDataNegative(int n, int floor)
{
List<ChartData> data = new List<ChartData>(n);
Random random = new Random();
double p = (random.NextDouble() * 11) + 1;

for (int i = 0; i < n; i++)
{
data.Add(new ChartData
{
Name = CultureInfo.InvariantCulture.DateTimeFormat.MonthN ames[i % 12],
Data1 = Math.Floor(Math.Max((random.NextDouble() - 0.5) * 100, floor)),
Data2 = Math.Floor(Math.Max((random.NextDouble() - 0.5) * 100, floor)),
Data3 = Math.Floor(Math.Max((random.NextDouble() - 0.5) * 100, floor)),
Data4 = Math.Floor(Math.Max((random.NextDouble() - 0.5) * 100, floor)),
Data5 = Math.Floor(Math.Max((random.NextDouble() - 0.5) * 100, floor)),
Data6 = Math.Floor(Math.Max((random.NextDouble() - 0.5) * 100, floor)),
Data7 = Math.Floor(Math.Max((random.NextDouble() - 0.5) * 100, floor)),
Data8 = Math.Floor(Math.Max((random.NextDouble() - 0.5) * 100, floor)),
Data9 = Math.Floor(Math.Max((random.NextDouble() - 0.5) * 100, floor))
});
}

return data;
}
}
}

speedstepmem4
Oct 12, 2015, 9:57 AM
Hi Daniil,


Thanks for the reply.


Can you please provide a independent source code which includes .aspx page that help us to have a look on the entire working of Chart?
We used your sample code and ended up with some compilation errors.

Hope you help us!!

Daniil
Oct 12, 2015, 10:07 AM
Please clarify what exactly compilation errors.


Can you please provide a independent source code which includes .aspx page that help us to have a look on the entire working of Chart

A standalone .aspx page? Well, it should be possible, but it will require modification of the .aspx page that you copy from Examples Explorers. You'll need to modify it each time. Really, it would be simpler to put that GenerateData code into an individual .cs file and get it compiled. Then you'll be able to just copy, paste and run the Chart examples without any changes.