BarSeries and IsVisible

4 posts, 0 answers
  1. Valery
    Valery avatar
    53 posts
    Member since:
    May 2011

    Posted 23 May 2018 Link to this post

    Create BarSeries:

                _barModel = new BarSeries
                {
                    ValueMember = "Model",
                    CategoryMember = "N",
                    LegendTitle = "Model",

         IsVisible = false
                };
                _radChartViewGss.Series.Add(_barModel);

    Set data source (dataTable):

                _radChartViewGss.DataSource = _table;

    After this, changing the property _barModel.IsVisible = true does not lead to anything - the bar series is not visible.

     

    Why???

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3469 posts

    Posted 24 May 2018 Link to this post

    Hello, Valery,    

    In order to load the chart's layout properly in the form's constructor, it is recommended to manipulate the series' visibility after the DataSource is applied and after calling the RadChartView.LoadElementTree method. Thus, the axis' information will be loaded as expected. Here is a sample code snippet which result is illustrated in the attached gif file:
    DataTable table;
    BarSeries barSeries = new BarSeries();
     
    public RadForm1()
    {
        InitializeComponent();
        table = new DataTable();
        table.Columns.Add("Value", typeof(double));
        table.Columns.Add("Name", typeof(string));
        table.Rows.Add(1, "John");
        table.Rows.Add(3, "Adam");
        table.Rows.Add(5, "Peter");
        table.Rows.Add(12, "Sam");
        table.Rows.Add(6, "Paul");
       
     
        radChartView1.Series.Add(barSeries);
        barSeries.ValueMember = "Value";
        barSeries.CategoryMember = "Name";  
     
        this.radChartView1.DataSource = table;
        this.radChartView1.LoadElementTree();
        barSeries.IsVisible = false;
    }
     
    private void radToggleButton1_ToggleStateChanged(object sender, Telerik.WinControls.UI.StateChangedEventArgs args)
    {
        if (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
        {
            barSeries.IsVisible = true;
        }
        else
        {
            barSeries.IsVisible = false;
        }
    }

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Zim
    Zim avatar
    7 posts
    Member since:
    May 2018

    Posted 20 Sep 2018 Link to this post

    We don’t yet support individually styled bars on the series (though it’s something we’re keen to include in a future version).  That said, you can still get the effect you want by using two series and stacking them rather than putting them next to each other (which is the default).  
  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3469 posts

    Posted 21 Sep 2018 Link to this post

    Hello, Zim,  

    By default, all bar elements that belong to the same series have one common color. Thus, it is easy to distinguish which element to which series belong. However, you can iterate the BarSeries.Children collection and specify a separate color for each BarPointElement. As a result, all bars may be colored differently:

    Random rand = new Random();
    private void RadForm1_Load(object sender, EventArgs e)
    {
        foreach (BarPointElement barElement in this.radChartView1.Series[0].Children)
        {
            barElement.BackColor = Color.FromArgb(rand.Next(0, 255), rand.Next(0, 255), rand.Next(0, 255));
        }
    }



    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top