VBA Bestfit position for datalabels on line chart - excel

I was trying to make my own function to reposition data labels on line chart so they'll be in their best fit.
What does it mean best fit?
The data label wont be above the line itself (I took the higher angle of the point and put the data label in higher-angle/2 - so it will be in the middle of the higher angle) - I succeed to get the higher-angle but didn't succeed to get the position on graph (in pixels, relatively)
After u put the data label in the middle of the higher angle, you need to check with the other seriescollections, that the data label is not above one of other seriescollections line... - didn't reach this part.
and still I am not sure that's it...
Is anybody got something prepared? or someone wants to help me with it?
It is way over my level right now...

"Best fit" is a setting unique to pie chart data labels.
You have the option of positioning a line chart's data labels centered (directly on a point), as well as above, below, left of, and right of the point. You can also position the data label anywhere by changing the .left and .top properties of the label. Left and Top are in points with respect to the top left corner of the chart, so you will have to brush up on your algebra to fine tune label positioning.
As with all else involving charts, Keep It Simple is sound advice. Do you need to label everything, or can you get away with a few key labels?

So after some tries, I decided to ditch the idea since this's way too complicated for me.
What I can say is that I ditch it after I stepped up a little bit.
I could find the best position for each label only when there's one line.
I achieved it by calculating the bigger arc (assumed each point is the middle of a circle), and than put it in the middle of that arc.
to do it when you have more than one line, you have to consider the position of the points of the other line/s. Therefore it becomes much more complicated and this is the reason I decided to ditch it.

Related

Algorithm for determining LR and TB order when not uniform

wondering if anyone has any insight as to how to ascertain the order of differently sized rectangles from left to right and from top to bottom when they are not already aligned to any grid, and they are differently sized and/or rotated. Some might also be missing.
As anyone can see from the illustration, the objects should be numbered as shown. But how, mathematically or programmatically, can I determine this? What is the logic? I don't even know what words to use to describe the problem.
This looks like a rather complex problem; maybe some algorithm already exists, IDK.
Approach 1: grid positioning.
One approach could start with trying to position the rectangles on a grid whose mesh size will have to be calculated; maybe a best fit to the size of the rectangles (H & W, or surface, maybe?)
Once a reasonable grid has been determined, it must be appropriately placed over the rectangles; maybe in such a way that minimizes row overlap and column overlap of the rectangles?
The last step would consist of traversing the grid row by row, and assigning a label to each rectangle; maybe based on the max common surface shared by a grid cell and a rectangle?
There will be many edge cases to identify and resolve.
Approach 2: sweep line.
Alternatively, a sweep line numbering of the rectangles from N, S, E, and W, and an appropriate weighting/averaging of the numbering of the rectangles from each direction, might give good results?
It may require several passes, after identifying what could be rows and columns, in order to find a "best fit".
This second approach is likely easier to implement.

Add extra labels to a chart

I'm using Excel 2016 and wanted to know how I can make a chart that represents a spectrum from left to right with labels on both sides, and a marker in the middle. Essentially I want to represent the Myers Briggs Type Indicator.
What I've tried so far is to make a horizontal bar chart with a marker, but I can't seem to get labels to the left and right. How might I be able to achieve this?
You just need to add text boxes from drawing tools and put them on top of the chart. Set their backgrounds to transparent by choosing no fill.

Is there a way to transform rectangle into any shapes in MS Excel?

In MS Excel, I applied conditional formatting to a cell A1 so that it's color changes from blue at value 0 and red at value 100. I copied that cell and pasted it as linked picture(I) specially.(Paste Special). The color of the rectangle picture now changes if value in original cell is changed. The problem is, the shape is only rectangular, it can be converted into square and diamond shape at best.If same rectangle can be transformed into different shapes(maybe by adding extra anchor on rectangle shape), a heat map can be created easily. Please share your insights about this thing if there is a way.
Following pictures may help understand the problem:
[Example][1]
If you want a heat map, please consider using a CHART not gazillions of picture objects, colored/placed/rotated/etc to ... mimic a chart.
First, google anything about "surface chart" in Excel, see how it looks in Excel, whatever. Just see it and think about it so you can compare it to your current approach.
You will observe some things, like:
it's 3D
it has just a few layers/colors
etc.
But really, all of them can be solved. Probably easier than your current approach.
you can easily turn off both axes and you can rotate it so the camera is totally straight top-down - then it looks flat as paper and noone can see it as 3D anymore
you can add more layers, you can set each of them to specific colors
etc.
Some resources:
multiple colors in surface chart
how to change rotation of 3d chart
geesh, I just found even a whole article/tutorial dedicated to creating heat map charts.
Please, read that last link and I'm pretty sure you will want to use that approach instead of doing picture puzzles.

Excel VBA - Making points invisible removes markers

I'm having a problem to making some points of my series (making them invisible). In the image below, you can see that it goes well until I make the point invisible. The marker's legend get all confused and set the legend to the XValues, in this case "1","2", and so on.
Is it possible to make a point invisible but keeping the original marker legend?
May I suggest to substitute the "invisible" points' values with CVErr(xlErrNA)? That way the line will still be drawn, but these points will be "ignored".
Or do you need to mantain those values?

Corona SDK: Rotating an object with specific reference point consecutively

I'm trying to make a square move by rotating it sideways with its reference point set to the bottom side of the direction it is moving to.
For example: if I would move the square to the right, I would set its reference point to the bottom right of it and animate a rotation of 90 degrees, after the movement is done, I increase the square X by the width of it and centrally set its rotation to 90 degrees (so that I can keep track of its position)
The thing is, how should I proceed to keep repeating it? 'cause if I try to rotate by another 90 degrees using bottom right reference point, it won't be using the right position. What should I do to get the new bottom right relative position?
Thanks!
Create a transparent image twice as wide and high as the square.
Place the square in the top left corner.
Rotating the image around its center will now rotate the square in the way you describe.
You will need some maths to track where the new bottom is, using some simple formula for 2D rotation, so you calculate BEFORE rotating, where the point you wish to modify.
Then you use xReference and yReference variables :)

Resources