You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support of several X-coordinates for same Y-coordinate #1629
I have an application where each line-series contains points that are looking like this: (Xn_1, Xn_2, Yn).
Practically for each Y value there are 2 corresponding X-values: one of them is for instance some absolute X-value (could be a DateTime time-stamp) and the second X value is for instance a relatively calculated value (like a percentage from something). I would then add 2 linear axes to the plot, one for the each of the 2 defined X values.
Could the DataPoint class be extended to take several X coordinates for one Y coordinate?
Realistically, I think not. There have been a couple of other issues lately discussing having multiple sets of labels per axis (#1357, #1336), and perhaps this would be worth thinking about.
To some extent, these could addressed by having multiple axes on different tiers all slaved together.
What is your end goal in terms of user experience?
For the application I am thinking about, I have actually a plot with line-series representing the values of different process data between 2 events (like start and end of production process). The 2 events represent the 0 - 100 % scale which is used for the X axis.
I would need the option to add a second X axis to represent the absolute time-stamps for the data points between the 2 events (an option would be to toggle between the 2 X axes, or, maybe even better, to be able to add/remove the DateTime X axis whenever the user activates it, by context menu or whatever)..
Right now I show the DateTime values for each DataPoint in a customized TrackerFormatString, but having an optional additional DateTime axis would be much more user-friendly)
Yes, the Axis.PositionTier property allows you to stack axes on the same size of the plot (there is big example in example library under Axis Examples).
Unfortunately I dont see the second axis as in the example browser. The scale of the second linear axis is dsplayed, but the values below the scale and the title are missing. Looks that these are cut off from the plot view. I tried to set the Margin property of the PlotView, but it did not help. Any idea what happens?
That does sound like an issue with the margins: can you provide a screen shot or reproducing code?
If you set the margins to NaN, do they appear? Axes exist within the plot the margins, so if they are set manually, then they need to accommodate all the axes.
It's also possible that no tick marks have been computed for it for some reason (e.g. if the interval/step is large and the axis is small).
The second axis should actually be a DateTime axis, and I could compute the minimum and maximum values. I guess that it is not obligatory that the second X axis is also a LinearAxis.
But as a first step I was trying to display a second X axis at all. Of course actually there is no correlation at all between the second axis and any DataPoints, there are no dataPoints assigned to it. All the DataPoints are assigned to the first X axis. That was the reason of my initial question, if it is possible to store two different X values in the same DataPoint.
The margin on the PlotView is just the margin defined for any control. You have to set it on PlotModel, where it should default to all NaN. Could the PlotModel.Margin be being set elsewhere? This is often done to avoid the axes 'bouncing' because OxyPlot computes them based on what is displayed, and this can be undesirable upon user interaction.
Is there any possibility to couple/synchronize the second DateTime X axis with the first X axis? For instance when zooming the plot and respectively the first X-axis, to also zoom/adapt the DateTime X axis. Does anyone have maybe a code sample about how to achieve such a functionality?
There is no built in support for slaving. It's been a while since I tried, but you should be able to hook on OnAxisChanged on both axes and update the other accordingly. This should work because it isn't called when you change the minimum/maximum directly, but it means that any manual update will have to be intercepted some other way.
The example library could do with an example of this...
I understand the theory, not sure about the practical implementation...
To get the "Zoom effect" on the second axis I would have to calculate somehow the "zoom factor" on the first X-Axis in OnAxisChanged?
And then to zoom manually the second X axis, I would have to recalculate the minimum and maximum properties for it?
Unfortunately there are no samples of handling OnAxisChanged or calling ZoomAt in the example library...
Ok, I understand now. How could I display for instance something like "15.03.2014" instead of the day of the week?
And one more question about the helper functions DateTimeAxis.ToDouble(DateTime value) and DateTimeAxis.ToDateTimeValue(double value). If I write this code:
var dtNow = DateTime.Now;
var dtDouble = DateTimeAxis.ToDouble(dtNow);
var dtNowAgain = DateTimeAxis.ToDateTime(dtDouble);
, the dtNow variable has the Kind property set to DateTime.Local, but dtNowAgain has the Kind property set to DateTime.Utc (the other values are identical).
Could be eventually a bug.
Regarding datetime local/UTC, the static methods have to pick one and run with it, so there isn't much that can be done there. This could be a problem for presentation, but that can always be overriden.
The default legends only render series. You could override and extend them to do otherwise, but it would be a lot of work.
In terms of long-term improvements, an ILegendItem interface might be a good idea: there isn't always a one-one mapping between series and legend entries, and it could allow other things (e.g. annotations) to join in. If you have ideas that would influence such a design, do make an issue about them so we can keep track of them.
The issue with the date disappearing presumably coincides with a tick appearing: at the point it stops rendering just one label and tries to render many, but they are probably 'off-screen'. It might make sense to detect if there is only one and re-center it.
Is there any setting that allows displaying the title of a X Axis directly on the right (or left) side of the axis line, instead of below it?
Can the font size of the label texts for the axis be configured?
Title position isn't configurable (it's an old issue (#22) with a lot of difficulties with regards to how different axes with offset-titles should interact which the layout system can't really handle at the moment).
Label size should be controlled by by PlotElement.FontSize.
The configuration of the title position would be a very useful feature in my opinion...
What about the font size of the axis title, can this also be configured?
What it needs is someone familiar with the library to invest in the design work. It could probably be done quite easily, but it would go wrong when you have lots of axes. Maybe I'll have a go at a prototype over the weekend...
Axis title is Axis.TitleFontSize, though I think there is a bug in 2.0 involving that.
@VisualMelon : Should be possible to zoom the X-axis in my scenario? By moving the mouse wheel only the y-axis is zoomed. Where exactly should I place the mouse cursor (as decribed here to get the zoom for the x axis working?
The same question for pan (works also only for the y axis).
@abrasat Without looking at your code for the plot model and controller, I can't really help. An X axis should always zoom when the mouse is over the plot area. Check you don't have any invisible axes, or axes which are configurated as non-zoomable/pannable or have absolute bounds.
@VisualMelon I used basically the code above in this issue, to synchronize the additional x-axes with the x axis that I initially had (the one with the percentage values).
The problem seems to be in this code, with the 2-way synchronization of the x-axes.
Slave(y2axis, yaxis, x => x * 100);
Slave(yaxis, y2axis, x => x / 100);
If I remove the second Slave() call and thus have only a "one-way" axis synchronization, the zoom and pan functions work normally, also with the additional x axes.
Activity
VisualMelon commentedon Jul 22, 2020
Realistically, I think not. There have been a couple of other issues lately discussing having multiple sets of labels per axis (#1357, #1336), and perhaps this would be worth thinking about.
To some extent, these could addressed by having multiple axes on different tiers all slaved together.
What is your end goal in terms of user experience?
abrasat commentedon Jul 22, 2020
For the application I am thinking about, I have actually a plot with line-series representing the values of different process data between 2 events (like start and end of production process). The 2 events represent the 0 - 100 % scale which is used for the X axis.
I would need the option to add a second X axis to represent the absolute time-stamps for the data points between the 2 events (an option would be to toggle between the 2 X axes, or, maybe even better, to be able to add/remove the DateTime X axis whenever the user activates it, by context menu or whatever)..
Right now I show the DateTime values for each DataPoint in a customized TrackerFormatString, but having an optional additional DateTime axis would be much more user-friendly)
abrasat commentedon Jul 22, 2020
Is there any possiblity to stack two X axes at the bottom, one above the other?
I tried this, but the X axes override each other:
VisualMelon commentedon Jul 22, 2020
Yes, the
Axis.PositionTierproperty allows you to stack axes on the same size of the plot (there is big example in example library under Axis Examples).abrasat commentedon Jul 22, 2020
Ok, thanks, I will take a look.
Is it possible to run the examples from the example library ?
Later edit: Found it, the ExampleBrowser.WPF
abrasat commentedon Jul 22, 2020
Unfortunately I dont see the second axis as in the example browser. The scale of the second linear axis is dsplayed, but the values below the scale and the title are missing. Looks that these are cut off from the plot view. I tried to set the Margin property of the PlotView, but it did not help. Any idea what happens?
VisualMelon commentedon Jul 22, 2020
That does sound like an issue with the margins: can you provide a screen shot or reproducing code?
If you set the margins to
NaN, do they appear? Axes exist within the plot the margins, so if they are set manually, then they need to accommodate all the axes.It's also possible that no tick marks have been computed for it for some reason (e.g. if the interval/step is large and the axis is small).
abrasat commentedon Jul 22, 2020
Actual code + screenshot.
Is it necessary to calculate minimum and maximum for the second axis? But why is not even the title displayed?
VisualMelon commentedon Jul 22, 2020
It will be necessary to compute them if you want it to say anything meaningful, but it should default to [0, 100] and display as such.
It does look exactly like it is being clipped. If you make the plot margin NaN or double whatever it is now, does that change anything at all?
abrasat commentedon Jul 22, 2020
I had this margin in xaml:
How can I set NaN as Margin?
The second axis should actually be a DateTime axis, and I could compute the minimum and maximum values. I guess that it is not obligatory that the second X axis is also a LinearAxis.
But as a first step I was trying to display a second X axis at all. Of course actually there is no correlation at all between the second axis and any DataPoints, there are no dataPoints assigned to it. All the DataPoints are assigned to the first X axis. That was the reason of my initial question, if it is possible to store two different X values in the same DataPoint.
VisualMelon commentedon Jul 22, 2020
The margin on the
PlotViewis just the margin defined for any control. You have to set it onPlotModel, where it should default to allNaN. Could thePlotModel.Marginbe being set elsewhere? This is often done to avoid the axes 'bouncing' because OxyPlot computes them based on what is displayed, and this can be undesirable upon user interaction.abrasat commentedon Jul 22, 2020
You are right, thanks!
I had this:
After changing to this
, I see the second X axis
abrasat commentedon Jul 22, 2020
Is there any possibility to couple/synchronize the second DateTime X axis with the first X axis? For instance when zooming the plot and respectively the first X-axis, to also zoom/adapt the DateTime X axis. Does anyone have maybe a code sample about how to achieve such a functionality?
VisualMelon commentedon Jul 22, 2020
There is no built in support for slaving. It's been a while since I tried, but you should be able to hook on
OnAxisChangedon both axes and update the other accordingly. This should work because it isn't called when you change the minimum/maximum directly, but it means that any manual update will have to be intercepted some other way.The example library could do with an example of this...
abrasat commentedon Jul 22, 2020
I understand the theory, not sure about the practical implementation...
To get the "Zoom effect" on the second axis I would have to calculate somehow the "zoom factor" on the first X-Axis in OnAxisChanged?
And then to zoom manually the second X axis, I would have to recalculate the minimum and maximum properties for it?
Unfortunately there are no samples of handling OnAxisChanged or calling ZoomAt in the example library...
10 remaining items
abrasat commentedon Jul 23, 2020
Ok, I understand now. How could I display for instance something like "15.03.2014" instead of the day of the week?
And one more question about the helper functions DateTimeAxis.ToDouble(DateTime value) and DateTimeAxis.ToDateTimeValue(double value). If I write this code:
, the dtNow variable has the Kind property set to DateTime.Local, but dtNowAgain has the Kind property set to DateTime.Utc (the other values are identical).
Could be eventually a bug.
VisualMelon commentedon Jul 23, 2020
Check out String Formatting.
Regarding datetime local/UTC, the static methods have to pick one and run with it, so there isn't much that can be done there. This could be a problem for presentation, but that can always be overriden.
abrasat commentedon Jul 23, 2020
Ok, I will check it.
I think the Kind property is read-only, can be set only when constructing a DateTime.
VisualMelon commentedon Jul 23, 2020
The default legends only render series. You could override and extend them to do otherwise, but it would be a lot of work.
In terms of long-term improvements, an
ILegendIteminterface might be a good idea: there isn't always a one-one mapping between series and legend entries, and it could allow other things (e.g. annotations) to join in. If you have ideas that would influence such a design, do make an issue about them so we can keep track of them.VisualMelon commentedon Jul 23, 2020
The issue with the date disappearing presumably coincides with a tick appearing: at the point it stops rendering just one label and tries to render many, but they are probably 'off-screen'. It might make sense to detect if there is only one and re-center it.
abrasat commentedon Jul 23, 2020
Ok, thanks.
P.S. Not sure what happened, my last posting disappeared.
abrasat commentedon Jul 24, 2020
Is there any setting that allows displaying the title of a X Axis directly on the right (or left) side of the axis line, instead of below it?
Can the font size of the label texts for the axis be configured?
VisualMelon commentedon Jul 24, 2020
Title position isn't configurable (it's an old issue (#22) with a lot of difficulties with regards to how different axes with offset-titles should interact which the layout system can't really handle at the moment).
Label size should be controlled by by
PlotElement.FontSize.abrasat commentedon Jul 24, 2020
The configuration of the title position would be a very useful feature in my opinion...
What about the font size of the axis title, can this also be configured?
VisualMelon commentedon Jul 24, 2020
What it needs is someone familiar with the library to invest in the design work. It could probably be done quite easily, but it would go wrong when you have lots of axes. Maybe I'll have a go at a prototype over the weekend...
Axis title is
Axis.TitleFontSize, though I think there is a bug in 2.0 involving that.abrasat commentedon Jul 24, 2020
Thanks, it seems to work for my application
abrasat commentedon Aug 10, 2020
@VisualMelon : Should be possible to zoom the X-axis in my scenario? By moving the mouse wheel only the y-axis is zoomed. Where exactly should I place the mouse cursor (as decribed here to get the zoom for the x axis working?
The same question for pan (works also only for the y axis).
VisualMelon commentedon Aug 10, 2020
@abrasat Without looking at your code for the plot model and controller, I can't really help. An X axis should always zoom when the mouse is over the plot area. Check you don't have any invisible axes, or axes which are configurated as non-zoomable/pannable or have absolute bounds.
abrasat commentedon Aug 10, 2020
@VisualMelon I used basically the code above in this issue, to synchronize the additional x-axes with the x axis that I initially had (the one with the percentage values).
The problem seems to be in this code, with the 2-way synchronization of the x-axes.
If I remove the second Slave() call and thus have only a "one-way" axis synchronization, the zoom and pan functions work normally, also with the additional x axes.