This is the discussion forum for OxyPlot.
For bugs and new features, use the issue tracker located at GitHub.
Also try the chat room!

StringFormat instead of formatted value on DateTimeAxis

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

akiss wrote at 2013-09-20 14:14:

Hi,

I've just installed OxyPlot and started experimenting with it. However, with DateTimeAxis, I ran into a strange problem. Whatever I set as StringFormat shows verbatim as the labels below the axis. I.e., if StringFormat=@"D", I see lots of Ds on the chart not the actual dates. If I set the property to null then yyyy appears instead of the years. Any ideas what's gone wrong?

Snipets below.

Thanks,
Akos

XAML:
<oxy:Plot x:Name="chart" Title="A Graph"/>
C#:
PlotModel model = new PlotModel();
var xAxis = new DateTimeAxis(AxisPosition.Bottom, null, @"D", DateTimeIntervalType.Months) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot };
model.Axes.Add(xAxis);
var yAxis = new LinearAxis(AxisPosition.Left, 0.0 / 0.0, 0.0 / 0.0, "Value") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot };
model.Axes.Add(yAxis);
chart.Model = model;
Configuration: Win 7SP1 (Hungarian), VS Pro 2012U3, OxyPlot.Core|Wpf 2013.1.82.1 via NuGet

objo wrote at 2013-09-20 14:46:

Try the latest version, this was fixed yesterday. Egészségedre!
https://oxyplot.codeplex.com/workitem/10077

akiss wrote at 2013-09-20 14:54:

Ahh, amazing response time! Thanks! :)

OxyColors Gradient

Oystein Bjorke hace 10 años actualizado por Lijo hace 7 años 1
This discussion was imported from CodePlex

A7eex wrote at 2013-08-14 10:23:

Hey there,

i'm currently trying to improve the Graphics of my Chart and therefore i wanted to change the PlotAreaBackground to a gradient Color so that it switches from i.e. white to light grey.
This feature is not supported yet, is it? Is there a way to achive this?

Regards Alex

objo wrote at 2013-08-14 10:42:

Sorry, gradients are not supported. I want to keep the rendering API as simple as possible, to make it easy to port to different platforms.

I recommend reading the books of Tufte and Few (links on home page), they have many recommendations about how a chart should be styled. Background gradients is one of the embellishments they don't recommend!

everytimer wrote at 2013-08-14 11:11:

If you really NEED the gradient I think you could set the background to Transparent and add a Rectangle of the same size as the Plot behind with the gradient. I don't consider this a good solution or even a solution, maybe just a patch. Good luck

A7eex wrote at 2013-08-14 11:23:

Thanks for the quick and helpful answers. I think i will just stick with the standard design.

objo wrote at 2013-08-14 21:25:

I thought about it on my way home from work... There is a workaround. Use an ImageAnnotation with an image containing the gradient and stretch it over the plot area.
See the example I just added! (Sorry, I didn't try to make it look pretty :)

A7eex wrote at 2013-08-16 09:56:

Haha! It's great! Good choice of colors! :) No I won't mess up my charts like this but thank you!

Measure rotated labels

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

anomistu wrote at 2012-03-28 16:58:

Just an fyi for this...

If ever you want to set the angle of an axis for displaying rotated major labels, you may want to correct the AxisBase.Measure method with the angle. Here's one quick way to do it:

...

double radians = this.Angle * Math.PI / 180;
var maximumTextSize = new OxySize();
foreach (double v in majorLabelValues)
{
    string s = this.FormatValue(v);
    OxySize size = rc.MeasureText(s, this.ActualFont, this.FontSize, this.FontWeight, this.Angle);
    size = new OxySize(
        Math.Abs(size.Width * Math.Cos(radians) + size.Height * Math.Sin(radians)),
        Math.Abs(size.Width * Math.Sin(radians) + size.Height * Math.Cos(radians)));
...

anomistu wrote at 2012-03-28 18:41:

Fixed (I hope) by bringing to first quadrant:

double radians = Math.Abs(this.Angle) * Math.PI / 180;
var maximumTextSize = new OxySize();
foreach (double v in majorLabelValues)
{
    string s = this.FormatValue(v);
    OxySize size = rc.MeasureText(s, this.ActualFont, this.FontSize, this.FontWeight, this.Angle);
    if (radians > Math.PI / 2)
        radians = Math.PI - radians;
    size = new OxySize(
        size.Width * Math.Cos(radians) + size.Height * Math.Sin(radians),
        size.Width * Math.Sin(radians) + size.Height * Math.Cos(radians));

objo wrote at 2012-03-30 13:23:

thanks, I will have a look at this! But isn't it necessary to check all 4 corners of the text bounding box to get the correct extents?


chage wrote at 2014-02-12 00:19:

Hi guys,
I changed the axis code according to above example to handle rotated label. Things look great on WPF but the PDF export has the label overlapped with the axis, can you advise how to fix this as well?

Image

Displaying message and axes on mouse click on the line serie

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

vboilay wrote at 2014-04-28 17:34:

Hello,
I could not find an example about how to have a text message displaying clicked point coordinates as well as axes exactly like it is done in many examples (normal distribution for instance).
Same issue with finding a click event handler....

This is for winform/C#

The documentation is not easy to navigate. The product itself is stunning !

Thx for the good work.

objo wrote at 2014-04-29 09:17:

Yes, we all know the documentation is far behind. It seems I am the only person working on it, so expect it to take a few more months or years before it is complete... You see I have three small children and very limited spare time at the moment. :-)

To handle click events I recommend using a PlotController. Can somebody explain how to do this for vboilay?

vboilay wrote at 2014-04-29 09:50:

Thanks for your answer. I understand you are gently letting people know that some help would be greatful.
I understand that.
I have myself 2 kids and that is my first time using oxyplot.
Be ensured that by time passing by, if I am getting experienced, I will help the best I can.

Maximum number of LineSeries?

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

AntiqueMapMan wrote at 2014-02-12 02:49:

Hi,

Is there a maximum number of LineSeries in a PlotModel? I added 8, but only the first 5 are displaying. As far as I can tell (and I've checked it a number of times) I'm treating all 8 LineSeries the same.

Thanks,
Dan

AntiqueMapMan wrote at 2014-02-12 21:09:

Never mind. User error.

Thanks,
Dan

Context menu broken in the latest Nuget package?

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

bvsms wrote at 2014-04-03 02:50:

Has anything changed recently with respect to context menus?

The last working Nuget version is 2014.1.229.1. Since then context menus are broken. Has something changed or this is a bug?

objo wrote at 2014-04-03 08:45:

WPF or Silverlight? It is possible this was introduced when we added the "Plot controller" recently. For WPF I expect the bug to be in the OxyPlot.Wpf.Plot.OnMouseUp method. We should add examples with context menu for both WPF and Silverlight.

bvsms wrote at 2014-04-03 08:53:

It was in WPF.

Yes I went to the Silverlight online example (http://www.oxyplot.org/examplebrowser) and tried to look for a "context menu" example to double check but could not find an entry.

objo wrote at 2014-04-03 16:10:

should be fixed. see new example for Wpf.

objo wrote at 2014-04-03 22:26:

sorry, I forgot to add some files. Will fix this tomorrow.

bvsms wrote at 2014-04-04 00:29:

Ok thanks!

Colored background bands

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

antdig wrote at 2012-07-10 22:30:

I've created a line graph to plot data on and it's working well. I'd like to have the background show colored bands to represent red/yellow/green areas. For example, the background of the graph should be red for Y values less than 10; yellow for Y values >= 10 and < 20; green for Y values >= 20.

What's the best way to achieve this?

(Here's a crude example: http://www.csc-scc.gc.ca/text/pblct/rpp/rpp2012-13/images/ex1-eng.jpg )


objo wrote at 2012-07-11 00:24:

This could be done by annotations. I added a "RectangleAnnotation" class - see the example "Annotations | RectangleAnnotation - horizontal bands" in the "Example browser". The code is in the ExampleLibrary/Examples/AnnotationExamples.cs


antdig wrote at 2012-07-11 02:23:

Dude, you rock! That works perfectly.

One thing I noticed is that if I specify the MaximumY parameter as double.MaxValue it didn't plot the RectangleAnnotation. However, this was trivial to solve by omitting the MaximumY parameter.


objo wrote at 2012-07-11 14:50:

I added support also for double.MinValue/MaxValue (same effect as using NaN). I see this is useful when setting only the upper/lower bound. 

Ps. The hatched (pattern) brush in your example is not supported by OxyPlot. 

Watermark

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

bsguedes wrote at 2012-05-25 15:46:

Hello again!

Is it possible to set an image as a watermark background in a plot?

Thanks!


objo wrote at 2012-05-26 08:28:

sorry, image/bitmap rendering is currently not supported (there are some challenges how to implement the bitmap data across the different render contexts (svg, wpf, sl, winforms, pdf etc.)

simple logos could be traced and added as vector graphics (see the Misc|La Linea example in the example browser for an example of a traced image)


bsguedes wrote at 2012-05-28 22:04:

Thanks for the answer! I was trying to solve the shadow grid problem reported on the other thread using a watermark, but now I'll no longer use dotted lines on the grid so it's fine!

0
En revisión

Failed Implementation of Custom/Absolute StairStep Series

Oystein Bjorke hace 10 años actualizado hace 10 años 2
(copied from https://github.com/oxyplot/oxyplot/issues/395)

Camuvingian commented 20 hours ago
I am attempting to create a new plot type in OxyPlot. I essentally need a StairStepSeries, but with any negative values replaces by their Math.Abs value and when this occurs, the line style to reflect this has happened (by using color and or LineStyle). So, to highlight what I want
plotexample
To do this, I have created the two classes (I have pasted actual code used below). This is conceptually easy when you know the tools you are working with, which I don't. My problem is directly related to my improper use of rectangle.DrawClippedLineSegments(). I can get a standard StairStepSeries plotting (copying the internal code) but when I attempt to use the rectangle.DrawClippedLineSegments()intuatively I realise I have not got a clue what this method does or how it is supposed to be used, but can't find any documentation. What is rectangle.DrawClippedLineSegments() doing and how should this method be used?
Any help anyone can provide (esp. changes or ammendments to my non-working class), it would be most appreciated. Thanks for your time.

Multiple Trackers

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

michael75 wrote at 2012-05-16 12:04:

Hi there!

First of all thank you very much for this excellent charting control! I love it!

Now to my question:

I would like to have multiple trackers in a chart available. For example for "measuring" a range. It should be possible to click at the first point and then drag over the data. While doing so, it should display both trackers and show additional data like the range value between the two data points.

How can I achieve this? Do I have to modify the sources or is it possible by customizing the Tracker property of the control?

Thanks in advance for your answers!

Michael


objo wrote at 2012-05-26 08:31:

I think you have to create a custom tracker control here. Then set the DefaultTrackerTemplate property of the Plot control (WPF/SL only).