Microsoft Chart draw coordinates of point - visual-c++

I am using MS Chart Control to draw simple 2D chart.
I would like that each point have label which contain his own coordinates, i.e: 2,5 (where 2 is X, and 5 is Y).
I found that in Series property is something like IsValueShownAsLabel, but it shows only Y value of point.
My question is: what is the simplest way to reach that?

OK, i found an answer.
chart1->Series["Series1"]->Label = "(#VALX;#VAL)";
or in Properties of chart -> Series -> Label and here type: (#VALX; #VAL)

Related

Conditional rounded corners on stacked bar chart

I have a chart with stacked bars A and B
A is on top of B and A have top corners rounded but not B.
But I want B having rounded top corners when A = 0
You can leverage the ZingChart Stacked Bar chart token “%scale-value-value” (or “%vv”) for this. It’s the sum value of the stacked node and all nodes stacked below it.
Using a rule, compare this sum value to the “%stack-total” (or “%total”) to determine if the node is the top of the stack, then add your border radius:
“rules”: [
{
“rule”: “%vv == %stack-total”,
“borderRadiusTopLeft”: “10rem”,
“borderRadiusTopRight”: “10rem”
}
]
Put that rule in your “plot” object and you should be fine.
I made a demo in the ZingChart studio if you want to check it out.
An alternative (more or less flexible, depending on the setup) is to use (%node-value)(PLOTINDEX) locator to check for the value of the node "below"
"rules":[
{
"rule":"(%node-value)(2) === 0",
"borderRadiusTopLeft":"10rem",
"borderRadiusTopRight":"10rem"
}
]
This basically says: if the value of the corresponding node of the 3rd plot (plot index is 2) is zero, then round the borders.
See: https://app.zingsoft.com/demos/view/ZJ1XMRK3

How to do an Arrhenius plot using excel-VBA? AKA: How to do a reciprocal x-axis in excel-VBA?

I want to write a program to transform temperature dependend data into an Arrhenius plot. An Arrhenius plot show the logarithm of a property that is thermally acitavted versus the reciprocal temperature aka 1/T. Now is 1/T something that most people are not used to. This is why most of the plot also contain the translation in temperature on a second axis. Usually on top of the graph. The output should look like this:
Picture Source
The second axis is only for better readability and is corresponds to the primary axis with the relation:
primary=1/secondary
secondary=1/primary
What I am not able to do in excel-VBA (excel 2010) is the reciprocal second x-axis. There is no predefined axis scaling like this. There is xlScaleLinear and xlScaleLogarithmic for the property ScaleType of an axis. Is there a way to do this?
A secondary problem is that this:
Dim CH As Chart
Set CH = Tabelle2.ChartObjects(1).Chart
CH.ChartType = xlXYScatterLinesNoMarkers
With CH
.HasAxis(xlCategory, xlSecondary) = True
End With
Does not seem to work. Which means that a xyScatterplot does not seem to have a secondaryXaxis enabled.
I could try to add the lables and ticks myself using forms but this seems a little to much pain, I cannot be the only one who has encountered this problem.
Problem 1: How to format an axis reciprocal (1/x)?
Problem 1b: How to properly add a second x axis in a XYscatterplot?
You can do this by creating a fake axis using a series with data labels (inspired by https://peltiertech.com/secondary-axes-that-work-proportional-scales/):
Columns A and B are your data. Column C matches the X-ticks of your primary X-axis. Column D is =1/C2 etc and column E is the y-axis maximum for your chart. Now simply create a new series of columns C and E, format it to have no line and in this case I chose the + marker but you can create your own vertical line marker if you want it to be exact. Then add data labels set to range column D.
I don't think you'll find another way to do it without this hack, but it's really not that hard and doesn't require VBA which is always a plus in terms of readability / audibility of your workbook.
Another alternative would be to use the data labels to write the actual temperature to the data points:
Column C has the temperature in Celsius.
Since the Arrhenius plot is only defined as ln(k) against 1/T, this would be a good option I think.

Excel chart with only x axis and empty space beetween points

I need to draw Excel chart with only x axis and empty space between the points.
For example I will have points on x axis (1,3), (5,8), (9,10)
The line should go from 1-3 then empty then line from 5-8 then empty then line from 9,10
I tried something with Scatter graph but didn't manage to do it.
Basic-lay Y axis can exist but I will always use the same value
Any ides?
Here is screenshot to get the idea. It is not connected to mentioned points
Chart Example
In chart example points would be (3,5) , (7,8)
You can do something like this:
First in your data, add a empty row in your data where you want the space (row 10 in my example).
Choose a "Scatter plot with Straight Lines and Markers"
Then format your axis (right click on x-axis and choose format axis) to "Units" -> "Major": 1.
Notice how my empty space creates a gap between the two series (5,8) and (9,10).

charting trendlines together

I need to display this kind of data in one chart:
Which means:
Function A: Y= X + 10 ;
Function B: Y= X * 2 ;
but what I got from excel is:
Actually what I want is (sorry for the drawing):
My real data is like:
If I format it like this:
I can still not get the correct charts.
Updated to account for change of question
Your data structure is wrong to achieve this in Excel, see for example:
On the left you want your x axis values, don't put a header in this column otherwise it will plotted on your graph as a series (extra line).
You can fill in gaps in your data with #N/A and excel will ignore these points, joining the line to the next available point.

How to put two x,y coordinate values as one in scatter chart in excel

I want to do something like this
I want to make a point x,y coordinate for one and x,y for another and show two points in a single scatter chart.
I am unable to figure out how to do this
x y x2 y2
1 1 1 8
From data above I need to show two points (1,1) and (1,8)
Depending on your data layout, the data points can be added as one series or as two series. Steps vary with your Excel version.
Try this: click an empty cell that has no data in neighbor cells. Click Insert > XY Scatter chart. This will create a blank XY chart. Now add the series.
Right-click the chart > Select Data > Add > select the range(s) for the X and Y values. Repeat for any other series.
If the data is in one contiguous table, you only need one series.

Resources