I will paste the code in here because I am only allowed to attach images to the forum (BTW, how can you attach zip files when "
Allowed extensions: .gif, .jpg, .jpeg, .png"??)
MainPage.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls.Charting;
namespace YAxisCollabsedPlotAreaMouseLeftButtonDown
{
public partial class MainPage : UserControl
{
public List<
SomeInfo
> Data { get; set; }
public MainPage()
{
InitializeComponent();
Data = new List<
SomeInfo
>();
Random r = new Random();
for (int i = 0; i < 10; i++)
{
Data.Add(new SomeInfo(i, r.Next(0, 10)));
}
chart.ItemsSource = Data;
}
protected void ChartArea_PlotAreaMouseLeftButtonDown(object sender, PlotAreaMouseEventArgs e)
{
Point currentPoint = new Point()
{
X = e.XValue,
Y = e.YValue,
};
box.Text = currentPoint.Y.ToString();
}
public class SomeInfo
{
public int XVal { get; set; }
public int YVal { get; set; }
public SomeInfo(int x, int y)
{
this.XVal = x;
this.YVal = y;
}
}
}
}
MainPage.xaml
<
UserControl
x:Class
=
"YAxisCollabsedPlotAreaMouseLeftButtonDown.MainPage"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"400"
>
<
StackPanel
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
TextBox
x:Name
=
"box"
/>
<
telerik:RadChart
x:Name
=
"chart"
BorderThickness
=
"0"
>
<
telerik:RadChart.SamplingSettings
>
<
telerik:SamplingSettings
SamplingThreshold
=
"0"
/>
</
telerik:RadChart.SamplingSettings
>
<
telerik:RadChart.PaletteBrushes
>
<
SolidColorBrush
Color
=
"Red"
/>
<
SolidColorBrush
Color
=
"Green"
/>
<
SolidColorBrush
Color
=
"Yellow"
/>
</
telerik:RadChart.PaletteBrushes
>
<
telerik:RadChart.SeriesMappings
>
<
telerik:SeriesMapping
ItemsSource
=
"{Binding Serie}"
LegendLabel
=
"{Binding LegendName}"
>
<
telerik:SeriesMapping.SeriesDefinition
>
<
telerik:LineSeriesDefinition
ShowItemLabels
=
"False"
ShowPointMarks
=
"False"
/>
</
telerik:SeriesMapping.SeriesDefinition
>
<
telerik:ItemMapping
FieldName
=
"XVal"
DataPointMember
=
"XValue"
/>
<
telerik:ItemMapping
FieldName
=
"YVal"
DataPointMember
=
"YValue"
/>
</
telerik:SeriesMapping
>
</
telerik:RadChart.SeriesMappings
>
<
telerik:RadChart.DefaultView
>
<
telerik:ChartDefaultView
ChartLegendPosition
=
"Bottom"
>
<
telerik:ChartDefaultView.ChartArea
>
<
telerik:ChartArea
PlotAreaMouseLeftButtonDown
=
"ChartArea_PlotAreaMouseLeftButtonDown"
LegendName
=
"ChartLegendCoManShutIn"
BorderThickness
=
"0,10,0,0"
EnableAnimations
=
"False"
Padding
=
"0,0,10,5"
SmartLabelsEnabled
=
"False"
>
<
telerik:ChartArea.AxisY
>
<
telerik:AxisY
Visibility
=
"Collapsed"
MinValue
=
"0"
MaxValue
=
"10"
AutoRange
=
"False"
Step
=
"1"
/>
</
telerik:ChartArea.AxisY
>
<
telerik:ChartArea.AxisX
>
<
telerik:AxisX
Title
=
"Time"
MinValue
=
"0"
MaxValue
=
"10"
AutoRange
=
"False"
Step
=
"1"
/>
</
telerik:ChartArea.AxisX
>
</
telerik:ChartArea
>
</
telerik:ChartDefaultView.ChartArea
>
<
telerik:ChartDefaultView.ChartLegend
>
<
telerik:ChartLegend
BorderThickness
=
"0"
Header
=
"Legend"
x:Name
=
"ChartLegendCoManShutIn"
/>
</
telerik:ChartDefaultView.ChartLegend
>
</
telerik:ChartDefaultView
>
</
telerik:RadChart.DefaultView
>
</
telerik:RadChart
>
</
StackPanel
>
</
UserControl
>
I added a TextBox above the chart which contains the value of the Y position when you click on the chart.
If you run with the Y axis collabsed it give you negative numbers
If you run the application with a visible Y axis you get the correct values
Thanks for the help.
Michele