Let me try to answer this if I am getting you clearly. There are several contributed modules available for creating charts in Drupal. Refer to the comparison of charting modules for more details. You are not specifying the Drupal version, let me assume a use case for 7. Also know that there are various types of licenses (commercial, open source, ...) for each of the charting libraries, so your choices may be limited by your license needs (each module typically requires at least 1 such charting library as its charting engine).
The solution I am giving has a lot to do with the Google Charts API implemented via the Google Chart Tools module. The module provides a simple API that allows you to build your graphs on that.The module ships with an example that gives a nice pointer to writing your own custom module.
A simple module to get the content types.
function example_block_info(){
//lets display this in a block. You can do a page if you like.
$blocks['example_chart'] = array(
'info' => t('Example Line Bar Showing Content Types'),
'cache' => DRUPAL_CACHE_PER_ROLE //This is a Drupal default.You can set your own.
);
return $blocks;
}
function example_block_view($delta = ''){
//Create a display for the block.
switch ($delta) {
case 'example_chart':
$block['content'] = example_block_contents()
break;
}
return $block;
}
function example_block_contents(){
//This is a function specific to the block that lets you prepare the content for the chart.
//Google Chart Tools integration begins here.
//First empty the array that is to be passed to draw_chart().
$settings = array();
//We then populate the array.
$settings['chart']['Chart for Nodes'] = array(
//I am using just one content type. You can loop to get the other node types.
'header' => array('My Node'),
//This is the array to be presented to draw().
'rows' => array(array(
example_node_count(),
)
),
'chartType' => 'ColumnChart',
'containerId' => 'example_chart',
'options' => array(
'forceIFrame' = FALSE,
'title' => 'A column chart for nodes',
'width' => 800,
'height' => 600
)
);
draw_chart($settings);
//Return the DIV containing the chart.
return '<div id="example_chart"></div>';
}
function example_node_count(){
//Custom function to count the nodes available.
//Put to use Entity Field Query.
$query = new EntityFieldQuery;
$query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'my_node_type');
//Count your node type.Introduce a loop to count your other nodes as needed.
$my_node_type_count = $query->count()->execute();
return $my_node_type_count;
}
This is just a shell of a working module. Get some education of the charts at Google Visualization API docs. Warning: There might be some typos in there. Just trying to give an alternative.