How to make a Spoke Chart

Share

Facebook
Twitter
LinkedIn

Last week at the Chandoo.org Forums, MarnieB asked:

I have been asked to produce a chart that looks like the spokes in a wheel. Lines for each data point that start from the same point in the middle and go out in different directions. The length of the line indicates the value of the data point. There are only 5 or 6 data points.

Lets see how we can produce such a “Spoke Chart” in Excel.

Disclaimer: Before I go too far I want to say that this post isn’t recommending the use of this type of chart. The post is about introducing techniques which you can use as the basis of many custom chart types. The post just uses this chart as a simple example.

 

EXCEL CHART TYPES

Excel doesn’t have a native Spoke Chart in its catalog of built in Chart Types.

As MarbnieB found out, Radar Chart give some level of simulation, but there not ideal for what MarnieB’s boss wanted.

Luckily for us Excel has a Scatter Chart and this chart type can be used as a veritable drawing board for your own purposes.

The Scatter Chart draws lines between sets of coordinates in the X-Y plane.

Typically Scatter Chart are used for Plotting two variables against each other where neither the X or Y axis has a regular occurrence frequency,

But Scatter Charts can also be used for adding custom chart types as we will see below.

 

MARNIEB’s SPOKE CHART

Lets look at MarnieB’s specifications:

  • It should have 5 or 6 spokes
  • Spokes radiate out from a central hub
  • The length of the spokes should reflect the spokes value

So it will look something like this:

(Not drawn to scale)

We can imagine that the center of the Spoke is at a position X=0, Y=0 or (0, 0) on the Cartesian plane.

We can then break up a circle into a number of segments n. MarnieB’s requirements n = 6.

As a full circle is 360 degrees we can see that each spoke will be separated by 360/6 = 60 Deg

Hence there will be spokes at:

  • 0 Deg
  • 60 Deg
  • 120 Deg
  • 180 Deg
  • 240 Deg
  • 300 Deg

The length of each spoke will be supplied by MarnieB.

We can use the Scatter chart to plot each Spoke as a separate series on the scatter chart.

Each series will consist of two points, being the center point (0, 0) and another point at the end of the spoke (x, y).

 

We will need to determine the X and Y values for each end of the spoke.

Using some simple trigonometry we see that:

X = Length * Cos ( angle )

Y = Length * Sin ( angle )

Now we know the angles and lengths and so in Excel we can setup a small table to calculate the X, Y values for each end of the spokes.

Using Excel we need to remember that Excel requires angles in radians. This just requires a simple modification to the formula to:

X = Length * Cos (Radians( angle ) )

Y = Length * Sin (Radians( angle ) )

 

Setup the Chart Series

Before we jump in you can follow along this example using a new Excel file or the worked Example File, Excel 97/03, Excel 07/10.

As mentioned above each spoke will require two points

Point 1, The center of the spoke at 0,0 and a point at X, Y

In Excel we setup a small table of the Inputs including the Point Id, Angle and Length

We can then add some formulas to take the inputs and convert them to X, Y Cartesian coordinates using the formulas described above.

 

Putting the Chart Together

Once you have the Spoke coordinates you can construct the chart

With NO data selected, goto the Insert Ribbon and select Scatter, Scatter with Straight Lines

A blank chart will appear on the Screen

You can resize and shift the chart to a useable location if you require.

Right Click on the Chart and select the Select Data option

The following dialog appears:

Select the Add, button and the Edit Series dialog appears.

The Series Name: is linked to the Spokes Name $A$4

The Series X values: is linked to the two Chart X values: E3:E4

The Series Y values: is linked to the two Chart X values: F3:F4

Ok when complete

You can now go ahead and add the other 5 Series to the chart by selecting the Add button.

Your Select data dialog will now appear like:

And the chart will appear something like:

Cleanup and Format the Chart

We now need to clean up and format the chart

Select and Delete the Charts Title, Chart Legend & Horizontal Grid Lines

Select Each Axis in Turn, Right Click and Format Axis

Set the Minimum and Maximum values to something greater than our data eg: -20, +20 in our example. The Minimum and Maximum for the Horizontal and Vertical axis bust be the same so that the chart scales correctly.

Resize the Chart so that it is approximately square

Leave the axis for now, it is simple to delete them later

Select each spoke in turn

Right Click and select Format Data Series

Set the Marker Options, Marker Fill, Line Style, Line Color to suit your preferences

If you want to add a marker to one end of the line, Select the line, then use the Right/Left arrow keys to select the end you want, Ctrl 1 to Edit the Format of that end only.

Your chart should now be something like:

Add Data Labels

Select each spoke in turn using the Up/Down arrows, then using the Right/Left Arrow keys, select the outer end of the Spoke

Right Click and Add Data Label

A Default value will appear which is the Y Value for the data point

Right Click on the Data Label then select Format Data Label or simply press Ctrl 1

Unclick the Y Value and Tick the Series Name

Repeat for each Spoke.

You may want to change the alignment for some of the Data Labels so they don’t clash with the spokes.

Add Circular Grid Lines

Lets add 3 Grid lines at a Maximum value and at 1/3rd and 2/3rds of that value

First we need to calculate the Grid Values

In cells C22:C24 I added 3 formulas

I have then assigned 3 Named Formulas to the 3 cells

Max_Circle: =$C$22

Mid_Circle: =$C$23

Min_Circle: =$C$24

To make a circle on a Scatter Chart we will need some points for the X and Y values for each point around the circle

To achieve this I will use a few Named Formulas:

t: =RADIANS(ROW(OFFSET(‘1’!$A$1,,,361,1)))

X_1: =SIN(t)*Max_Circle

Y_1: =COS(t)*Max_Circle

X_2: =SIN(t)*Mid_Circle

Y_2: =COS(t)*Mid_Circle

X_3: =SIN(t)*Min_Circle

Y_3: =COS(t)*Min_Circle

 

Lets look at a few of these and see what is going on:

t: =RADIANS(ROW(OFFSET(‘1’!$A$1,,,361,1)))

This formula sets up an Array of 360 values from 1 to 361, corresponding to 1 degree to 361 degrees. This occurs using the formula: = ROW(OFFSET(‘1’!$A$1,,,361,1)) which takes the Row value of an temporary range which is setup from cell A1 and offset 0 Rows, 0 Columns and is 361 rows high and 1 Column wide.

In a blank cell C27 type: = ROW(OFFSET(‘1’!$A$1,,,361,1)) press F9 not Enter

Excel will display ={1;2;3;4;5; … ;355;356;357;358;359;360;361}

1 number for each row, which will be used to represent the degrees of the circle

 

In a blank cell C28 type: =Radians( ROW(OFFSET(‘1’!$A$1,,,361,1))) press F9 not Enter

Excel will display ={0.0174532925199433;0.0349065850398866;0.0523598775598299; … ; 6.2482787221397;6.26573201465964;6.28318530717959;6.30063859969953}

The same array of Degrees now converted to Radians

You can learn more about how this style of formula works by reading the Formula Forensics Series where a number of similar formulas are used.

 

We can now use the Array of Radians to feed the Formula for the X and Y values

Looking at X: the X value of each point will be X = Circle Radius * Cos( t )

Where t is our array of Radians

So for Circle 1, the Maximum Circle the X Values will be

X_1: =Cos(t)*Max_Circle

In a blank cell C29 type: =COS(t)*Max_Circle press F9 not Enter

Excel will display ={14.9977154273459;14.9908624052864;14.9794430213186; … 14.9908624052864;14.9977154273459;15;14.9977154273459}

This is an array of the X Values of the Maximum Circle, all 360 of them.

You can check out the other X and Y values for the other circles yourself.

To add the Circular Grid lines to the chart, Right Click on the Chart, Select Data

This is the same Dialog we saw earlier

Select Add

Series name: =”Max Circle”

Series X values: =’1′!x_1

Series Y values: =’1′!y_1

Note: that we have added the worksheet name and the Named formula to the Series X and Series Y value fields. This serves to reference the Named Formula to this worksheet, sheet “1”.

Select Ok and add the Mid and Min Circles in a similar manner.

Your chart should now be similar to this:

Add Grid Annotation

Add Grid Annotation by adding 3 more series to the chart, 1 series for each annotation point.

We can put a point at the intersection of the 3 circles and the X Axis because we know the radius and the Y value = 0 so the 3 points will be at

(Min_Circle, 0)

(Mid_Circle, 0)

(Max_Circle, 0)

Once again Right Click on the Chart, Select Data

This is the same Dialog we saw earlier

Select Add

Series name: =”Min Annotation”

Series X values: =’1′!Min_Circle

Series Y values: ={0}

We can note that we have used the Named Formula for the Min Circle value as the X Value and that we have used a constant array for the Y value of 0.

Repeat this for the Mid and Max annotation points.

 

Format the Annotation Points

The 3 points you have just added to the chart may or may not be visible

The easiest way to find them is to either

Use the up/down arrow keys to scroll through the Chart series until you see it selected

Or

Select the Chart

Goto the Chart Tools, layout Ribbon and select the Min Annotation series from the drop down list:

If there is a marker showing, set the Marker Style to None

Close the Format Dialog and Right Click on the Marker, Add Data Labels

Select the Data Label and Change it from the Y Value to the X Value

Also change the Label Position to Above

Resize the Chart

Right Click on the outside of the Chart and select Format Chart Area

On the Size Tab, set the Height and Width to the same value

Select the Horizontal Axis and Delete it and repeat for the Vertical Axis

Your chart is now complete

 

DOWNLOAD THE ABOVE FILE

You can download the Example File used above: Excel 97/03, Excel 07/10.

 

OTHER CHARTS DONE IN EXCEL USING SCATTER CHARTS

As you have seen above the Scatter Chart can form the basis of your own custom Charts with the results being limited by your imagination.

Presented below are three Scatter charts where the authors have taken Scatter Charts to the extreme.

 

Hui’s – 3D Pendulums

In 2011, I produced an animated Scatter Chart consisting of 18 x 3D Pendulums in Excel which includes the ability to rotate the chart whilst the pendulums are swinging.

This is a Scatter Chart that consists of about 22 series, 18 for the Pendulums and a few others for the Frames and Axis.

The maths behind the pendulums locations and the rotations is all done via named formulas with a very simple macro driving the animation.

http://chandoo.org/wp/2011/07/06/3d-dancing-pendulums/

Excel Hero – Smith Chart

Daniel Ferry at Excel Hero.com has produced what I consider one of the most amazing charts in Excel I have ever seen.

I don’t make this statement just for the actual modelling of the Smith Chart or the use of Excel and Named Formulas in particular but also for the sheer Beauty that is displayed in the finished chart.

http://www.excelhero.com/blog/2010/08/excel-high-precision-engineering-chart-1.html

ExcelHero - Smith Chart

 

Frankens Team

The Frankens team has published a number of strange charts with a lot of them based on Scatter Charts.

https://sites.google.com/site/e90e50fx/home/creative-and-advanced-chart-design-in-excel

Please note that some of these charts use advanced excel techniques and are not for the feint hearted.

 

Yes the 3 charts above are all Scatter Charts, illustrating the incredible diversity that can be achieved using this tool.

 

WHAT CHART STYLES WOULD YOU LIKE TO SEE ?

What do you think of the techniques discussed above ?

What chart styles would you like to see ?

Let us know your thoughts to the above in the comments below:

 

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst
Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

30 Responses to “Rescue oddly shaped data – Battle between Formulas, VBA and Power Query”

  1. MF says:

    Nice use of Power Query! Power Query is simply awesome! But somehow a lot of people are punishing themselves by not using it (not learning it).

    An imperfect 4th approach for consideration... no codes at all...
    Select myrange.
    Go to Special --> Blank
    Delete Cell --> Shift cell left
    90% done... now we just need to move the data of 2nd column to the bottom of 1st column
    Of course... Power Query is the best.
    Cheers,

  2. There is another way but it involves multiple steps:
    Copy the values in column E, move the cursor to F5, Paste Special with Skip Blanks, OK
    Copy the values in column D, move the cursor to F8, Paste Special with Skip Blanks, OK
    And so on.
    This works perfectly, albeit a little clumsily apart from the values in B17 and C16, which can be moved with simple copy and paste

  3. Robson says:

    Power Query Forever! I do not know how I survived for so long without knowing and using this tool, I can not recommend it to my colleagues, but by the way they prefer to suffer to learn.

    My congratulations here from Brazil.

  4. Haz says:

    I rolled my eyes when I saw that data

    Using decimal places is a nice trick to order data, thanks for that

    And tweaking the first formula a bit, you can use OFFSET instead of INDIRECT

    =OFFSET($A$1, MIN(IF(myrange, ROW(myrange)), ROWS(A$1:A1))-1, RIGHT(TEXT(MIN(IF(myrange, ROW(myrange) + COLUMN(myrange)*0.00001), ROWS(A$1:A1)), ".00000"), 5)-1)

    • Michael Connor says:

      Tried the above formula with the downloaded oddly shaped data file and I could not get it to work. I get #value without ctrl+shift+enter, and #ref with ctrl+shift+enter.

      • Haz says:

        Sorry, it was SMALL, not MIN.
        Add with CTRL+SHIFT+ENTER.

        • Michael Connor says:

          Thank you for your formula. Like the indirect formula I tested this one in older versions of EXCEL and it worked without ALTERATION in EXCEL 95. Very impressive.

  5. Bertie Hechter says:

    Too complicated

    Use =Sum to summarize all the sells to the left and Bobs Your Uncle

  6. Michael Connor says:

    I tested this formula in versions of Excel all the way back to Excel 95

    =IF(ISERROR(INDIRECT("R"&SUBSTITUTE(TEXT(SMALL(IF(MyRange"",ROW(MyRange)+COLUMN(MyRange)*0.00001),ROWS(A$1:A9)),"00000.00000"),".","C"),FALSE)),"",(INDIRECT("R"&SUBSTITUTE(TEXT(SMALL(IF(MyRange"",ROW(MyRange)+COLUMN(MyRange)*0.00001),ROWS(A$1:A9)),"00000.00000"),".","C"),FALSE)))

    So there are multiple ways of cleaning up messy data by formulas.

    • Chandoo says:

      Wow.. Excel 95. Who knew people still use that. But as you have shown, Excel has all these beautiful and powerful functions for 23 years. It has data sciency stuff before DS was even a thing.

      • Michael Connor says:

        I had a problem with pasting the formula in the original post.
        Formula should be: =IF(ISERROR(INDIRECT("R"&SUBSTITUTE(TEXT(SMALL(IF(myrange"",ROW(myrange)+COLUMN(myrange)*0.00001),ROWS(A$1:A1)),"00000.00000"),".","C"),FALSE)),"",(INDIRECT("R"&SUBSTITUTE(TEXT(SMALL(IF(myrange"",ROW(myrange)+COLUMN(myrange)*0.00001),ROWS(A$1:A1)),"00000.00000"),".","C"),FALSE)))

        EXCEL even in a 16 bit version, is a very robust and capable program.

  7. Michael Connor says:

    I don't like the VBA code. If you have a blank row in MyRange, the last entry in the range is doubled up in the paste.here range.

    • Chandoo says:

      Not really. The macro is writing one cell at a time from paste.here. You have to clean the range before, which I was too lazy to write. But a line like Range(range("paste.here"), range("paste.here").end(xldown)).clearcontents should do the trick.

      • Michael Connor says:

        Adding Range(range("paste.here"), range("paste.here").end(xldown)).clearcontents fixed the problem.

  8. A Rakesh Patro says:

    for step split column by delimiter i am not getting option of split into rows or columns. Can you help me in this

  9. Marc says:

    Thanks Chandoo for promoting Power Query.

    To simplify further, you can "Unpivot Columns" instead of right click on the newly created column and split it by comma in to rows in step 3 of Power Query.

  10. johan says:

    i used

    =LOOKUP(10000,B5:F5)

    and got the answers. I just plagiarized this formula somewhere and use it, maybe you can explain why it works.
    Regards

    • Chandoo says:

      @Johan... I am not sure if the formula works correctly. When I tested it with the sample data in this post, it showed #N/As in two cells. Essentially, it will only give first value in each row. So if a row has multiple values, then subsequent values are missed. LOOKUP() function goes thru a list and finds the first value that is less than or equal to the input - in this case 10000 in B5:F5.

  11. Ben says:

    I have the need to convert pdf's to excel on occasion and they often come out a mess like this. I have used:

    Cell G2 =COUNT(myrange)
    Cell G3 =IFERROR(IF(G2-1<1,"",G2-1),"") copied down to G100
    Cell H2 =IFERROR(LARGE(myrange,G2),"") copied down to H100

  12. Patrick says:

    Waouw...

    =IFERROR(INDIRECT("R" & SUBSTITUTE(TEXT(SMALL(IF(myrange "", ROW(myrange) + COLUMN(myrange)*0.00001),
    ROWS(A$1:A1)), "00000.00000"), ".", "C"), FALSE), "")

    but CTRL Shift Enter with {} before and after 🙂 😀

  13. Peter B says:

    Another possibility.
    This assumes that you have a row index 'k' to use in the SMALL function and a column index 'h' to identify the columns of 'myRange'.
    If you define 'coord' to refer to
    =k+h/10 [assuming h<10]
    then it will be possible to recover values later based upon location within 'myRange'. The formula 'nb' that identifies non-blanks by coordinates is given by
    = SMALL( IF(myRange"", coord), k )
    Finally, to unpick the pieces
    = INDEX( myRange, INT(nb), 10*MOD(nb, 1) )

  14. Peter B says:

    Whilst I am here and making trouble the PQ solution is also a tad over-complicated. All that is needed is to unpivot the entire table and remove the Attribute column.

    The advanced editor would show
    let
    Source = Excel.CurrentWorkbook(){[Name="myRange"]}[Content],
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"})
    in
    #"Removed Columns"

  15. vivian.liu says:

    1.fill the blank cells with 0
    2.the requested column value=sum of those mess number column
    but this can be used in only one column has value

  16. Juan Carlos Barreto says:

    Chandoo

    And if we use the formula SEARCH (100000000, B5: F5)

    JC

  17. Daniel Dion says:

    Another approach with Power Query, it will still work if the number of columns changed:
    let
    Source = Excel.CurrentWorkbook(){[Name="myrange"]}[Content],
    #"Added Custom" = Table.AddColumn(Source, "List", each Record.ToList(_)),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"List"}),
    #"Expanded LIst" = Table.ExpandListColumn(#"Removed Other Columns", "List"),
    #"Filtered Rows" = Table.SelectRows(#"Expanded LIst", each ([List] null))
    in
    #"Filtered Rows"

  18. Bob says:

    Nowadays, you can just use TOCOL on Excel 2024, MS 365, and Web Excel. It has a parameter to ignore blanks/errors/both.

Leave a Reply