I'm trying to create a series of inline charts to be displayed on the detail of a record using either Visualforce Charting or Highcharts. The charts do need to be dynamically rerendered based on any changed information on the page, they are static after page load. I would like to create charts like this for a few different objects in the database so I've setup a controller extension that services muliple sObjects and uses a series of if statements and instanceOf declarations in the constructor to figure out the object I'm on. My goal is write the fewest lines of code using abstract or virtual classes when appropriate and I'm in need of an appropriate design pattern.
Ideally, my controller could service all of the charts but this is where I got stuck. Each chart has so many different attributes, like type (pie, bar, or multi-axis line and bar), whether there is a right axis, the SOQL query or in some cases multiple SOQL queries for multi-axis charts, and on and on. Since I'm not sure I can fully componentize my chart with passed in attributes given the complexity of each chart, is there anything that can be made extensible in my controller? What is the same from chart to chart is whether or not the org uses the fiscal year, and the data model of the charts. There is always a set of x-axis categories like months or years, and there is always one, two, or three numeric data sets for the y-axis.
In my controller extension, I'm having to write getters for each set of categories and each data set for each chart and I'm thinking that there must be a better, more extensible way. What am I missing?