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

Cant get names under my chart

3 Answers 65 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Letoir
Top achievements
Rank 1
Letoir asked on 21 Dec 2011, 11:16 AM
I want to add Strings beneath my chart, i dont understand why this doesnt work.

my       sm.ItemMappings.Add(new ItemMapping("Name", DataPointMember.XValue));
Should Show GAS for no.1 and Electricity for no.2
But i cant get it working? im sending u a picture in the picture u can see that the first number is gas and the value for this week and last week and same for number two. I want to change the names to GAS and Electricity
 


 public void GenerateChart()
        {
            SeriesMapping sm = new SeriesMapping();
            sm.LegendLabel = "Comparrison of the Past 7 days, with the folowoing 7 days (€)";
    smartHomeChart.DefaultView.ChartTitle.Content = "Comparison Chart";
            smartHomeChart.DefaultView.ChartLegend.UseAutoGeneratedItems = false;


            ChartLegendItem item1 = new ChartLegendItem();
            item1.Label = "Previous week";
            item1.MarkerFill = new SolidColorBrush(Colors.LightSkyBlue);
            smartHomeChart.DefaultView.ChartLegend.Items.Add(item1);


       
            ChartLegendItem item2 = new ChartLegendItem();
            item2.Label = "This week";
            item2.MarkerFill = new SolidColorBrush(Colors.PaleVioletRed);
            smartHomeChart.DefaultView.ChartLegend.Items.Add(item2);


            smartHomeChart.DefaultView.ChartArea.AxisX.IsDateTime = true;
            smartHomeChart.DefaultView.ChartArea.AxisX.AutoRange = false;
            smartHomeChart.DefaultView.ChartArea.AxisX.MinValue = 40839.00;
            smartHomeChart.DefaultView.ChartArea.AxisX.MaxValue = 40845.00;


            smartHomeChart.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45;
            smartHomeChart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "dd-MMM";
            sm.ItemMappings.Add(new ItemMapping("Name", DataPointMember.XValue));
            sm.ItemMappings.Add(new ItemMapping("DezeWeek", DataPointMember.YValue));
            sm.ItemMappings.Add(new ItemMapping("VorigeWeek", DataPointMember.YValue));
            smartHomeChart.SeriesMappings.Add(sm);

            smartHomeChart.DefaultView.ChartLegendPosition = Dock.Bottom;
        }

3 Answers, 1 is accepted

Sort by
0
Bartholomeo Rocca
Top achievements
Rank 1
answered on 21 Dec 2011, 11:32 AM
Hello Letoir,

The ItemMapping should be for DataPointMember.XCategory instead of DataPointMember.XValue -- check the following help article here: http://www.telerik.com/help/wpf/radchart-features-categorical-charts.html.


Greetings,
Bart.
0
Letoir
Top achievements
Rank 1
answered on 21 Dec 2011, 12:09 PM
no i used this, i get the names under my chart, but now i only have one value.
I had the Lastweek and This week value on the Y axis, but now i only have one value, apparantly its the LastweekValue i think, how can i make them both appear?


            sm.ItemMappings.Add(new ItemMapping("Name", DataPointMember.XCategory));
            sm.ItemMappings.Add(new ItemMapping("ThisWeek", DataPointMember.YValue));
            sm.ItemMappings.Add(new ItemMapping("LastWeek", DataPointMember.YValue));
0
Giuseppe
Telerik team
answered on 22 Dec 2011, 12:11 PM
Hi Letoir,

You cannot add multiple item mappings for DataPointMember.YValue in the same series mapping -- you need to define multiple series mappings (each of them with single item mapping for DataPointMember.YValue) to visualize multiple series properly.

Hope this helps.


All the best,
Giuseppe
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Chart
Asked by
Letoir
Top achievements
Rank 1
Answers by
Bartholomeo Rocca
Top achievements
Rank 1
Letoir
Top achievements
Rank 1
Giuseppe
Telerik team
Share this question
or