How to program the Distance Between Axis Intervals (Charts) - vb.net

I am creating a custom bar chart using VB.NET, I am wondering if there is a way to program the distance between intervals in the y axis. For example if I wanted the distance between points 1 and 2 in the axis to be of a certain length e.g 2cm long and the next interval to be of a certain length e.g 5cm long, is there a way to achieve this. Any help would be appreciated.

You can set the ChartArea to be a specific size and then configure the Axis.Interval property

No (at least, not easily). The Axis.Interval property sets all intervals to be the same size. You would need to subclass Chart and override the OnPaint method to draw the ticks (and/or grid lines) with different spacings. Not sure offhand if there are ways to have it paint parts of the chart as it normally would, while doing custom painting on other parts...
ETA: It may become slightly easier if you only have 2 intervals to worry about (e.g., the axis line itself, then one line 2 cm up, then another line 5 cm up from that, and no more lines after that). You could probably use the Axis.Interval and Axis.MinorGrid.Interval properties in that case.
ETA again, since it didn't show up nice in the comments: One thing you could try is to hide all of the ticks and grid lines, and then handle the OnPaint event (not override) to just draw lines on top of the chart where needed. Something like this psuedocode
private void ChartPaint(object sender, Args e) {
e.Graphics.DrawLine(figure_out_2cm_above_axis, Color.Black, etc);
e.Graphics.DrawLine(figure_out_5cm_above_line, Color.Black, etc);
}

Related

IntersectWith.None VB.NET AutoCAD

I have a problem with the function IntersectWith
I have used this function with VBA and it has a option Intersect.None
But when I call the function from VB.NET this option does not exist.
I try to use the available options but all detect an incorrect intersection
yourCADObjectII.IntersectWith(myText, Intersect.ExtendBoth, points, New IntPtr(0), New IntPtr(0))
yourCADObjectII.IntersectWith(myText, Intersect.OnBothOperands, points, IntPtr.Zero, IntPtr.Zero)
yourCADObjectII.IntersectWith(myText, Intersect.ExtendArgument, points, IntPtr.Zero, IntPtr.Zero)
yourCADObjectII.IntersectWith(myText, Intersect.ExtendThis, points, IntPtr.Zero, IntPtr.Zero)
I don't know how to use IntersectWith in VB.NET as I used in VBA with the Intersect.None option.
I tried to detect a text string vs. a closed polyline, the text is inside of a polyline, I want to detect if the text intersects with the LWPolyline.
The text has different rotations and the polyline has different geometry.
As far as know, the COM/ActiveX IntersectWith method does not have any Intersect.None option. It has a acExtendNone option whose .NET equivalent is Intersect.OnBothOperands.
COM .NET
acExtendNone Intersect.OnBothOperands Does not extend either object.
acExtendThisEntity Intersect.ExtendThis Extends the base object.
acExtendOtherEntity Intersect.ExtendArgument Extends the object passed as an argument.
acExtendBoth Intersect.ExtendBoth Extends both objects.
I think you are implementing IntersectWith correctly and your problem is not with what you mentioned. From memory, when you try to use intersectwith for DBText with any other object, it doesn't actually calculate the intersection with the text itself but rather with its bounding box. And that bounding box doesn't always fit the text exactly. It sometimes is bigger than the text (depending on rotation). Or sometimes it is smaller than the text especially when using letters like (y, j, q,g, etc...)
So your best bet is to try and find the bounding box that fits your rotated text by finding the bounding box that fits the same text with no rotation then rotate that box (using a closed polyline to capture all 4 corners)
Now your problem becomes intersection of two polylines instead of text and polyline. And then you can use intersectWith to get intersection points

How to reposition non reliative multiple labels of edges in JGraphX

In a graph, I have edges that have more than one label (multi labels): one label is beside the source cell and another one beside the target cell. Both labels are created as child vertices of the edge. For correct positioning adjustement reasons, these labels do not have their geometry set relative (to the edge). When generating the edges, labels are correctly positionned: I use the mxGraphView.getPerimeterPoint() and an few adjustements to position the source and target labels.
When moving a cell using the mouse drag, I need to reposition these labels. For the moment I have tried to react to graph events (mxEvent.CELLS_MOVED, mxEvent.MOVE_CELLS) or model events (mxEvent.CHANGE) registering either a graph or a model listener.
However, the getPerimeterPoint function uses an mxCellState (not an mxCell) obtained through the graphView (graph.getView().getState(cell)) to do the calculation and this cell state mxGeometry is based on the previous position of the cell.
Is this solution based on events the correct way of doing this?
And if yes, should I rewrite completely the getPerimeterPoint (and functions used in it) to use the mxCell returned by the event (event.getProperties("cells")) whose greometry is correct rather than the mxCellState? Or is there a technique to get the cell state corresponding to the end of the current move operation without messing up the whole graph update process?
Any help or advice appreciated, thanks.

vb.net return actual chart x and y values on mousemove

In my simple vb.net chart that displays a particular series, I would like to obtain running values of the actual values in the chart. I can already obtain the x-y coordinates, which is easy (e.x and e.y) - but wondering if there is a available method to convert the coordinates to the values related to the chart itself.
I need to use the mousemove event rather than mousedown.
I wish to transfer these actual values to a textbox on the form.
Thanks - burnt out trying to figure this out on my own.
This is pretty easy, unless the chart control doesn't give you some crucial information, in which case it's pretty hard :)
Your chart control probably shows several elements: the chart itself (bounded by the X and Y axes), the chart title, the axis titles, maybe a legend, etc. What you need to know is the .Left and .Width values of your X-axis. Assuming you can obtain those, the formula you want is
actualX = (mouseX - axis.Left) / axis.Width * (axis.Max - axis.Min) + axis.Min
Without knowing what chart control you're using on which platform, it's hard to tell you how to find all those pieces, but the formula is what you're looking for.

ZedGraph Axis labels

I have two questions about axis labels:
How do I make a label at the Y2-axis, that shows a highlighted label following the dynamic price (y2-value) of the last bar/candlestick? As the red label in this example:
And possibly also the same on the XAxis, showing the time of the last bar.
Also I wonder how to make the time axis plot only every 30 min, and also that it should be full half hours, not arbitrary 30 min spots.. As also shown in the above image.
ZedGraph is awesome. But takes some time to figure out the tricks and tweaks.. :)
Ad. 1.
You probably need to create a custom text object. If I remember correctly:
TextObj label = new TextObj("some text", 1, y2coordinate);
label.Location.CoordinateFrame = CoordType.XChartFractionY2Scale;
label.Location.AlignH = AlignH.Left;
myPane.GraphObjList.Add(label);
to change the color and background, just edit properties of label.FontSpec
Ad. 2.
You need to set manualy the Min, Max and MajorStep of the Scale object of your axis.

MS Access Draw line around detail section that can grow

This really shouldn't be hard, I just can't figure out how to do it.
I am making a proposal report that needs to have a border around it. The problem is to get the vertical lines on the side. I can't figure out how to get a line to grow and shrink based on the height of the detail section.
I have used Crystal reports and sure wish Microsoft would learn a few things in regards to MS Access report writing!
I am very comfortable with VBA so have no fears there.
You were right, this isn't so hard. The trick is to use 2 variables, top and bottom. In the PageHeader_Format event you set top to Me.Height, and in the PageFooter_Format event you set the bottom to Me.Top - correction, where correction is a fixed amound you use to fix the right length. I´m not sure where this amount comes from, you just have to try a little bit.
In the Report_Page event you can then draw your line from top to bottom.
Another method that nobody has mentioned is the one using the Line method of the report, outlined in Knowledge Base article 210321. I've used this one for years, and it can be used to draw both lines and rectangles. It's quite handy for invoices that have variable height subreports for the invoice details, but need the vertical lines to change according to the height of the main report detail.
No VBA needed.
Make a dummy grouping that is unique to each detail. For that grouping, set footer to yes.
In your new group footer section that you just created, add your line.
In your detail section, select all the relevant fields that can grow and set Can Grow = Yes
Done!
Edit
Off-topic, I agree that Access Reports could learn a lesson or two from Crystal. But Crystal isn't perfect either. [/flamewar]
Try this one.
Right click on the detail bar and select properties. Set the special effect to “Sunken”. This will put kind of a border around the detail section that resizes with the detail section.
I have tried to get a line to dynamically resize but its catch 22, by the time you know the height of the section (In the On Print event) you cant make any changes!
use the page event coupled with me.line and scaleheight / scalewidth.
I draw a box around the whole page with the following. Play with it and see where you end up. It is very handy for making professional reports. If you want a line in a certain place on a report you can use the controls coordinates. like
me.line(Mycontrol.left,mycontrol.top) - (myothercontrol.left+myothercontrol.width, myother control.top + myothercontrol.height)
Private Sub Report_Page()
Me.Line (0, 0)-(scalewidth -30, scaleheight-30), 0, B
End Sub