Where is YAxisKey used and how
This discussion was imported from CodePlex
Ambron wrote at 2014-03-06 06:12:
I see plenty reference to YAxisKey, but I cannot find an implemented series that have this property; what am I missing?
maddog56 wrote at 2014-03-11 01:54:
Ambron,
The key is used to link (or key) an axis to a series. This will insure that the series all appear in the plot area. In this example I have 3 x-axes and 1 y-axis in a single plot, with the x-axes at the bottom of the chart laid in "tiers". You can see how I used the key property.
For i = 1 To 3
For i = 1 To 3
The key is used to link (or key) an axis to a series. This will insure that the series all appear in the plot area. In this example I have 3 x-axes and 1 y-axis in a single plot, with the x-axes at the bottom of the chart laid in "tiers". You can see how I used the key property.
For i = 1 To 3
Dim ax As LinearAxis
ax = New LinearAxis(AxisPosition.Bottom, 0, 50*i, "Title")
ax.Key = "key" & i.ToString
ax.PositionTier = i - 1
ax.IsZoomEnabled = False
ax.Font = "Trebuchet MS"
ax.FontSize = 12.0
ax.FontWeight = OxyPlot.FontWeights.Bold
ax.TitleFont = "Trebuchet MS"
ax.TitleFontSize = 12.0
ax.TitleFontWeight = OxyPlot.FontWeights.Bold
myModel.Axes.Add(ax)
Next For i = 1 To 3
Dim lineSeries0 As New LineSeries()
lineSeries0.Title = "Title"
lineSeries0.Color = OxyColors.Black
lineSeries0.StrokeThickness = 1.25
lineSeries0.MarkerFill = OxyColors.Red
lineSeries0.MarkerSize = 5.0
lineSeries0.MarkerStroke = OxyColors.DarkGray
lineSeries0.MarkerStrokeThickness = 1.0
lineSeries0.MarkerType = MarkerType.Circle
For j = 0 To dataseriesC.Points.Count - 1
dp = dataseriesC.Points(j)
lineSeries0.Points.Add(dp)
Next
lineSeries0.CanTrackerInterpolatePoints = False
lineSeries0.XAxisKey = "key" & i.ToString
myModel.Series.Add(lineSeries0)
NextAmbron wrote at 2014-03-11 03:55:
That is indeed how I understood it should work.
I probably should have added some more detail; in the .Net OxyPlot assemblies (notably OxyPlot.Wpf ) there is no XAxisKey property for a lineSeries
Hence the question, what am I missing?
I probably should have added some more detail; in the .Net OxyPlot assemblies (notably OxyPlot.Wpf ) there is no XAxisKey property for a lineSeries
Hence the question, what am I missing?
Ambron wrote at 2014-03-11 04:01:
To elaborate:
I have a ViewModel that creates an
var dateAxis = new OxyPlot.Axes.DateTimeAxis(AxisPosition.Bottom, "Time", "HH:mm")
I have a ViewModel that creates an
var dateAxis = new OxyPlot.Axes.DateTimeAxis(AxisPosition.Bottom, "Time", "HH:mm")
{
MajorGridlineStyle = LineStyle.Solid,
MinorGridlineStyle = LineStyle.Dot,
IntervalLength = 80
};
var tempAxis = new OxyPlot.Axes.LinearAxis(AxisPosition.Left, "Temperature") {Key = "Temp"};
var humAxis = new OxyPlot.Axes.LinearAxis(AxisPosition.Right, "Humidity") {Key = "Hum"};
model.Axes.Add(dateAxis);
model.Axes.Add(tempAxis);
model.Axes.Add(humAxis);
Ambron wrote at 2014-03-11 04:10:
apologies, browser playing up.. So I create the OxyModel in a ViewModel which I den populate with line-series, based on the location and whether it is a temperature or Humidity.
so when the data comes in I add the points with something like this, where I would want to use YAxisKey
private static void AddNamedValue(PlotModel plotModel, string name, DateTime time, decimal value)
so when the data comes in I add the points with something like this, where I would want to use YAxisKey
private static void AddNamedValue(PlotModel plotModel, string name, DateTime time, decimal value)
{
var s = plotModel.Series.FirstOrDefault(ms => ms.Title == name);
if (s == null)
{
s = new OxyPlot.Series.LineSeries { Title = name };
//if (name.StartsWith("Hum"))
// s.YAxisKey = "Hum";
plotModel.Series.Add(s);
}
var ls = s as OxyPlot.Series.LineSeries;
ls.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(time), (Double)value));
}
Customer support service by UserEcho