views:

515

answers:

1

Hi I would like to know how can i do to set the label for X axis and y axis?

Righ now, i have a chart with the values, and I format the tooltip, but i can't realize how to set the label for X an Y axis.

Another thing is, Is posible to execute zooming in a chart series, I mean, if i have the x axis in years, i would like to change it to months, or semesters and new points need to appear in the line? if this is posible, is too dificult to do it?

+2  A: 

I haven't able to set the label of the y axis (I don't think its possible) but you could set it on the legend using the Title property. On the x axis it depends on the binding set on your DataPointSeries'IndependentValueBinding.

Lets say on this sample I have created a class object that will represent every record/datapoint.

public class ChartInfo
{
    public string Label { get; set; }
    public double Value { get; set; }
}

Then I have this code:

List<ChartInfo> list = new List<ChartInfo>();
ChartInfo item = new ChartInfo();
item.Label = "Individual";
item.Vale = 27;
list.Add(item);
item = new ChartInfo();
item.Label = "Corporate";
item.Vale = 108;
list.Add(item);

DataPointSeries series = new ColumnSeries();
series.Title = "Quantity";
series.DependentValueBinding = new Binding("Value");
series.IndependentValueBinding = new Binding("Label");
series.ItemsSource = list;
series.SelectionChanged += new SelectionChangedEventHandler(series_SelectionChanged);
this.chartingToolkitControl.Series.Add(series);

It will give me this result.

alt text

For the zooming - I think the right term is drill-down. You could use the SelectionChanged event (see the code above). What you should do is requery your datasource and clear the graph's series and add a new one based on your query result.

private void series_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        //The sender here is of type DataPointSeries wherein you could get the SelectedItem (in our case ChartInfo) and from there you could do the requery.
    }
Jojo Sardez
Thanks for your answer, it really helpme. and I hadn't thought the zoom in that way. Thanks.
Clerks
@Clerks - if the answer helped you don't forget to vote it up and mark it as the accepted answer of your question :)
Jojo Sardez