Has anyone any idea how to use Excel.XlLegendPosition.xlLegendPositionCustom to specifically position the legend of a chart? Currently, I'm using
chart.Legend.Position = Excel.XlLegendPosition.xlLegendPositionBottom;
which does exactly what one would expect. Right up until the time when you try and print the chart. THEN it places the legend pretty much where ever it wants -- which isn't where I need it to be.
I've checked the MSDN and every other site I could think of. The best Microsoft can come up with is as follows:
xlLegendPositionCustom: A custom position.
There are no examples that I could find that show how to use this.
Thanks for any help.
Okay, it doesn't seem as if anyone has encountered this particular issue -- or needed to use the command. No worries, I appreciate folks taking the time to look at the question.
I did find a workaround that allows you to position the legend using points. It appears if you use the preset positioning options (like Excel.XlLegendPosition.xlLegendPositionBottom), Excel positions the legend based on whatever magic MS uses to figure these things out. Since I couldn't figure out how to use the Excel.XlLegendPosition.xlLegendPositionCustom, I played around with the other commands and found these:
chart.Legend.Left = 375;
chart.Legend.Top = 450;
Those commands will take an int (I used 374 and 450) and using them, you can force the position of the legend to anywhere on the chart.
I don't think you can set it to xlLegendPositionCustom, it's read-only, i.e. when you 'ask'(Debug.Print ActiveChart.Legend.Position), after setting ActiveChart.Legend.Left/ActiveChart.Legend.Top you get -4161 which is xlLegendPositionCustom.
Related
The issue I am dealing with is that I cannot seem to find an alternative to PickPoint for SectionViews.
In the Revit 2019 API, I've been trying to create a small script which draws a DetailLine between two points. However, I wish these points to be selected by the user, which PickPoint is perfect for. Since I need this to work in Section Views too, I'm at a roadblock though.
The relevant code is given.
XYZ p1 = uiDoc.Selection.PickPoint();
XYZ p2 = uiDoc.Selection.PickPoint();
DetailLine l = uiDoc.Document.Create.NewDetailCurve(
uiDoc.Document.ActiveView,
Line.CreateBound(p1, p2)) as DetailLine;
This throws a Autodesk.Revit.Exceptions.InvalidOperationException in a Section View, since I don't have a Work Plane.
The part that confuses me is that we can very easily draw a DetailLine in Revit itself, but I can't seem to be able to do this in my own AddIn.
I figured it out, but I'll leave my solution here for whoever might need help with it.
Basically, Revit doesn't allow you to pick points without an active Work Plane at all. This is because the coordinate system in Revit is three-dimensional, and when you're picking a point with your mouse you can't go in three dimensions. To make sure everything is precise and right, Revit forces you to have a plane on which you will pick a point.
The work-around is a blatant hack, but it works. You have to create a sketch plane, from which you can create a work plane, in which you select a point, and then after that you delete the work plane. It's dirty, but it works.
Since you're creating and deleting stuff, this requires a Transaction.
XYZ pickPoint;
using (Transaction t = new Transaction(Document))
{
t.Start("Test Transaction");
SketchPlane sp = SketchPlane.Create(Document, Plane.CreateByNormalAndOrigin(
Document.ActiveView.ViewDirection,
Document.ActiveView.Origin));
Document.ActiveView.SketchPlane = sp;
// Finally, we are able to PickPoint()
pickPoint = Document.Selection.PickPoint();
// Don't forget to clean up
Document.Delete(sp.Id);
t.Commit();
}
// Draw whatever you want with this point now.
Hope this helps someone out.
I'm looking for a simple function in C# to interpolate my 3D data.
Given is already a list with around 100-150 data sets and 3 double values.
-25.000000 -0.770568 2.444945
-20.000000 -0.726583 2.467809
-15.000000 -0.723274 2.484167
-10.000000 -0.723114 2.506445
and so on...
The chart created by these values looks usually like this, I'm not sure if this counts as scattered or rather still gridded data ...
In the end I want to hand over two double values and get the third then from the interpolation function. It shouldn't flatten the surface, it should still go through all the given data points.
Since I'm not given the time to look into all possible algorithms and lack the mathematical background I'm a bit overwhelmed by all the possibilities that I get thrown at: Kriging, Delauney triangulation, NURBs and many more ...
In addition to that most solutions I found in the net were either for a different language, outdated or are charged by the time (e.g ilnumerics, still not sure if they have the solution)
In matlab there exists a griddata function that does exactly this (and is based on a kriging algorithm as far as I know) but in this case C# is mandatory for me.
Thank you for your help and criticism and suggestions are welcome.
I'm using classes from the C# Charting namespace to create a line graph, which is working fine so far. I have set a ToolTip so I can hover over a plot line and see its XY coordinates as follows:
chart_MPPTs.Series[seriesName].ToolTip = seriesName + " #VALX : #VALY{C}";
However, I got the " #VALX : #VALY{C}" portion from some sample code I found on the Web and I don't fully understand it. #VALX and #VALY appear to be macros or some other type of replacement mechanism and {C} is for formatting. However, I've been unable to find any documentation on these or the full set of such things that are available. Can anyone direct me to this information?
Also, the Microsoft documentation of the Charting classes and their contents seems even more terse than usual when it comes to examples or explanations of some of the terms used. Is there a book or any other resource that provides some good examples of using all of the various features of these classes?
The # is part of the expression syntax for Chart Keywords. And yes, the part in curlies is about formatting, as explained at the bottom of the link..
Here are the settings you will need to make it work as mentioned iin the comments, i.e. display the label going from 0 - 24:
Make sure your x-value data are in fact added as DateTime and tell the chart about it:
chart_MPPTs.Series[seriesName].XValueType = ChartValueType.DateTime;
Now your tooltips should look right. Then to style the chart further try these settings:
chart_MPPTs.ChartAreas[0].AxisX.Interval = 1;
chart_MPPTs.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Hours;
chart_MPPTs.ChartAreas[0].AxisX.LabelStyle.Format = "hh";
Or "hh\\h"; or "h\\h"; for 00h - 24h or 0h - 24h..
All settings can also be done in the designer.
I'm trying to make a truncated icosahedron, though with more subdivision (so more hexagons)
In the game I use it, eacht pentagon and hexagon is a separate object. So after generating the icosahedron, I just use the generated points to place either a pentagon or a hexagon on it (instead of doing the find-middles-of-each-triangle-thing, I do this since I need them to be separate object anyway.) I have some questions about it though, and google doesn't really help, so I'm hoping there are some smart smath-knowing people here :D
Here we go:
Am I assured that the length of each sides is equal?
Since each hexa/petagon is a separate object, I need to rotate them to get them positioned properly, any help with this?
Assuming I have hexa/petagons with a radius of 1 (one), how far for the middle do I have to position them? (Basecly, whats the relationship between the radius of my hexa/pentagons and the radius of my truncated icosahedron.)
Here's my first test, I generated a icosahedron and then on each point put a pentagon model, which I rotate so it's pointing away from the middle. As you can see they still need to be rotated to fit together (question 2) and their distance to the middle has to the tweaked aswell (question 3).
I'll continue on working on this too, though all help will be appreciated! (I'm making this in Unity, using c#, so if you give sample code, it would be really really awesome if you use that.)
Thanks a lot!
Well, not the answer to your questions but maybe worth thinking about:
Wouldn't it be easier to start with a ready made Blender, Maya, ... model of a soccer ball like for example this one on Blend Swap, change it to fit your needs. Or do it on your own as there are a couple of YouTube tutorials. Then you will have far more options like LOD, materials. You can design it in Blender with each pentagon/hexagon as single object and so it will be imported in Unity.
oes anyone know a way to plot how a watched variable changes over time in Visual Studio 2010? I.e. if you had the following code
double someVariable;
for ( int i = 0; i < 20; i++)
{
someVariable = Math.Pi() * i;
}
and you watched 'someVariable' in the ide you could step through the code and watch how it grows with each step. I would like to be able to run through the loop and plot what that variable did with out having to manually step through it. I am doing a lot of math and sometimes watching how variables change is really useful and insightful.
More info:
I have a bunch of slightly different solvers and depending on the problem I am troubleshooting I would like to watch different variables to see where the problems are occurring. I currently put log these variables to a log file but it slows down the solver significantly and I have to spend a decent amount of time changing debug code to track down problems. I am looking for a slicker way to do this that is IDE centric. Sort of a Visualizer on steroids.
How about using Tracepoints? In VS 2008 (it's somewhat different in VS 2010) you just add a normal breakpoint, then right-click on it, then select "When Hit...".
In the subsequent dialog box, check "Print a message" and enter something like
someVariable = {someVariable}
This will just output its value to the output window in the IDE.
Screenshot:
Easy way? None.
But you can code it yourself..
Use property.
In setter put code, that will log change in some collection. Possibly save time too.
Use some plotting control to plot this collection
Edit:
If you dont want to create property, you can create some kind of generic class, that will have this property and has some kind of internal logging logic.
Use Perfmon and publish that value to a counter that perfmon can read. Perfmon does all the plotting etc. You just need to publish to perfmon. Unfrotunately it is not very well documented and is not trivial. (well, at least it wasn't trivial for unmanaged c++ when I was looking into it)
I did this a while back and used some classes published in an old MSJ article. (ca 1998 or so)
I will try to find some online docs.
See this question for some links
This may also be useful
If you find a solution or this works for you please let us know.
Hopefully someone will come up with a better answer, but here is what I did in a similar situation...
I output the values, in CSV format, to the console. From there, I would copy and paste into Excel, and let Excel do some graphing for me. It worked quite well, but was a complete hassle during a caffeine-driven development session.
Can't you just define and array and write someVariable to array[i] inside the loop? Then you could reference it after you're done.
double[] x = new double[20];
double someVariable;
for ( int i = 0; i < 20; i++)
{
someVariable = Math.Pi() * i;
x[i] = someVariable;
}
I've found SpPerfChart very easy to use and helpful. Simply add the user control and input your changing data to it. You'll get a graphical plot of whatever number you input realtime.