VBA - Drawing an Arc based on 3D Bubble scatter graph coordinates

Jason3000

New Member
Joined
Sep 23, 2018
Messages
1
Hi guys

I am trying to draw an arc in a 3D bubble scatter plot.I have a code that looks like this

Sub insertArc()


Dim Arc As Shape
Const CenterX = 200
Const CenterY = 200
Const Radius = 10

ActiveSheet.ChartObjects("Chart 15").Activate


Set Arc = ActiveChart.Shapes.AddShape(msoShapeArc, CenterX, CenterY - Radius, Radius, Radius)
Arc.Line.EndArrowheadStyle = msoArrowheadTriangle
Arc.Adjustments.Item(1) = 30
Arc.Adjustments.Item(2) = 180

how can i reference the Const CenterY and ConstCenterX to the graph origin ?




End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Re: VBA HELP! Drawing an Arc based on 3D Bubble scatter graph coordinates

Hi Jason
Welcome to the board

You can get the origin coordinates from the axes. You get the X coordinate from the beginning of the X axis and same for the Y coordinate with the Y axis.

This is an example:

Code:
Sub CircleAtOrigin()
Dim cht As Chart
Dim axisX As Axis, axisY As Axis
Dim dX As Double, dY As Double, dRadius As Double

Set cht = Worksheets("Sheet1").ChartObjects("MyChart").Chart
Set axisX = cht.Axes(xlCategory) ' X axis
Set axisY = cht.Axes(xlValue)      ' Y axis

' Origin coordinates
dX = axisX.Left                     ' X coordinate of the origin
dY = axisY.Top + axisY.Height ' Y coordinate of the origin

' Ex: draw a circle of radius 5 around the origin
dRadius = 5 ' radius of the circle
cht.Shapes.AddShape msoShapeOval, dX - dRadius, dY - dRadius, 2 * dRadius, 2 * dRadius

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top