Custom draw axis labels
nicolasr75 wrote at 2013-09-10 22:20:
I really appreciate the possibility to have four y-axes using the PositionTier property (two axes on the left and two on the right)
My problem is that the user can not tell to which axis a specific series is bound.
Does anyone have experience how to solve this?
A friend suggested I should have small, colored squares behind the axis titles to indicate the associated series.
But this would require that I custom draw the axis titles? Any idea how to do this?
thanks in advance!
Nicolas
everytimer wrote at 2013-09-10 22:41:
objo wrote at 2013-09-11 20:21:
It is possible to subclass the axis and override the rendering, but I see the HorizontalAndVerticalAxisRenderer need some refactoring to make it easier (the RenderAxisTitle method is not overridable).
@everytimer: good suggestion, note also that the color of the axis title can be set to match the series that use the axis
See also
https://oxyplot.codeplex.com/workitem/9192
nicolasr75 wrote at 2013-09-11 20:35:
@everytimer: very interesting ideas, I will think about them and do some tests with it...
@objo: so you say it is in principle possible to render the axis myself? Could you give me a hint which classes in which files implement the original rendering?
Maybe an intermediate solution would be to duplicate the code in my derived class. By the way: this is for maximally four vertical axes and currently only for WPF.
Nicolas
objo wrote at 2013-09-11 20:43:
Render
method. You see the current implementation in Axis.cs
Your derived class will work on all platforms.
nicolasr75 wrote at 2013-09-11 20:52:
Nicolas
objo wrote at 2013-09-11 21:14:
nicolasr75 wrote at 2013-09-12 00:04:
For a first try I have derived special implementations from LinearAxis and HorizontalAndVerticalRenderer.
I have overridden the Render methods and call the base classes methods. After that I call my rendering code for colored rectangles that represent the associated series. I had to use Reflection to get at some internal properties of the Axis class though.
This seems to work fine for now!
thanks again for your help!
Null reference error
BlindMonk wrote at 2013-09-04 12:49:
polygonAnnotation1.Points.Add(new OxyPlot.DataPoint(8,-4));
Full error:System.NullReferenceException was unhandled
Message=Object reference not set to an instance of an object.
Source=sepsi
StackTrace:
at sepsi.ArrToImage.arraytoImageCon(List`1 dataIn, Int32 wid, Int32 ht, Boolean isAmp) in E:\projects\nstest\nstest\MainWindow.xaml.cs:line 1611
at sepsi.MeanData.listToImage(Int32 wid, Int32 ht) in E:\projects\nstest\nstest\MainWindow.xaml.cs:line 799
at sepsi.MainWindow.processfocfile(GBSFile fObj) in E:\projects\nstest\nstest\MainWindow.xaml.cs:line 601
at sepsi.MainWindow.<.ctor>b__2(Object o, EventArgs`1 args) in E:\projects\nstest\nstest\MainWindow.xaml.cs:line 84
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at sepsi.FileListWindow.Button_Click(Object sender, RoutedEventArgs e) in E:\projects\nstest\nstest\fileList.xaml.cs:line 74
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at sepsi.App.Main() in E:\projects\nstest\nstest\obj\x86\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
at System.Activator.CreateInstance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
objo wrote at 2013-09-04 20:03:
BlindMonk wrote at 2013-09-05 12:14:
WPF and Oxyplot: graph with CategoryAxis and LogarithmicAxis
Hello everyone,
PDFs on Mono
evolvedmicrobe wrote at 2013-07-17 17:50:
I wanted to run by/suggest some ideas for getting oxyplot to work on mono.
Right now, the PDF generation fails in mono because PDFSharp uses the User32.dll file to get some binary information to embed in the PDF for the various fonts. Myself and others have tried to work around this by either 1) Embedding the font information ahead of time in the PDF assembly, or 2) Grabbing the information directly from the font files on the local machine in a platform specific way.
Unfortunately, it seems that the results are still not up to par... and the rendering is much better on windows. I think this might have to do with the GDI library in mono not behaving the same way as the windows one, but it's a pretty buried problem and I can't track it down.
I was thinking of investing more time in it, but it also seemed to me that perhaps just switching over to a different PDF generating library, such as iTextSharp, to do the rendering. It seems shapes are possible as in here:
http://www.mikesdotnetting.com/Article/88/iTextSharp-Drawing-shapes-and-Graphics
I wanted to ask if other people have attempted PDF rendering on Mono though, to see if they had any insights on the ease or feasibility of either:
1) Trying to switch to iTextSharp
2) Trying to get PDFSharp to render correctly.
3) Deciding the problem is too much work to invest in.
Does anyone have any thoughts or experience in how hard any of these might be? (hours/days??)
objo wrote at 2013-07-19 08:24:
I would like to see the following changes rather than spending time on iTextSharp and PDFSharp
- change OxyPlot text rendering so text alignment does not depend on text measurements
- include a small pdf exporter that can render lines, fill polygons and render text in the OxyPlot core library (PCL). I did some prototyping some time ago, and it seems feasible (but the text/font handling is probably the hardest part). See pdf reference
evolvedmicrobe wrote at 2013-07-25 17:22:
I wound up using a hacked version of pdfsharp described here: http://forum.pdfsharp.net/viewtopic.php?f=4&t=1206&p=7289#p7289 that works, provided one tells it where to find the fonts on the local system, which is something of a pain. I don't think embedding the fonts works either because mono uses X11 to do the drawing, and they may not match.
Looks like this is more than I can handle now though so will have to leave the issue for now. Thanks for the response though!
Draw a graphic from an equation
FrankiAA wrote at 2013-04-04 11:16:
y = ax³ + bx² + cx + d = 0.
What's the best and the easiest way to do that?
i saw examples with cos, sin,... but it's not really what i'm look for i guess...
Thanks.
objo wrote at 2013-04-18 09:57:
new FunctionSeries( x => a*x*x*x + b*x*x + c*x + d, .... )
IsAxisVisible property not working when binding to Model
sargent wrote at 2014-06-16 04:26:
IsAxisVisible not working
<oxy:Plot Width="600" Height="200" Margin="0" Model="{Binding UserPlotModel}">
<oxy:Plot.Axes>
<oxy:DateTimeAxis Position="Bottom"
StringFormat="hh:mm:ss"
IsAxisVisible="false"
Maximum="{Binding PlotTimeMax}"
Minimum="{Binding PlotTimeMin}"/>
<oxy:LinearAxis Position="Left" IsAxisVisible="false"/>
</oxy:Plot.Axes>
</oxy:Plot>
In other plots where I am binding through the ItemSource the IsAxisVisible property works fine. It appears to be an isolated case when binding to Model. Am I doing something wrong or is there a work around for this?IsAxisVisible Working
<oxy:Plot Width="600" Height="200" Margin="0">
<oxy:Plot.Axes>
<oxy:DateTimeAxis Position="Bottom" StringFormat="hh:mm:ss"/>
<oxy:LinearAxis Position="Left" IsAxisVisible="True"/>
</oxy:Plot.Axes>
<oxy:LineSeries ItemsSource="{Binding PartsPerHourDataPoints}"/>
</oxy:Plot>
objo wrote at 2014-06-16 09:59:
Model
property should override all the properties and collections (annotations, axes, series) of the
PlotView
, so I think this is working as intended. But I have created https://oxyplot.codeplex.com/workitem/10222, I think this should generate a runtime error (exception).
See also https://oxyplot.codeplex.com/workitem/10128
sargent wrote at 2014-06-19 03:57:
Copyright holder
objo wrote at 2014-02-16 14:43:
When other collaborators contribute with large portions of code, it feels strange to list my name there. And I guess they also want to be released from liability.
I also want to encourage contributions, and it may be strange to create a major fature and put my name in the copyright text...
Should it be changed?
a. more generic text like "OxyPlot contributors"? then list contributors in a separate file?
b. list of all contributors on each file? it is more work to keep track of it, cannot replace by general header
stephenroe wrote at 2014-02-24 21:15:
Copyright (c) 2014 OxyPlot.org
and then maintain a CONTRIBUTORS file located in the root of the project?
objo wrote at 2014-02-25 08:30:
like
http://golang.org/CONTRIBUTORS
http://golang.org/AUTHORS
http://golang.org/LICENSE
Another alternative: Copyright (c) 2014 The OxyPlot Authors.
Should there be a CLA?
http://en.wikipedia.org/wiki/Contributor_License_Agreement
objo wrote at 2014-02-25 20:41:
stephenroe wrote at 2014-02-25 23:33:
Copyright (c) 2014 jQuery foundation and other contributors
Going in this direction would allow you to keep your name as the major copyright holder. For example:
Copyright (c) 2014 Oystein Bjorke and other contributors
At the end of the day, due to source control, it is very easy to identify each authors contribution.
http://stackoverflow.com/questions/2228188/finding-the-author-of-a-line-of-code-in-mercurial
objo wrote at 2014-02-27 20:32:
The list in the CONTRIBUTORS file was compiled from the Hg history, but it is very possible some contributors are missing. Please send me a notification to be added to the CONTRIBUTORS or AUTHORS lists. Also let me know about other improvements. (CLA?)
I am currently reading "Producing OSS" by Karl Fogel and my goal is simply to get more collaborators on the project!
http://www2.econ.iastate.edu/tesfatsi/producingoss.karlfogel2005.pdf
http://www.amazon.com/Producing-Open-Source-Software-Successful/dp/0596007590
Bug: In Annotations - No Clipping Demo
ckoo wrote at 2012-03-12 07:38:
When you drag the plot, half of the plot remains frozen, which leads to the situation where you can have two origins on the same plot. The plot area seems to be divided into 4 separate quadrants, each with their own behaviour.
objo wrote at 2012-03-12 07:48:
This is the desired behaviour. There are four axes in this plot, and we are testing that the annotation lines are extended across the whole plot area.
ckoo wrote at 2012-03-12 10:51:
OK. Looks very confusing at first. Thanks for the clarification.
Misbehaviour of the Heatmap series
geopars wrote at 2013-05-21 22:58:
First of all a big bravo for the project. You have done an amazing job.
I experienced an interesting misbehavior of the heatmap series. When you are adding a symmetric matrix, the heatmap series generated is not completely correct since it is slightly shifted.
Here is the code that I used to generate the above image.
public static PlotModel SymmetricHeatmap()
{
double x0 = 0;
double x1 = 16;
double y0 = 0;
double y1 = 16;
var random = new Random();
var data = new double[17,17];
for (var i = 0; i < 17; i++)
{
data[i, i] = 0.0;
}
for (var i = 1; i < 17; i++)
{
for (var j = 0; j < i; j++)
{
var num = random.NextDouble();
data[i, j] = num;
data[j, i] = num;
}
}
var model = new PlotModel("Peaks");
model.Axes.Add( new ColorAxis
{
Position = AxisPosition.Right,
Palette = OxyPalettes.Hot(500),
HighColor = OxyColors.Gray,
LowColor = OxyColors.Black
});
model.Series.Add(new HeatMapSeries { X0 = x0, X1 = x1, Y0 = y0, Y1 = y1, Data = data });
return model;
}
Also I had to change the Render override of the HeatmapSeries in order to get the colors to align correctly according to the axis.public override void Render(IRenderContext rc, PlotModel model)
{
if (this.Data == null)
{
this.image = null;
return;
}
var left = this.X0;
var right = this.X1;
var bottom = this.Y0;
var top = this.Y1;
var s00 = this.Transform(left, bottom);
var s11 = this.Transform(right, top);
var rect = OxyRect.Create(s00, s11);
if (this.image == null || this.Data.GetHashCode() != this.dataHash)
{
this.UpdateImage();
this.dataHash = this.Data.GetHashCode();
}
if (this.image != null)
{
var clip = this.GetClippingRect();
rc.DrawClippedImage(clip, this.image, rect.Left, rect.Top, rect.Width, rect.Height, 1, true);
}
}
x-axis in descending order
yt2 wrote at 2013-08-13 16:39:
I'm using oxyplot for some scientific stuff with C# and WPF. I'm looking for a way to sort the x-axis in descending order (ex. 720 to 400).
I tried a lot of things and did a research on the web - but didn't find any way to solve this. Could you please help me?
Thanks
Nico
everytimer wrote at 2013-08-13 20:05:
You need to set the StartPosition and EndPosition of your axis to 1 and 0 respectively. Then if you want you can set the Minimum/Maximum. Good luck
yt2 wrote at 2013-08-14 10:35:
Служба підтримки клієнтів працює на UserEcho