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

Horizontal100stackedbarchart problem

5 Answers 36 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Gary Blakely
Top achievements
Rank 1
Gary Blakely asked on 27 Mar 2010, 11:42 PM

The helper class and code pasted below create a horizontal100bar chart that looks OK except that the left axis does not have the desired label which is a string containg a date contained in the "Played" field.  The line that is commented out is an attempt to insert the dates played as a label on the left YAxis but when included completely messes up the chart.  How can I get the Played values (always 9 of them) to appear on the left?

By the way, If I only show the Birds, the played series prints just fine.
Thanks, Gary
(a .png of the graph produced is attached)   

public class SummarySet
    {
        public SummarySet(string played, string birds, string pars, string bgys, string dbls, string trpls, string othrs)
        {
            this.Played = played;
            this.Birds = birds;
            this.Pars = pars;
            this.Bgys = bgys;
            this.Dbls = dbls;
            this.Trpls = trpls;
            this.Othrs = othrs;
        }
        public string Played { get; set; }
        public string Birds { get; set; }
        public string Pars { get; set; }
        public string Bgys { get; set; }
        public string Dbls { get; set; }
        public string Trpls { get; set; }
        public string Othrs { get; set; }
    }

            SummaryChart.Width = chartWidth * 1.5;
            SummaryChart.Height = chartHeight;
            SummaryChart.DefaultView.ChartTitle.Content = "Summary Last 9 Games";
            SeriesMapping sm = new SeriesMapping();
            sm.SeriesDefinition = new HorizontalStackedBar100SeriesDefinition();
            sm.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Birds" });
            //sm.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.XCategory, FieldName = "Played" });
            sm.LegendLabel = "Birdies";
            SummaryChart.SeriesMappings.Add(sm);

            sm = new SeriesMapping();
            sm.SeriesDefinition = new HorizontalStackedBar100SeriesDefinition();
            sm.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Pars" });
            sm.LegendLabel = "Pars";
            SummaryChart.SeriesMappings.Add(sm);

            sm = new SeriesMapping();
            sm.SeriesDefinition = new HorizontalStackedBar100SeriesDefinition();
            sm.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Bgys" });
            sm.LegendLabel = "Bogeys";
            SummaryChart.SeriesMappings.Add(sm);

            sm = new SeriesMapping();
            sm.SeriesDefinition = new HorizontalStackedBar100SeriesDefinition();
            sm.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Dbls" });
            sm.LegendLabel = "Doubles";
            SummaryChart.SeriesMappings.Add(sm);

            sm = new SeriesMapping();
            sm.SeriesDefinition = new HorizontalStackedBar100SeriesDefinition();
            sm.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Trpls" });
            sm.LegendLabel = "Triples";
            SummaryChart.SeriesMappings.Add(sm);

            sm = new SeriesMapping();
            sm.SeriesDefinition = new HorizontalStackedBar100SeriesDefinition();
            sm.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Othrs" });
            sm.LegendLabel = "Others";
            SummaryChart.SeriesMappings.Add(sm);
                   
            SummaryChart.ItemsSource = data;

5 Answers, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 31 Mar 2010, 01:52 PM
Hi Gary,

There seems to be an issue with the RadChart. We will investigate it.

In the mean time, I suggest the following work-around:
Handle the AxisX.TickPoints.CollectionChanged event and update the text of the tick points.


Regards,
Joshua
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Gary Blakely
Top achievements
Rank 1
answered on 31 Mar 2010, 06:28 PM

Joshua,
Could you show me how to handle the AxisX.TickPoints.CollectionChanged event in C#?  I can't seem to find the object whose events I should subscribe to.  My entire code for producing this chart is pasted below...
Thanks,
Gary

 

 

private void ProcessSummaryChart(GCService.GCServicePlayerDataClass myPlayerDataClass)

 

{

 

var SummaryData = myPlayerDataClass.summaryData;

 

 

List<SummarySet> sdata = new List<SummarySet>();

 

 

foreach (var s in SummaryData)

 

{

sdata.Add(

new SummarySet(s.Played, s.Birds, s.Pars, s.Bgys, s.Dbls, s.Trpls, s.Othrs) );

 

}

CreateSummaryChart(sdata);

}

 

private void CreateSummaryChart(List<SummarySet> data)

 

{

 

SummaryChart.Width = chartWidth * 1.5;

SummaryChart.Height = chartHeight;

SummaryChart.DefaultView.ChartTitle.Content =

"Summary Last 9 Games";

 

 

SeriesMapping sm = new SeriesMapping();

 

sm.SeriesDefinition =

new HorizontalStackedBar100SeriesDefinition();

 

sm.ItemMappings.Add(

new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Birds" });

 

 

//sm.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.XCategory, FieldName = "Played" });

 

 

 

 

sm.LegendLabel =

"Birdies";

 

SummaryChart.SeriesMappings.Add(sm);

sm =

new SeriesMapping();

 

sm.SeriesDefinition =

new HorizontalStackedBar100SeriesDefinition();

 

sm.ItemMappings.Add(

new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Pars" });

 

sm.LegendLabel =

"Pars";

 

SummaryChart.SeriesMappings.Add(sm);

 

sm =

new SeriesMapping();

 

sm.SeriesDefinition =

new HorizontalStackedBar100SeriesDefinition();

 

sm.ItemMappings.Add(

new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Bgys" });

 

sm.LegendLabel =

"Bogeys";

 

SummaryChart.SeriesMappings.Add(sm);

sm =

new SeriesMapping();

 

sm.SeriesDefinition =

new HorizontalStackedBar100SeriesDefinition();

 

sm.ItemMappings.Add(

new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Dbls" });

 

sm.LegendLabel =

"Doubles";

 

SummaryChart.SeriesMappings.Add(sm);

sm =

new SeriesMapping();

 

sm.SeriesDefinition =

new HorizontalStackedBar100SeriesDefinition();

 

sm.ItemMappings.Add(

new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Trpls" });

 

sm.LegendLabel =

"Triples";

 

SummaryChart.SeriesMappings.Add(sm);

sm =

new SeriesMapping();

 

sm.SeriesDefinition =

new HorizontalStackedBar100SeriesDefinition();

 

sm.ItemMappings.Add(

new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Othrs" });

 

sm.LegendLabel =

"Others";

 

SummaryChart.SeriesMappings.Add(sm);

 

SummaryChart.ItemsSource = data;

}

Helper class...

 

 

public class SummarySet

 

 

 

 

{

 

public SummarySet(string played, string birds, string pars, string bgys, string dbls, string trpls, string othrs)

 

{

 

this.Played = played;

 

 

this.Birds = birds;

 

 

this.Pars = pars;

 

 

this.Bgys = bgys;

 

 

this.Dbls = dbls;

 

 

this.Trpls = trpls;

 

 

this.Othrs = othrs;

 

}

 

public string Played { get; set; }

 

 

public string Birds { get; set; }

 

 

public string Pars { get; set; }

 

 

public string Bgys { get; set; }

 

 

public string Dbls { get; set; }

 

 

public string Trpls { get; set; }

 

 

public string Othrs { get; set; }

 

}

0
Dwight
Telerik team
answered on 02 Apr 2010, 08:12 AM
Hi Gary,

Here is a short example on how you can handle changes in tick points collection:
public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();
 
        this.RadChart1.DefaultView.ChartArea.AxisX.TickPoints.CollectionChanged += TickPoints_CollectionChanged;
    }
 
    private void TickPoints_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        foreach (var tickPoint in this.RadChart1.DefaultView.ChartArea.AxisX.TickPoints)
            tickPoint.Label = "aaa";
    }
}


Best,
Joshua
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Gary Blakely
Top achievements
Rank 1
answered on 02 Apr 2010, 04:53 PM
Joshua,
Thanks. That worked fine for now.  BTW, are there any docs on all of the events that can be handled for the various controls.  This would be most useful.
Gary
0
Velin
Telerik team
answered on 07 Apr 2010, 03:14 PM
Hello Gary,

We are constantly extending and improving our documentation. At present it does not cover such topics.

All the best,
Velin
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Chart
Asked by
Gary Blakely
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Gary Blakely
Top achievements
Rank 1
Velin
Telerik team
Share this question
or