Cant get names under my chart

4 posts, 0 answers
  1. Letoir
    Letoir avatar
    6 posts
    Member since:
    Nov 2011

    Posted 21 Dec 2011 Link to this post

    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);

                ChartLegendItem item2 = new ChartLegendItem();
                item2.Label = "This week";
                item2.MarkerFill = new SolidColorBrush(Colors.PaleVioletRed);

                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.DefaultView.ChartLegendPosition = Dock.Bottom;
  2. Bartholomeo Rocca
    Bartholomeo Rocca avatar
    247 posts
    Member since:
    May 2006

    Posted 21 Dec 2011 Link to this post

    Hello Letoir,

    The ItemMapping should be for DataPointMember.XCategory instead of DataPointMember.XValue -- check the following help article here:

  3. Letoir
    Letoir avatar
    6 posts
    Member since:
    Nov 2011

    Posted 21 Dec 2011 Link to this post

    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));
  4. Giuseppe
    Giuseppe avatar
    2363 posts

    Posted 22 Dec 2011 Link to this post

    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,
    the Telerik team

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

Back to Top