Category pie diagram meta box in post editing page

The problem might be because of this line:

echo do_shortcode('[mycategories]');

It should not stand alone like this in the plugin file, because this will show up before the headers are sent out. I guess you added this line just to check the output? Try to remove this line or encapsulate it with a relevant function. You could instead add the shortcode [mycategories] into the content of some post/page to test it.

You could replace this line

add_meta_box( 'my-meta-box-id', 'Category by Percentage', 'categories', 'post', 'normal', 'high' );  

with

add_meta_box( 'my-meta-box-id', 'Category by Percentage', 'category_meta_box_html', 'post', 'normal', 'high' );  

and add this function:

function category_meta_box_html(){
    echo do_shortcode("[mycategories]");
}

to display the graph inside the metabox.