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

ScatterPointSeries and X Axis as strings

6 Answers 157 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Jatinder
Top achievements
Rank 1
Jatinder asked on 28 Dec 2011, 07:49 PM

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>

6 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 29 Dec 2011, 11:05 AM
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 >>

0
Jatinder
Top achievements
Rank 1
answered on 29 Dec 2011, 03:33 PM

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.

0
Giuseppe
Telerik team
answered on 29 Dec 2011, 03:56 PM
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 >>

0
Jatinder
Top achievements
Rank 1
answered on 29 Dec 2011, 04:14 PM

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??

0
Accepted
Giuseppe
Telerik team
answered on 29 Dec 2011, 04:39 PM
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 >>

0
Jatinder
Top achievements
Rank 1
answered on 29 Dec 2011, 04:45 PM

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

Thanks again

Tags
ChartView
Asked by
Jatinder
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Jatinder
Top achievements
Rank 1
Share this question
or