ScatterPointSeries and X Axis as strings

7 posts, 1 answers
  1. Jatinder
    Jatinder avatar
    12 posts
    Member since:
    Oct 2011

    Posted 28 Dec 2011 Link to this post

    Hi

    My itemsSource for a ScatterPointSeries is IList<Tuple<string,int>>

    I want to have the x axis to be the individual string items. I am not sure how to accomplish this. I tried to swap the horizontalAxis CategoryAxis but that doesnt seem to do anything.

    my data looks somewhat like this: (IList<Tuple<string,int>>) 

    apples,2

    oranges,5

    pears,3

    apples,10 (have a second point in the x-value apples)

    etc

    Please advice how this can be done.
    I didnt try to use the Charting 2d scatter graph yet - is this scenario possible with that instead of the chartview??

    My xaml i am using 

    <chart:RadCartesianChart Palette="Metro">
                <chart:RadCartesianChart.HorizontalAxis>
                    <chartview:CategoricalAxis Title="Fruits"/>
                </chart:RadCartesianChart.HorizontalAxis>
                <chart:RadCartesianChart.VerticalAxis>
                    <chartview:LinearAxis Title="Some Value"/>
                </chart:RadCartesianChart.VerticalAxis>
      
      
                <chartview:ScatterPointSeries ItemsSource="{Binding Items}" x:Name="series"
                                              XValueBinding="Item1"
                                              YValueBinding="Item2"/>
            </chart:RadCartesianChart>

  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 29 Dec 2011 Link to this post

    Hello Jatinder,

    The ScatterPointSeries is designed to work with numerical XY axes and cannot visualize categorical information.

    Generally you can achieve the desired appearance by using categorical LineSeries with transparent line stroke, however, note that neither RadChartView, nor RadChart will visualize multiple x-entries for the same categorical value (i.e. both "Apples" entries will be drawn onto the same x position -- you will need to provide different categorical values in order to render the items into different categories i.e. "Apples" and "Apples " are considered different).

    We have attached a sample application to get you started as well.


    Regards,
    Giuseppe
    the Telerik team

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

  3. DevCraft banner
  4. Jatinder
    Jatinder avatar
    12 posts
    Member since:
    Oct 2011

    Posted 29 Dec 2011 Link to this post

    Hi Giuseppe

    That is unfortunate that the ScatterPointSeries is only designed to work with numerical XY and not support the CategoricalAxis. I did try the RadChart version and it supports the CategorixalAxis with string based values and works. I would assume that they would work almost the same.

    As for your attached solution, actually i might have explained the desired behavior wrong - see the attached png for what i am hoping to accomplish. 

    the graph should still behave like a scatter graph, in my case with multiple y vlaues for the same x e.g (2,3), (2,4), (2,8) but in my scenario the '2' is actually a string like (apples,3), (apples,4) and (apples,8). I've also attached another png that shows my end goal with the amount of data i have(dummy data).

    I really hope there is a way this can be done with the ChartView.

  5. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 29 Dec 2011 Link to this post

    Hello Jatinder,

    In this case the default categorical behavior of the LineSeries should achieve the desired effect -- check the attached modified sample application.

    Hope this helps.


    Kind regards,
    Giuseppe
    the Telerik team

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

  6. Jatinder
    Jatinder avatar
    12 posts
    Member since:
    Oct 2011

    Posted 29 Dec 2011 Link to this post

    Hi Giuseppe

    Wow that worked like a charm.

    Although looking at the code and xaml - it looks exactly like what your previous sample was.

    What change did you make to have the behavior different from the first sample??

  7. Answer
    Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 29 Dec 2011 Link to this post

    Hello Jatinder,

    The only change is in the actual categorical values -- the original sample contained strings like "Apples" and "Apples " (with trailing whitespace) that are considered different categories in RadChartView, while the modified sample contains only "Apples" (thus all entries with this category are rendered at the same x-position).


    Kind regards,
    Giuseppe
    the Telerik team

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

  8. Jatinder
    Jatinder avatar
    12 posts
    Member since:
    Oct 2011

    Posted 29 Dec 2011 Link to this post

    I was looking really hard to see what the difference was but the trailing space evaded me.

    Thanks again

Back to Top
DevCraft banner