[CLOSED] Chart examples data bind

  1. #1

    [CLOSED] Chart examples data bind

    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?
    Last edited by Daniil; Oct 27, 2015 at 2:01 PM. Reason: [CLOSED]
  2. #2
    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.MonthNames[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.MonthNames[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;
            }
        }
    }
  3. #3

    Chart Examples

    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!!
  4. #4
    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.

Similar Threads

  1. Bind Chart in Javascript
    By amarchavan in forum 2.x Help
    Replies: 12
    Last Post: Apr 19, 2014, 7:26 PM
  2. Chart Examples not found
    By Rupesh in forum 1.x Help
    Replies: 1
    Last Post: Jun 14, 2012, 7:25 PM
  3. Replies: 0
    Last Post: Apr 22, 2012, 9:39 AM
  4. Replies: 1
    Last Post: Dec 11, 2011, 6:45 AM
  5. Replies: 0
    Last Post: Jun 19, 2009, 4:18 AM

Posting Permissions