This is a migrated thread and some comments may be shown as answers.

BarSeries and IsVisible

3 Answers 121 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Valery
Top achievements
Rank 1
Veteran
Valery asked on 23 May 2018, 12:13 PM

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???

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 May 2018, 09:54 AM
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.
0
Zim
Top achievements
Rank 1
answered on 20 Sep 2018, 04:20 PM
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).  
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 21 Sep 2018, 08:16 AM
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.
Tags
ChartView
Asked by
Valery
Top achievements
Rank 1
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Zim
Top achievements
Rank 1
Share this question
or