Oxyplot - simple column chart - labels not appearing for highest value (ios but may happen in other systems)
lpinho wrote at 2014-01-09 15:46:
I'm working with Xamarin and using this fantastic lib.
I'm using it for a few months without any problem, I'm now making my iPhone version of my application and when I plot it in the horizontal, the labels for the top value are not plotted/drawn.
I set the Frame background to green and the plot area background to white just to help to understand how I'm doing things.
Do you have any idea of what I can do to make these labels visible?
-Already tried to set padding and plot margins to 0 and I also tried not to set them at all.
Not working:
Working:
Code in draw method:
public override void Draw(System.Drawing.RectangleF rect)
{
base.Draw(rect);
KPIItemCollection dataSource = new KPIItemCollection();
if (kpiCollectionPerTimeScale != null)
{
dataSource = GetSourceForChart();
}
UIColor selectedColor;
string selectedFormat;
Utilities.ColorAndFormatPicker(KPIType, out selectedColor, out selectedFormat);
selectedColor = UIColor.FromRGBA(0f / 255f, 80f / 255f, 140f / 255f, 1.000f);
PlotModel plotModel = new PlotModel();
plotModel.TitleFont = "HelveticaNeue-Light";
plotModel.Background = OxyColor.FromRgb(242, 242, 242);
plotModel.PlotAreaBackground = OxyColors.White; //OxyColor.FromRgb(242, 242, 242);
if (isPhone)
{
plotModel.PlotMargins = new OxyThickness(15, 0, 15, 20);
plotModel.Padding = new OxyThickness(0, 0.25 * this.Frame.Height, 0, 0);
}
else
{
plotModel.Padding = new OxyThickness(0, 0.25 * this.Frame.Height, 0.08 * this.Frame.Width, 0);
}
plotModel.PlotAreaBorderThickness = 0;
plotModel.Axes.Add(new CategoryAxis
{
ItemsSource = dataSource,
LabelField = "Name",
AxislineStyle = LineStyle.Solid,
AxislineThickness = 0.1,
GapWidth = 0.15,
TickStyle = TickStyle.None,
});
if (isPhone)
{
plotModel.Axes[0].FontSize = 8;
}
plotModel.Axes.Add(new
LinearAxis(AxisPosition.Left)
{
IsAxisVisible = true,
AxislineThickness = 1,
TextColor = OxyColors.Transparent,
TickStyle = TickStyle.None,
AxislineColor = OxyColors.Transparent,
});
plotModel.DefaultFont = "HelveticaNeue-Light";
plotModel.Series.Add(new ColumnSeries
{
ItemsSource = dataSource,
ValueField = "Value",
FillColor = Utilities.FromUiColor(selectedColor),
LabelPlacement = LabelPlacement.Outside,
LabelFormatString = selectedFormat,
FontSize = isPhone ? 10 : 20,
TextColor = Utilities.FromUiColor(selectedColor),
});
plotModel.Update(true);
var renderer = new MonoTouchRenderContext(UIGraphics.GetCurrentContext());
plotModel.Render(renderer, rect.Width, rect.Height);
}
Thanks for your help, L. Pinho
objo wrote at 2014-01-10 09:17:
https://oxyplot.codeplex.com/workitem/10113
I think a workaround is to increase the
MaximumPadding
of the vertical axis.objo wrote at 2014-01-10 09:18:
lpinho wrote at 2014-01-10 09:44:
Thanks again for the help, I just love this library, I couldn't believe it when I found it, its flexible, it works and its free. This is a great asset for open source community.
Sure, when I publish it I will share it with you.
How to disable scroll in plotview?
I would like to disable the possibility to scroll/zoom in my plotview. I dont want the user to scroll/zoom away from the graph by misstake.
Is this possible?
How to make a plot fill its available area in WPF?
seveland12 wrote at 2013-04-11 17:07:
Using DateTimeIntervalType.Manual
SteveReedSr wrote at 2014-07-07 05:25:
My graphs display specific date ranges based upon user selection of 1 day, 3 day, 7 day, or 1 month. When 1 day is selected, I want ticks every 6 hours, when 3 day every 24 hours, etc.
I've seen an example where someone overrides the GetTickValues method, but it seems that the Axis is setup to allow manual values. But HOW?
I'm using Xamarin on Android, and the graphs work very well! Great tool, just need to do some minor tweaking of the labels and I'll be done!
SteveReedSr wrote at 2014-07-16 06:25:
Plotting data stream received by a serial port
JohnnyPP wrote at 2012-11-01 21:27:
Hello,
I would like to plot data stream received by a serial port with sampling rate set to 1 Hz. Data stream is generated by a digital temperature sensor TMP102 connected to a microcontroller. The microcontroller sends the temperature values to the PC through serial port. In windows forms there is serial port control which I use to receive the data. All works well, with one exception the plot shows only last value received by the serial port. I am aware that the code I use right now is not optimized to draw a line between received points. I read other similar threads dealing with displaying real time data like:
http://oxyplot.codeplex.com/discussions/398856
http://oxyplot.codeplex.com/discussions/281036
http://oxyplot.codeplex.com/discussions/350457
I also looked at Realtimedemo and Refreshdemo. The answers and code are somehow confusing and complex (I am more involved in hardware than in software).
So my question is: how can I connect data points with a line? I would like to keep the code it as simple as possible.
Thanks in advance!
The code I use:
// -------------------------------------------------------------------------------------------------------------------- // <copyright file="Form1.cs" company="OxyPlot"> // http://oxyplot.codeplex.com, license: Ms-PL // </copyright> // -------------------------------------------------------------------------------------------------------------------- using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System; using System.Windows.Forms; using OxyPlot; using System.Globalization; namespace WindowsFormsDemo { public partial class Form1 : Form { private int i = 0; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { serialPort1.PortName = "COM3"; serialPort1.BaudRate = 9600; serialPort1.DtrEnable = true; serialPort1.Open(); serialPort1.DataReceived += serialPort1_DataReceived; } private void button2_Disconnect_Click(object sender, EventArgs e) { if (serialPort1.IsOpen) { serialPort1.Close(); } } private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { string line = serialPort1.ReadLine(); this.BeginInvoke(new LineReceivedEvent(LineReceived), line); } private delegate void LineReceivedEvent(string line); private void LineReceived(string line) { double dTemperature, dTemperatureRound; try { dTemperature = double.Parse(line, CultureInfo.InvariantCulture); dTemperatureRound = Math.Round(dTemperature, 4); label1.Text = Convert.ToString(dTemperatureRound); var pm = new PlotModel("TMP102 digital temperature sensor", "Temperature data stream") { PlotType = PlotType.Cartesian, Background = OxyColors.White, }; var linearAxisX = new LinearAxis(); linearAxisX.Title = "Sample number"; linearAxisX.Position = AxisPosition.Bottom; linearAxisX.MajorGridlineColor = OxyColor.FromArgb(40, 0, 0, 139); linearAxisX.MajorGridlineStyle = LineStyle.Solid; linearAxisX.MinorGridlineColor = OxyColor.FromArgb(20, 0, 0, 139); linearAxisX.MinorGridlineStyle = LineStyle.Solid; pm.Axes.Add(linearAxisX); var linearAxisY = new LinearAxis(); linearAxisY.Title = "Temperature [°C]"; linearAxisY.Position = AxisPosition.Left; linearAxisY.MajorGridlineColor = OxyColor.FromArgb(40, 0, 0, 139); linearAxisY.MajorGridlineStyle = LineStyle.Solid; linearAxisY.MinorGridlineColor = OxyColor.FromArgb(20, 0, 0, 139); linearAxisY.MinorGridlineStyle = LineStyle.Solid; pm.Axes.Add(linearAxisY); var lineSeries1 = new LineSeries(); lineSeries1.Color = OxyColor.FromArgb(255, 78, 154, 6); lineSeries1.MarkerFill = OxyColor.FromArgb(255, 78, 154, 6); lineSeries1.MarkerStroke = OxyColors.ForestGreen; lineSeries1.MarkerType = MarkerType.Circle; lineSeries1.StrokeThickness = 2; lineSeries1.DataFieldX = "Date"; lineSeries1.DataFieldY = "Value"; lineSeries1.Points.Add(new DataPoint(i, dTemperatureRound)); pm.Series.Add(lineSeries1); plot1.Model = pm; i++; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } }
objo wrote at 2012-11-01 21:41:
I would suggest to create the PlotModel, axes and LineSeries in your form constructor. Call plot1.InvalidatePlot(true) to refresh. Something like this (not tested):
public class Form1 : Form { private readonly LineSeries lineSeries1; private int i; public Form1() { InitializeComponent(); var pm = new PlotModel("TMP102 digital temperature sensor", "Temperature data stream") { PlotType = PlotType.Cartesian, Background = OxyColors.White }; var linearAxisX = new LinearAxis(); linearAxisX.Title = "Sample number"; linearAxisX.Position = AxisPosition.Bottom; linearAxisX.MajorGridlineColor = OxyColor.FromArgb(40, 0, 0, 139); linearAxisX.MajorGridlineStyle = LineStyle.Solid; linearAxisX.MinorGridlineColor = OxyColor.FromArgb(20, 0, 0, 139); linearAxisX.MinorGridlineStyle = LineStyle.Solid; pm.Axes.Add(linearAxisX); var linearAxisY = new LinearAxis(); linearAxisY.Title = "Temperature [°C]"; linearAxisY.Position = AxisPosition.Left; linearAxisY.MajorGridlineColor = OxyColor.FromArgb(40, 0, 0, 139); linearAxisY.MajorGridlineStyle = LineStyle.Solid; linearAxisY.MinorGridlineColor = OxyColor.FromArgb(20, 0, 0, 139); linearAxisY.MinorGridlineStyle = LineStyle.Solid; pm.Axes.Add(linearAxisY); this.lineSeries1 = new LineSeries(); this.lineSeries1.Color = OxyColor.FromArgb(255, 78, 154, 6); this.lineSeries1.MarkerFill = OxyColor.FromArgb(255, 78, 154, 6); this.lineSeries1.MarkerStroke = OxyColors.ForestGreen; this.lineSeries1.MarkerType = MarkerType.Circle; this.lineSeries1.StrokeThickness = 2; this.lineSeries1.DataFieldX = "Date"; this.lineSeries1.DataFieldY = "Value"; pm.Series.Add(this.lineSeries1); plot1.Model = pm; } private void button1_Click(object sender, EventArgs e) { serialPort1.PortName = "COM3"; serialPort1.BaudRate = 9600; serialPort1.DtrEnable = true; serialPort1.Open(); serialPort1.DataReceived += this.serialPort1_DataReceived; } private void button2_Disconnect_Click(object sender, EventArgs e) { if (serialPort1.IsOpen) { serialPort1.Close(); } } private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) { string line = serialPort1.ReadLine(); this.BeginInvoke(new LineReceivedEvent(this.LineReceived), line); } private void LineReceived(string line) { double dTemperature, dTemperatureRound; try { dTemperature = double.Parse(line, CultureInfo.InvariantCulture); dTemperatureRound = Math.Round(dTemperature, 4); label1.Text = Convert.ToString(dTemperatureRound); this.lineSeries1.Points.Add(new DataPoint(this.i, dTemperatureRound)); plot1.InvalidatePlot(true); this.i++; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private delegate void LineReceivedEvent(string line); }
[HeatMapSeries] having different max in Data and ColorAxis
I'd like to have different max (and min) in Data and ColorAxis.
Of course the colors should still be corresponding.
For example, the max Data value could be 50 (yellow) and the max of ColorAxis could be 100 (red)
Is that possible ?
Thx,
Gingko
Oxyplot apis
tantrum wrote at 2012-11-06 14:52:
Hi,
I am new to oxyplot i am finding it hard to find oxyplot apis.
Can anybondy help .
I work on visual studios.
objo wrote at 2012-11-06 19:57:
I recommend looking at the WPF examples - in Source\Examples\WPF
Start with the "SimpleDemo". Also see the "ExampleBrowser", it shows the source that creates all the plots (this is also useful if you use OxyPlot on other platforms).
Updates to the documentation/wiki pages are planned, but this will still take some time...
OxyPlot.Wpf 2013.1.32.1 cannot load System.Core 2.0.5.0
Jeltz wrote at 2013-02-16 02:55:
Just used Nuget to update Oxyplot.WPF to 2013.1.32.1 and the wpf xaml now complains cannot load System.Core version 2.0.5.0 , so I have had to go back to the older Oxyplot version to fix it. Seems related to a Silverlight issue, but I do not and never have used Silverlight.
I can now confirm this happens between Oxyplot.WPF version 2013.1.10.1 which does not have this problem, and version 2013.1.11.1 which does have this problem.
Did this happen when Oxyplot went to a common library for Silverlight/WPF and has anyone else had this problem/hints to fix for latest Oxyplot release?
The problem happens even on a newly created fresh VS2012 WPF .Net 4.5 project with a fresh install of Oxyplot.
CMC wrote at 2013-02-16 04:07:
Copy plot to clipboard with context menu
Gimly wrote at 2013-10-02 14:17:
I've seen in another thread that the Plot was bound to
ApplicationCommands.Copy
, so I thought that this would work:<oxy:Plot> <oxy:Plot.ContextMenu> <ContextMenu> <MenuItem Command="ApplicationCommands.Copy" Header="Copy to clipboard" /> </ContextMenu> </oxy:Plot.ContextMenu> </oxy:Plot>
Any idea?
everytimer wrote at 2013-10-02 16:19:
I don't know why but Commands do not work in the ContextMenu. If you want that you should use the click event and then send a message (with Messenger or Mediator) to your ViewModel (or copy the plot in the codebehind with the click event). Good luck.
Add padding/margin to LineSeries line between line and data point
Is there a way to add padding/margin to LineSeries line between line and data point
Here's a pooooorly Photoshop image of what I'm looking to achieve (The top LineSeries)
Service d'assistance aux clients par UserEcho