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

How to ensure square plot area?

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

viklele wrote at 2012-11-20 07:47:

Hi,

In my application, I need to ensure that the actual plot area where the chart is drawn in always square.

Please advice - sample code welcome.

Thanks,

Warm Regards,

- Vikram


objo wrote at 2012-11-26 06:12:

I think you can change the "PlotMargins" of the plot each time the size of the plot changes...

Or make sure the size of the control is square (handle the sizechanged event on the control or override the coerce value callbacks on the width/height dependency properties?). 


viklele wrote at 2012-11-26 06:42:

Thanks for your reply.

 

I understand that I need to adjust plot margins in resize event of the control. I am not clear about the calculation. I have adjusted margins using height / width of the control, and height / width of the title area. This still does not make the plot area square. Here is my calculation:

        private void AdjustPoincareChartMargins(Plot plot, double dWidth, double dHeight)
        {
            Debug.WriteLine("Available W: " + dWidth + ", H: " + dHeight);

            plot.Model.IsLegendVisible = false;
            var availableWidth = dWidth;
            var availableHeight = dHeight - plot.Model.TitleArea.Height;

            var horzMargin = Math.Max(0, (availableWidth - availableHeight)) / 2;
            var vertMargin = Math.Max(0, (availableHeight - availableWidth)) / 2;

            plot.Model.PlotMargins = new OxyPlot.OxyThickness(horzMargin, vertMargin, horzMargin, vertMargin);

            Debug.WriteLine("Plot W: " + plot.Model.PlotArea.Width + ", H: " + plot.Model.PlotArea.Height);
            Debug.WriteLine("PlotAndAxisArea W: " + plot.Model.PlotAndAxisArea.Width + ", H: " + plot.Model.PlotAndAxisArea.Height);
        }

Thanks,
- Vikram
 

Scatter Series and HeatMap

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

Artiga wrote at 2013-08-19 10:53:

Hello!

When I tried to plot a scatter Series and a HeatMap together, the scatter points are not visible, how I fix that?

Thx for all !!!

objo wrote at 2013-08-19 11:01:

Try to add the scatter series after the heatmap series. Does that help?

Artiga wrote at 2013-08-19 11:13:

No, I think the problem is with the ColorAxis (needed for HeatMap) because if I add a ColorAxis to the PlotModel, even if i dont add the HeatMap series, the scatter points become "invisibles" ...

Artiga wrote at 2013-08-19 12:04:

Hi, I found the problem, I must pass a value to the ScatterPoint constructor, so now it works, thx =D

Is it possible or planned...

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

ffiala wrote at 2012-02-21 07:45:

  • ...to overlay different ploting series in one ploting area?
  • ...to add annotations to each datapoint?
  • ...to position these annotations outside of the ploting area?

The result shoud be something like this: ExampleChart


objo wrote at 2012-02-23 21:08:

Yes, you can overlay any number of plotting series in the same plot - it should not be any problem to combine line, scatter points and columns (bar) series as in your example.

You can create a string for each data point that will be shown when you use the mouse tracker, but currently only the BarSeries has the ability to render labels (will add this to the other series later).

You can create your own custom annotatiosn that renders in screen coordinates, anywhere in the control area.

You could also create a custom x-axis to render the club names. Simply override the Render method.


ffiala wrote at 2012-02-26 12:56:

I have now an OxyPlot version of my plot: 
LastGmes
Using the Oxyplot library without changes of source code. 
Thank You for support, Franz

Can't programmatically binding to OxyPlot properties

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

richardfen wrote at 2014-03-25 00:18:

I want to create a databinding programmatically for the LineSeries.Color property. The LineSeries.Color property must be a dependency property because you can bind to it in XAML. However, if I want to create a binding dynamically in code-behind, I need the static property LineSeries.ColorProperty. For example, the WPF TextBox.Text has an analogous TextBox.TextProperty. But Intellisense shows no LineSeries.ColorProperty.

objo wrote at 2014-03-25 20:58:

See OxyPlot.Wpf.Series.ColorProperty. It is public and the type is System.Windows.Media.Color

richardfen wrote at 2014-03-26 19:35:

thanks for your quick reply. I tried your solution and in order to get it to work we must use OxyPlot.Wpf.LineSeries (because it a DependencyObject and that is required for DataBinding). I used the following code:
            var ls = new OxyPlot.Wpf.LineSeries();
            var b = new Binding();
            b.Source = mySourceObject;
            b.Path = new PropertyPath("Color");           
            b.Mode = BindingMode.TwoWay;
            ls.SetBinding(OxyPlot.Wpf.Series.ColorProperty, b);

This code compiles perfectly but when I try to add the LineSeries to the model it won't compile:
           PlotModel model
           model.Series.Add(ls)
I get an error telling me that "ls" is the wrong type. It is expecting the non-WPF LineSeries. I have looked for a WPF version of PlotModel but can't find any. Thanks for you help.

objo wrote at 2014-03-26 20:55:

No, you cannot add a OxyPlot.Wpf.LineSeries to the OxyPlot.PlotModel. Try adding the "ls" to the Series collection in your OxyPlot.Wpf.Plot control.
0
Under review

The TrackerControl template must contain a content container exception

panbac88 9 years ago updated 9 years ago 3
Hi again,

I am using OxyPlot.WIndowsUniversal 2014.1.546.0 in a win8.1 project. I am trying to create a chart witth a category axis, a linear axis and a line series. Below is the code that creates the chart.

 var chartModel = new PlotModel();              

            CategoryAxis categAxis = new CategoryAxis();
            categAxis.Position = AxisPosition.Bottom;
            categAxis.ItemsSource = chartvm.DateValues;
            categAxis.LabelField = "MN";
            categAxis.IsTickCentered = true;
            categAxis.IsZoomEnabled = false;
            categAxis.IsPanEnabled = false;
            categAxis.MaximumPadding = 0;
            categAxis.MinimumPadding = 0;
            
            chartModel.Axes.Add(categAxis);


            LinearAxis linAxis = new LinearAxis();
            linAxis.Position = AxisPosition.Left;
            linAxis.IsPanEnabled = false;
            linAxis.IsZoomEnabled = false;
            linAxis.MaximumPadding = 0;
            linAxis.MinimumPadding = 0;
            linAxis.LabelFormatter = ((double d) => String.Format("{0:0.00€}", d));
            chartModel.Axes.Add(linAxis);          


            var series = new AreaSeries
            {
                Color = OxyColor.FromArgb(255, 78, 154, 6),
                DataFieldX2 = "OxySeriesValue",
                DataFieldY2 = "OxyZeroValue",
                DataFieldX = "OxySeriesValue",
                DataFieldY = "Value",
               
                MarkerType = MarkerType.Circle,
                MarkerSize=3,          
                MarkerFill = OxyColor.FromRgb(0, 117, 235),
                
                ItemsSource = chartvm.DateValues,
            };
            series.Color = OxyColor.FromRgb(0, 117, 235);
            series.Color2 = OxyColor.FromRgb(0, 117, 235);
                       
            chartModel.Series.Add(series);          
            
            var children = AllChildren(ChartSection);
            PlotView plotView = children[8] as PlotView;
            plotView.Model = chartModel;
            
It all works well until the tracker is required to show. Whrn that happens the following exception occurs.

System.InvalidOperationException: The TrackerControl template must contain a content container with name +'PART_ContentContainer'
at OxyPlot.WindowsUniversal.TrackerControl.OnApplyTemplate()

Does anybody know why the exception is thrown??

Thanks in advance !!
0
Under review

OxyPlot.XamarinFormsAndroid error LinkAssemblies

Fernando García 10 years ago updated 10 years ago 2
Hi,

I just installed the OxyPlot NuGet packages in my project (a XamarinForms PCL) and I get this error when I try to compile:

Error
1
Error inesperado en la tarea "LinkAssemblies".
Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item 'Xamarin.Forms.Platform.Android.ViewRenderer`2' (defined in 'OxyPlot.XamarinFormsAndroid, Version=2014.1.517.0, Culture=neutral, PublicKeyToken=null') from 'OxyPlot.XamarinFormsAndroid, Version=2014.1.517.0, Culture=neutral, PublicKeyToken=null' could not be resolved.
en Xamarin.Android.Diagnostic.Error(Int32 code, String message, Object[] args)
en Xamarin.Android.Tasks.LinkAssemblies.Execute()
en Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
en Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()
Chupeta.Android

If I remove OxyPlot.XamarinFormsAndroid from the references of the Android project it compiles fine, but then I can't use OxyPlot (I can't make the call to OxyPlot.XamarinFormsAndroid.Forms.Init(); )

Thanks.

OxyPlot.WPF.RectangleAnnotation no text when using code

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

DShawNitec wrote at 2013-06-01 01:13:

We are converting over from the 1.3 version to 2.0. In 1.3 we had made a WPF version from LineAnnotation which work ok but we are trying to use the supplied 2.0 version.
The rectangle shows with the correct outline color and fill color in the right location but no text.
Plot has a DateTimeAxis at the bottom, normal vertical axis on left.
We are using the following:
                ra = new OxyPlot.Wpf.RectangleAnnotation();
                ra.MinimumX = OxyPlot.Axes.DateTimeAxis.ToDouble(ll);
                ra.MaximumX = OxyPlot.Axes.DateTimeAxis.ToDouble(llW);
                ra.MinimumY = yBot;
                ra.MaximumY = yTop;
                ra.Fill = Colors.White;
                ra.Stroke = Colors.Black;
                ra.StrokeThickness = 2;
                ra.ClipToBounds = false;
                ra.Text = " Case Colors";
                ra.Layer = AnnotationLayer.AboveSeries;
                ra.TextRotation = 0.0;
                CaseComparePlot.Annotations.Add(ra);
Any suggestions on what's missing?

DShawNitec wrote at 2013-06-03 18:22:

Found the problem llW was bigger than maximum on the DateTime axis which caused the text to not appear. Our old version clipped on the axes so we never saw it.

objo wrote at 2013-06-08 10:53:

The text should be centered on the visible part of the rectangle.

Change axis textcolor in OxyPlot for WPF

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

Artholl wrote at 2014-07-07 22:50:

Hi, I have one question. How is it possible to change color of axis text color in WPF? In OxyPlot.dll you have Axis.TextColor property which comes from OxyPlot.PlotElement class. But in OxyPlot.Wpf.dll you don't have Axis.TextColor property. Probably because Axis is not inherited from OxyPlot.PlotElement class but from System.Windows.FrameworkElement class.
So my question is: Is there some way how I can achieve this?

I also posted question on StackOverflow.

objo wrote at 2014-07-10 12:40:

This should be covered by https://oxyplot.codeplex.com/workitem/9999. There is a lot of properties not yet covered.
I also think we should add a OxyPlot.Wpf.PlotElement class and let the Axis class inherit from this!

Artholl wrote at 2014-07-10 13:12:

OK, thanks. Good to know that.

oxyplot - 2014.1.245.1 get_ActualFont Error

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

nithinshiriya wrote at 2014-03-12 21:12:

Getting below error any guess?.

Object reference not set to an instance of an object.
at OxyPlot.PlotElement.get_ActualFont() in c:\TeamCity\buildAgent\work\3b9fcf1ba397d0ed\Source\OxyPlot\PlotModel\PlotElement.cs:line 106
at OxyPlot.Axes.Axis.Measure(IRenderContext rc) in c:\TeamCity\buildAgent\work\3b9fcf1ba397d0ed\Source\OxyPlot\Axes\Axis.cs:line 985
at OxyPlot.PlotModel.MaxSizeOfPositionTier(IRenderContext rc, IEnumerable1 axesOfPositionTier) in c:\TeamCity\buildAgent\work\3b9fcf1ba397d0ed\Source\OxyPlot\PlotModel\PlotModel.Rendering.cs:line 174
at OxyPlot.PlotModel.AdjustAxesPositions(IRenderContext rc, IList1 parallelAxes) in c:\TeamCity\buildAgent\work\3b9fcf1ba397d0ed\Source\OxyPlot\PlotModel\PlotModel.Rendering.cs:line 249
at OxyPlot.PlotModel.AdjustPlotMargins(IRenderContext rc) in c:\TeamCity\buildAgent\work\3b9fcf1ba397d0ed\Source\OxyPlot\PlotModel\PlotModel.Rendering.cs:line 212
at OxyPlot.PlotModel.Render(IRenderContext rc, Double width, Double height) in c:\TeamCity\buildAgent\work\3b9fcf1ba397d0ed\Source\OxyPlot\PlotModel\PlotModel.Rendering.cs:line 76
at OxyPlot.Wpf.Plot.UpdateVisuals() in c:\TeamCity\buildAgent\work\3b9fcf1ba397d0ed\Source\OxyPlot.Wpf\Plot.cs:line 1119
at OxyPlot.Wpf.Plot.ArrangeOverride(Size arrangeBounds) in c:\TeamCity\buildAgent\work\3b9fcf1ba397d0ed\Source\OxyPlot.Wpf\Plot.cs:line 564
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)

New Release documentation

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

njh86 wrote at 2014-06-13 12:56:

I need to know what changes have been made between the last and current releases, as I am now using the updated library but my project wont build.

Apparently OxyPlot.WindowsForms.Plot is deprecated, amongst other errors.

Can anyone point me in the direction of a change log as I can't seem to find any?

Thanks

objo wrote at 2014-06-14 08:55:

See Source code -> History
https://oxyplot.codeplex.com/SourceControl/list/changesets

I would like to auto create a description of all changes in each build, but I have not found a way to do this yet. Need a map between build numbers and hg changeset numbers...