#region Properties
public double Value
{
get { return _value; }
set { _value = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
#endregion Properties
How would I go about using the property 'Name' for the label and 'Value' for the point. I've tried using PointTemplates and LabelTemplates with no luck. I'd like to be able to specify a label and value for a pie, line, and bar chart. Any help?
10 Answers, 1 is accepted
Thanks for writing.
Please use the LabelDeifinitions property. It also allows you to define a label template. The data context of your label template is a PieDataPoint. This point has a DataItem property which contains a reference to your view model. Here is a simple example:
<
chart:RadPieChart
x:Name
=
"chart"
Palette
=
"Warm"
>
<
chart:PieSeries
ValueBinding
=
"Value"
>
<
chart:PieSeries.LabelDefinitions
>
<
chart:ChartSeriesLabelDefinition
>
<
chart:ChartSeriesLabelDefinition.Template
>
<
DataTemplate
>
<
TextBlock
Text
=
"{Binding DataItem.Name}"
/>
</
DataTemplate
>
</
chart:ChartSeriesLabelDefinition.Template
>
</
chart:ChartSeriesLabelDefinition
>
</
chart:PieSeries.LabelDefinitions
>
</
chart:PieSeries
>
</
chart:RadPieChart
>
this
.chart.Series[0].ItemsSource =
new
ViewModel[]
{
new
ViewModel() { Value = 5, Name =
"Item 1"
},
new
ViewModel() { Value = 10, Name =
"Item 2"
},
new
ViewModel() { Value = 15, Name =
"Item 3"
},
};
Please write again if you need further assistance. Regards,
Victor
the Telerik team
Two final questions:
First, is there a simple property that I can set so that the labels rotate for a bar categories? So instead of them display out horizontally they display vertically?
Second, do you have a simple example of date and time and categorical for a line chart?
Thanks,
Darin
You horizontal axis has a LabelRotationMode property. You can set it to multi line or rotate, this should do the trick.
Can you please explain in more detail about the line chart example? What is your exact requirement?
Victor
the Telerik team
So these changes are for a workout app that I'm working on. Another thing I'd like to display is the weight change per time you complete a workout or the time change per time you complete a workout.
Please have a look at the attached archive. It demonstrates a simple chart that displays values for certain days.
Basically there are two axes that you can use and these are DateTimeCategoricalAxis and DateTimeContinuousAxis. You can read more about them here. Also, feel free to check out the source code of our Examples app, it is included with the RadControls installation.
If you have more questions feel free to write again.
Victor
the Telerik team
I want to be able to display progress on a workouts time. For example, I have the workout 800m run. The first time I got on it was 6:20. The second was 4:30. I want to be able to show this improvement on the line chart. However, the Y-axis takes in a double and not a TimeSpan.
Thanks for writing.
Since the vertical axis cannot be another categorical axis it must be a linear axis. As you mention a linear axis cannot display a date time value. This means that you simply have to convert your DateTime value to a double. It can be ticks, seconds, minutes or whatever you find convenient. You can then convert back to a date time with a simple value converter in order to have proper labels.
Victor
Telerik
I have answered your question in the other threads you posted.
Regards,Victor
Telerik