The code pasted below produces a chart that looks ok but has two problems:
1. The legend works as a tooltip ok but I can't figure out how to put a label on the two series in the legend. I've tried everything I can think of. With the new 2010 version it shows the two colors but has no label.
2. The Category doesn't print on the x axis (just like it doesn't on your "binding to objects totorial") How can I get the category to print.
I've been through a lot of your chart totorials but didn't find the answer there. Should I have?
Thanks,
Gary Blakely
Helper class...
public class CompareSet
{
public CompareSet(string category, double? you, double? others)
{
this.Category = category;
this.You = you;
this.Others = others;
}
public string Category { get; set; }
public double? You { get; set; }
public double? Others { get; set; }
}
Code that produces chart...
private void ProcessPar345Chart(GCService.GCServicePlayerDataClass myPlayerDataClass)
{
var Par345data = myPlayerDataClass.par345Data;
List<CompareSet> data = new List<CompareSet>();
data.Add(new CompareSet("Par3's", Par345data[0].P3sY, Par345data[0].P3sG));
data.Add(new CompareSet("Par4's", Par345data[0].P4sY, Par345data[0].P4sG));
data.Add(new CompareSet("Par5's", Par345data[0].P5sY, Par345data[0].P5sG));
CreatePar345Chart(data);
}
private void CreatePar345Chart(List<CompareSet> data)
{
Par345Chart.Width = chartWidth;
Par345Chart.Height = chartHeight;
Par345Chart.DefaultView.ChartTitle.Content = "Par 345";
//The legend takes up too much space. Remove it and make it appear as a tooltip...
ChartLegend toolTipLegend = new ChartLegend()
{
Background = new SolidColorBrush(Colors.Black),
Height = 100,
Width = 200,
};
ChartLegendItem CItem1 = new ChartLegendItem(); //that don't work
CItem1.Label = "You";
//toolTipLegend.Items[0].Label = "You";
//toolTipLegend.Items[1].Label = "Others";
ToolTip toolTip = new ToolTip()
{
Content = toolTipLegend,
Style = this.LayoutRoot.Resources["CustomToolTipStyle"] as Style,
};
ToolTipService.SetToolTip(Par345Chart, toolTip);
Par345Chart.DefaultView.ChartLegend.Visibility = Visibility.Collapsed;
Par345Chart.DefaultView.ChartArea.Legend = toolTipLegend;
Par345Chart.ItemsSource = data;
}