[CLOSED] Bar Chart scroll issue

  1. #1

    [CLOSED] Bar Chart scroll issue

    Hi,

    I have bar chart which contains more than 50 columns, chart is not generated properly due to too many columns, therefore i want to add a horizontal scroll bar to chart or its container in which it is loaded.

    So how to add scroll bar to bar chart or its container so that graph becomes in readable format?

    Here is my sample code:

    // Model

    
      public class ChartModel
            {
                public string Name { get; set; }
                public int Data1 { get; set; }
            }

    //Controller

    
       public ActionResult Index()
            {
                return View(GenerateData());
            }
    
            public StoreResult GetData()
            {
                return new StoreResult(GenerateData());
            }
    
            public List<ChartModel> GenerateData() 
            {
                List<ChartModel> lst=new List<ChartModel>();
                ChartModel cm = new ChartModel();
                for (int i = 1; i <= 80; i++)
                {
                    cm = new ChartModel();
                    cm.Name = "Country " + i;
                    cm.Data1 = 100+i;
                    lst.Add(cm);
                }
                return lst;
            }

    // View

    
    
    @{
        ViewBag.Title = "Bar Chart";
        var X = Html.X();
    }
    @(Html.X().ResourceManager(ViewBag.ManagerConfig as MvcResourceManagerConfig))
    
    @{
        <h3>Bar Chart Sample</h3><br />
            
        
    
        @(X.Panel()
            .Title("Column Chart")
            .Layout(LayoutType.Fit)
            .Width(800)
            .Height(600)
            .AutoScroll(true)
            .Items(
                X.Chart()
                    .ID("Chart1")
                    .Shadow(true)
                    .StyleSpec("background:#fff;")
                    .Animate(true)
                    .Store(X.Store()
                        .Data(Model)
                        .Model(X.Model()
                            .Fields(
                                X.ModelField().Name("Name"),
                                X.ModelField().Name("Data1")
                            )
                        )
                        .Proxy(X.AjaxProxy()
                            .Url(Url.Action("GetData"))
                            .Reader(X.JsonReader().Root("data"))
                        )
                    )
                    .Axes(
                        X.NumericAxis()
                            .Fields("Data1")
                            .Grid(true)
                            .Title("Revenue")
                            .Label(X.AxisLabel()
                                .Renderer(r => r.Handler = "return Ext.util.Format.number(value, '0,0');")
                            ),
                        X.CategoryAxis()
                            .Position(Position.Bottom)
                            .Fields("Name")
                            .Title("Month of the Year")
                             .Label(X.AxisLabel()
                                .Rotate(X.RotateAttribute().Degrees(270))
                            )
                           
                    )
                    .Series(X.ColumnSeries()
                        .Axis(Position.Left)
                        .Highlight(true)
                        .XField("Name")
                        .YField("Data1")
                        .Tips(X.ChartTip()
                            .TrackMouse(true)
                            .Width(140)
                            .Height(28)
                            .Renderer(r => r.Handler = "this.setTitle(storeItem.get('Name') + ': ' + storeItem.get('Data1'));")
                        )
                        .Label(X.SeriesLabel()
                            .Display(SeriesLabelDisplay.InsideEnd)
                            .Field(new [] { "Data1" })
                            .Orientation(Orientation.Horizontal)
                            .Color("#333")
                            .TextAnchor("middle")
                            .Renderer(r => r.Handler = "return Ext.util.Format.number(value, '0');")
                        )
                    )
            )
        )
    }
    Thanks
    Last edited by Daniil; Apr 15, 2014 at 11:16 PM. Reason: [CLOSED]
  2. #2
    Hi @PriceRightHTML5team,

    I am afraid a Chart cannot do such scrolling.

    But you can organize scrolling for a Panel.

    Set up .AutoScroll(true) for the Panel and remove its .Layout(LayoutType.Fit) setting.

    Then set up enough width for the Chart and some Height.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @PriceRightHTML5team,

    I am afraid a Chart cannot do such scrolling.

    But you can organize scrolling for a Panel.

    Set up .AutoScroll(true) for the Panel and remove its .Layout(LayoutType.Fit) setting.

    Then set up enough width for the Chart and some Height.
    Thanks Danill, it is working, but is there anyway to set auto width to chart.
  4. #4
    Depending on the amount of Columns in the Chart? I am afraid there is no such functionality.

Similar Threads

  1. Replies: 5
    Last Post: Apr 27, 2016, 12:25 AM
  2. [CLOSED] Treepanel scroll issue
    By bayoglu in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 08, 2013, 9:03 AM
  3. Replies: 3
    Last Post: Dec 19, 2012, 3:01 AM
  4. Border Layout Scroll bar issue in ext.net
    By vs.mukesh in forum 1.x Help
    Replies: 3
    Last Post: Jun 24, 2010, 3:39 PM
  5. GridPanel scroll issue in IE6
    By danielg in forum 1.x Legacy Premium Help
    Replies: 0
    Last Post: May 08, 2009, 11:18 AM

Posting Permissions