I have a WPF application where I used DevExpress charts to display some data. I want to get rid of them and use LiveCharts, but I want to display a circle in the chart point closest to the mouse cursor when it is inside the chart. I have tried sections and I can show lines that cross in the point, but I can't mark that point as it automatically does when you hover over it. Is there a way to do this without changing the source code?
I think you can get your answer from this example.
By calculating the closest point to your mouse (like in the example, you can then change the style of your chart point. In the example, the x-axis lable at the specific point gets highlighted.
Related
I have different XAML Line Controls defined inside a MapControl. They change the rotation, color, ... so I thought it was better to do with lines that with MapPolyline which are supposed to stay static.
When panning around the map I found that when the origin of the lines are out of the MapControl, sometimes the lines dissappear, sometimes not. They dissappear only when outside the MapControl BUT on the right side or the lower side. THat doesn't happen when they pan out left side or upper side.
Obviously, I want them in the screen everytime, I don't want to dissappear them.
Any idea why it happens? And how can I get them visible all the time?
Lines visible when origin (orange point) inside the MapControl
Lines hidden when Lines origin outside right side. Orange point is partially visible.
Lines visible when origin outside left side. Even the orange point is outside the control, but lines are still visible.
It appears there is some code that toggles the visibility of attached XAML items based on whether the attached points are in the viewport. You could work around this by introducing additional points along the line.
In general, It's recommended to use MapElements rather than attached XAML for most scenarios. XAML should really only be used for things like dialogs with rich UI where you have relatively few such objects attached to the map. MapPolyline will perform better even for scenarios where you want to update the properties and position and will stay in sync with map motion much better than XAML.
I have found a solution for the dissapearing lines problem.
All the lines and XAML shapes that were just on the MapControl should be grouped inside a canvas, width the correct width and height (in my case the max length of the lines in both dimensions and also negative and positive directions, center/anchor the canvas in the MapControl.Center and play with margins tofit all the controls correctly).
For all the tests I have done, lines stays in th screen even both starting point and the ending point are not in the screen.
I'm currently working with a DevExpress ChartControl with several panes stacked vertically on top of each other. The panes can individually be shown or hidden at runtime, but their contents won't change after they're created. I'd like to remove all space between the panes so that the border of each is totally flush with the border of the pane above/below it.
I've already used the following code to set the PaneDistance to 0, which normally would do exactly what I'm looking for:
XYDiagram diagram = chartControl1.Diagram as XYDiagram;
diagram.PaneDistance = 0;
However, the problem I'm running into, visible in the screenshow below, is that the labels on my y axes can sometimes extend vertically above or below the edge of the pane itself, which forces there to be space between my panes.
The first two panes have no space between them at all, which is exactly what I want, but the problem can be seen on the bottom whree panes. The "0" label on the second pane extends slightly below the table, so empty space is added to allow it to fit. The bottom two axes both have labels that extend outside their panes, so even more space is being added.
I've tried editing every property of these axes that I can think of, but nothing has been able to remove this blank space. It seems like just getting the outer labels to be pushed up or down so they're inside the pane height should do the trick. Anyone have any ideas on how I can get this working like it should?
Edit: I'll mention that in a different part of this app, I have a different set of panels, rotated and aligned horizontally, with their axis labels doing what I want them to do in the case above:
You can see that the "0" and "300" labels are shifted slightly off-center to fit within their own pane, so they don't extend out and create empty space. I didn't have to touch any code to get that to happen. It could be because these are all instances of the same axis, while the ones that don't do this are different axes, that causes them to play nice in this case?
Edit 2:
Here's what I've got after setting my axis SideMarginsValues to 0 and AlwaysShowZeroLevel to false. Getting closer!
if you can't achieve what you need with DX chart's public properties there is still one trick you can try.
In Browser choose Inspect the chart area (CTRL+SHIFT+I in Chrome) and find the actual chart's element or the parent element and see what classes/ids DX have assigned to them.
Then pick the nearest element class/id and try to play with it's css by assigning negative margins/paddings like:
.dxtcLite.dxtc-top .dxtc-stripContainer {
margin-botton: -2px!important;
}
This is of course a dirty solution but sometimes it's the only one which works.
However, if you don't have any HTML-type margin/padding between chart panes but the blank space is actually a part of the generated chart Image, then probably the only thing you can do is to continue playing with DX chart properties which affect the actual chart image generation.
UPDATE:
Have you tried setting the Range.SideMarginsValue property to 0?
diagram.AxisY.WholeRange.SideMarginsValue = 0;
Another option would be to try to always hide 0-level axis label using
WholeRange.AlwaysShowZeroLevel :
diagram.AxisY.WholeRange.AlwaysShowZeroLevel = false;
or try setting max values for the axis values to exclude border labels:
// depending on possible min/max values for each pane
diagram.AxisY.WholeRange.SetMinMaxValues(5, 35 );
Let me know if anything of the above helps.
I want to make a 2D scatter plot with following requirements;
The "dots" should not be dots but instead arrows pointing either upwards or downwards depending on the data it represents.
It should be possible to specify what values to show on the axis.
The user should be able to zoom and pan on the graph.
I want to be able to specify what color each arrow should have.
The arrows should be clickable (i.e. I need some way to register a click event and decide which arrow was clicked).
I have tried to accomplish this using ZedGraph but I find it hard to get how I want, especially with the first requirement.
Is there a free charting library that would allow me to do this relatively easy in WinForms? Or, any general tips on how to accomplish the first requirement using ZedGraph?
In the Zedgraph samples there is an example of adding text labels to the data points using TextObjects. You can find this demo sample here.
Based on this example, you should be able to create the up and down arrows in required positions, using ArrowObjects instead of TextObjects.
I have now learned that all requirements can be accomplished using ZedGraph.
The "dots" should not be dots but instead arrows pointing either upwards or downwards depending on the data it represents.
The cleanest solution is to use LineItem and do custom symbol type just like in this post Customize symbol type of a ZedGraph LineItem .
It should be possible to specify what values to show on the axis.
An easy solution to this is to use TextLabels and manually place them where you want them.
The user should be able to zoom and pan on the graph.
Functionality built into ZedGraph.
I want to be able to specify what color each arrow should have.
One can create multiple LineItems for each color, this requires that the line itself is not visible though.
The arrows should be clickable (i.e. I need some way to register a click event and decide which arrow was clicked).
Easily made using the Click event and FindNearestPoint method.
How to make a movable control in c#?
Two circles with a line joining b/w them.
if we move one circle in any direction the other circle remains fixed but the line changes its position according to the first circle.
i want the idea .....pls help me if u have?
You are not telling us if this is a Winform application, WPF or Silverlight.
To me it sounds like WPF could be the right technology for this.
You could use the shape objects to draw circles and lines.
Link to MSDN documentation
I am using NPlot charting library to draw several plots illustrating signal fluctuations. The plots are inserted one beneath the other in a flowlayoutpanel1.
The x axis is the time. The y is the value of the signal.
I've added a trackbar at the bottom, along the x axis. When the user moves the trackbar, the value of each signal is displayed somewhere (in relation to the trackbar's position).
All of this is already functional.
I've been asked to add some visual way to illustrate the precise time where the trackbar is. They want some sort of vertical line that would move with the trackbar, over all the Nplots. However they are open to alternatives.
I have tried drawing the line but it's difficult to draw in relation to the trackbar's position. Also it ends up being drawn BEHIND the Nplots.
I've also tried drawing a static grid on the flowpanel but the Nplots are not transparent, and my boss doesn't like each plot having a individual grid for aesthetic purposes.
At this point i'm open to any "out-of-the-box" suggestions, or corrections on my implementation. I'm self taught in C# so i haven't done anything like this before.
Please help!
EDIT: I have gotten something slightly better by using a label with a border, stretching it to be tall and having width of 1. This creates a Line that goes over all other control. Now my biggest challenge is calculating the position of the trackbar pointer to make the line match it...
After a lot of fiddling, i found that the only way to have a line drawn over all other controls was NOT to use the Graphics drawline, as the controls placed on top were not transparent and i could not access their graphics component (was a imported control not a .NET class).
I ended up going with the EDIT solution, took a label with a border and put the width to 1, creating a simple line instead of a box.
The position formula took a lot of fine tuning, the way to go was to calculate (estimate) the width between two trackbar ticks an add a tiny offset for the control itself. Using the traback's pointer Value property, i could calculate the position of the label/line so that it would follow the trackbar pointer. There is a minuscule offset sometimes formed but not well seen to the naked eye.