Diagram generation process

From Catglobe Wiki
Revision as of 04:04, 4 August 2009 by Catglobe (talk | contribs) (Create first version)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

Diagram generation process require the inputs which can be in 2 types

  • Mandatory
    • A data cache
    • Selected axes that the diagram will be generated on
    • Output type: table or image
    • Output format: html, pdf, ppt, excel, image
  • Optional
    • An external stylesheet
    • Inline stylesheet
    • Custom settings like: data direction, value to display (absolute/percentage) etc.

Design Goals

  • Report's business is moved to separate assembly named CatGlobe.Report
  • Hide all detail implementations
  • Expose enough information so that from a domain Diagram class we could call something like Build(Diagram) whose parameter is a domain Diagram's instance

Sequence Diagram

Diagram - Generation Process.gif

Report framework users just need to know about ReportBuilder class which provide lot of facade methods into report system. Required parameters are usually the domain Diagram instance and DiagramInfo instance. Below are 3 methods for generating diagram:

      /// <summary>
      /// Convenient method for building as web control.
      /// </summary>
      /// <param name="diagram">The domain diagram</param>
      /// <returns>List of html controls that can be rendered</returns>
      public static IEnumerable<Control> BuildControl(this Domain.Reports.Diagram diagram);

      /// <summary>
      /// Convenient method for building as web control.
      /// </summary>
      /// <param name="diagram">The domain diagram</param>
      /// <param name="diagramInfo">Custom build information</param>
      /// <returns>List of html controls that can be rendered</returns>
      public static IEnumerable<Control> BuildControl(this Domain.Reports.Diagram diagram, DiagramInfo diagramInfo);

      /// <summary>
      /// Build diagrams with information from its domain class.
      /// </summary>
      /// <typeparam name="T">Desired returned type</typeparam>
      /// <param name="diagram">The domain class</param>
      /// <param name="reportType"></param>
      /// <returns>The report object</returns>
      public static IEnumerable<T> Build<T>(this Domain.Reports.Diagram diagram, Enum.ReportType reportType) where T : class;

All detail implementations are hidden, but basically diagram generation are 2 phases process:

  1. From data cache and selected axes, calculate the value series that is to be displayed in chart => this result can be saved and get back later for saving calculation cost
  2. From calculated data series and required output types, export data series into required formats

The above 2 methods are provided as static methods:

   internal abstract class Diagram
   {
      /// <summary>
      /// Build a <see cref="Chart"/> object from an <see cref="DiagramInfo"/> object.
      /// Static input for building process.
      /// </summary>
      /// <param name="diagramInfo">Input <see cref="DiagramInfo"/> object</param>
      /// <returns>Output <see cref="Chart"/> object</returns>
      public static Chart BuildChartObject(DiagramInfo diagramInfo);
   }

   internal abstract class ChartBuilder
   {
      /// <summary>
      /// Build an Array of charts base on chart object and prentation type
      /// </summary>
      /// <param name="chartBuildInfo">Information needed for building chart</param>
      /// <typeparam name="T">The expected returned type of objects</typeparam>
      /// <returns>A collection of object, for most of the case it returns a single
      /// object. The only cases that more than one object are returned is splitting of 
      /// large table into multiple smaller tables </returns>
      public static IEnumerable<T> BuildChart<T>(ChartBuildInfo chartBuildInfo) where T : class;
   }

Document revisions

Version No. Date Changed By Description Svn revision
0.1 04.08.2009 Nguyen Trung Chinh First version 54885