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

PointMark and SeriesMappings bug ?

3 Answers 121 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Pierre-François
Top achievements
Rank 1
Pierre-François asked on 02 Dec 2009, 10:17 AM
Hi all

I'm still evaluating the chart control. I have multiple LineSeries with PointMarks. I'd like to hide PointMarks for 1 particular serie but it doesn't work. Is there a knew bug ? I just followed the sample provided but it uses DataSeries where I'm using SeriesMapping.

Thanks for your help
Pierre-François

3 Answers, 1 is accepted

Sort by
0
Evan Hutnick
Top achievements
Rank 1
answered on 03 Dec 2009, 08:48 PM
Hi Pierre!

Just to get one note out of the way, if you really need an answer to a question you have the best way to get a sure response from our support staff is by submitting a support ticket.  Depending on your account level you have a certain dedicated response time (72 hours for trial users, but usually faster!).  When posting to the forums, you aren't guaranteed a response time, but at times you can be surprised by how quickly you get answers from community members too.  And while you do see responses from Telerik employees (like me!) on here, their general responsibility is to take care of dedicated support tickets before any time they have to navigate the forums. 

All that being said, I worked up a sample and couldn't find the problem with the pointmarks that you described.  Here's my code for my data item, series definition, and showing/hiding pointmarks based on a button click:

    public partial class MainPage : UserControl  
    {  
        public MainPage()  
        {  
            InitializeComponent();  
 
            SeriesMapping sm1 = new SeriesMapping();  
            sm1.SeriesDefinition = new LineSeriesDefinition();  
            sm1.LegendLabel = "Line Series One";  
            ItemMapping im1 = new ItemMapping("high", DataPointMember.YValue);  
            sm1.ItemMappings.Add(im1);  
 
            SeriesMapping sm2 = new SeriesMapping();  
            sm2.SeriesDefinition = new LineSeriesDefinition();  
            sm2.LegendLabel = "Line Series Two";                        
            ItemMapping im2 = new ItemMapping("mid", DataPointMember.YValue);  
            sm2.ItemMappings.Add(im2);  
 
            SeriesMapping sm3 = new SeriesMapping();  
            sm3.SeriesDefinition = new LineSeriesDefinition();  
            sm3.LegendLabel = "Line Series Three";   
            ItemMapping im3 = new ItemMapping("low", DataPointMember.YValue);  
            sm3.ItemMappings.Add(im3);  
 
            xRadChart.SeriesMappings.Add(sm1);  
            xRadChart.SeriesMappings.Add(sm2);  
            xRadChart.SeriesMappings.Add(sm3);  
 
            xRadChart.ItemsSource = GetItems();  
        }  
 
        private ObservableCollection<ChartItems> GetItems()  
        {  
            ObservableCollection<ChartItems> myCIS = new ObservableCollection<ChartItems>();  
 
            myCIS.Add(new ChartItems(1, 4, 3));  
            myCIS.Add(new ChartItems(4, 7, 6));  
            myCIS.Add(new ChartItems(8, 16, 8));  
            myCIS.Add(new ChartItems(12, 20, 1));  
            myCIS.Add(new ChartItems(4, 3, 20));  
            myCIS.Add(new ChartItems(2, 7, 16));  
            myCIS.Add(new ChartItems(9, 9, 9));  
            myCIS.Add(new ChartItems(3, 5, 1));  
 
            return myCIS;  
        }  
 
        private void Button_Click(object sender, RoutedEventArgs e)  
        {  
            int xy = 0;  
 
            foreach (DataSeries ds in xRadChart.DefaultView.ChartArea.DataSeries)  
            {  
                xy++;  
 
                if (xy == 2)  
                    (ds.Definition as LineSeriesDefinition).ShowPointMarks = !(ds.Definition as LineSeriesDefinition).ShowPointMarks;  
            }  
        }  
    }  
 
    public class ChartItems  
    {  
        public double high { get; set; }  
        public double mid { get; set; }  
        public double low { get; set; }  
 
        public ChartItems(double HIGH, double MID, double LOW)  
        {  
            this.high = HIGH;  
            this.mid = MID;  
            this.low = LOW;  
        }  
    }  

And my XAML is pretty easy, as follows:

<UserControl x:Class="SilverlightApplication2.MainPage" 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:tC="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting" 
             mc:Ignorable="d" 
             d:DesignWidth="640" 
             d:DesignHeight="480">  
    <Grid x:Name="LayoutRoot">  
        <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="6*" /> 
            <ColumnDefinition Width="*" /> 
        </Grid.ColumnDefinitions> 
        <tC:RadChart x:Name="xRadChart" /> 
        <Button Content="Click Me" 
                Grid.Column="1" 
                Click="Button_Click" /> 
    </Grid> 
</UserControl> 

Essentially, when showing/hiding pointmarks, you'll be working with the DataSeries that are present in RadChart after it has been created.  Of course there are other ways to go about this, but this should give you a good example of how to handle the chart series collection and modify individual series.  Also, one important thing to note, different series types have different attributes (for example, Pie series won't have pointmarks), so when doing any sort of modification, if the property doesn't show up, be sure to cast your DataSeries.Definition to the correct X-SeriesDefinition so you can get all that goodness.

Let us know if you need anything else! :)

-Evan
0
Pierre-François
Top achievements
Rank 1
answered on 04 Dec 2009, 08:25 PM
Hi Evan,
Thanks for your answer. The other post was just to challenge someone ;-)
Anyway. Well I don't know why but I ShowPointMarks doesn't work in my code. I finaly found another solution by creating and defining the PointMarks I wan't to use. And when I wan't to hide them, I just use Opacity property for Fill and Stroke.
I'll investigate later to understand ShowPointMarks doesn't work.

Thanks again for your help
Regards
Pierre-François
0
Evan Hutnick
Top achievements
Rank 1
answered on 04 Dec 2009, 08:28 PM
Hey Pierre,

If you'd like, submit a support ticket with the code you're having trouble with and cc hutnick at telerik dot com on it and I'll take a look at your code for you to try and figure out the ShowPointMarks issue. :)

-Evan
Tags
Chart
Asked by
Pierre-François
Top achievements
Rank 1
Answers by
Evan Hutnick
Top achievements
Rank 1
Pierre-François
Top achievements
Rank 1
Share this question
or