Wednesday, March 21, 2012

CSV to Chart Utility

In my last project we had a requirement where we need to build the good report from the csv data. One way to do that is to use excel and create chart from excel. 
But to combine all chart in single report(If there are multiple charts), do data processing if any (We can use micro if person is good in excel) is tedious job.  I am attaching the mevenize project with some screenshot which will help you to understand the Utility.

This tool is helpful to create good charts/reports from CSV. You can pass the set of CSV, tool will do the data processing(data conversion)
if defined and create a pdf/xls/doc based charts on user choice. Tool will create a chart and tabular report as configuration and 
render that in a page. For all valid CSV’s, it will create a chart report in a new page.

Underneath it is using Dynamic Reporting for charting/reporting and Spring DI for report configuration. All report configuration specified below can be configured using XML file. 
1.       Name of PDF (refer attachment Report Config.png)
2.       Report header (refer attachment ReportConfig.png)
3.       Report footer
4.       Chart name (refer attachment Component-Config.png)
5.       Chart X and Y axis (refer attachment Component-Config.png)
6.       Chart Label (refer attachment Component-Config.png)
7.       Chart Type (refer attachment Component-Config.png) - Currently It support Bar, Line,XYLine chart.
8.       Blank page (refer attachment BlankPageConfig.png)
9.       Data Processor – Data processor is used to convert Raw data into some specified format which should be shown on report like change milliseconds to second, hours to min, Byte to MegaByte, etc (refer attachment DataProcessor.png)

Some configuration for Report Component
Report Configuration
       <bean id="performanceReport" class="com.sapient.dynamicreports.configuration.Report">
              <property name="name" value="PerformanceReports" /> - output report file name
              <property name="displayName" value=" Performance Test Report  " /> - output report header
              <property name="outputType" value="PDF" /> - output report type
              <property name="outputPath" value="c:\\output" /> - output path
              <property name="components">
                     <list>
              List of components ---
                           <!-- <ref bean="blankPage" /> -->
                           <ref bean="cpuUtilization1" />
                           <ref bean="memoryUtilization1" />
                           <ref bean="threadUtilization1" />

                           <ref bean="cpuUtilization2" />
                           <ref bean="memoryUtilization2" />
                           <ref bean="threadUtilization2" />

                           <ref bean="cpuUtilization3" />
                           <ref bean="memoryUtilization3" />
                           <ref bean="threadUtilization3" />

                           <ref bean="responseTimePerTransaction" />

                     </list>
              </property>

 Component Configuration

       <bean id="activeThreadOverTime" class="com.sapient.dynamicreports.configuration.Component">
              <property name="name" value="ActiveThreadOverTime" />
-    Name of the component
              <property name="displayName" value="Active Users Over Time" />
-    Display name , which will come in the output report
              <property name="dataSource" value="CSV" />
-    Data source type – in our case it will be CSV
              <property name="dataSourcePath"
                     value="c:\\csvfileset\\input\\ActiveThreadsOverTime.csv" />
-    Data source – CSV file name
              <property name="dataSourceFileName" value="ActiveThreadsOverTime.csv" />
              <property name="chartConfiguration" ref="atotChartConfiguration" />
-    Define the chart Configuration
              <property name="pageType" value="A4" />
-    Page type of chart
              <property name="pageOrientation" value="PORTRAIT" />
-    Page orientation of chart
              <property name="dataProcessor" ref="customDataProcessor" />
-    Data processor if any
              <property name="tableType" value="NO" />
-    Table type could be NO, AGGREGATED, SIMPLE
       </bean>


       </bean>





Some of the screenshot (ReportPage1.png, ReportPage2.png) will give an idea how the report will look like. also fine high level class diagram for code in Image1 and Image2.  You can download code from here

1 comment:

Anonymous said...

You really make it seem so eaѕy ωith your presentation but Ӏ find this topiс to be aсtually something whiсh I think I ωоulԁ never
understand. ӏt ѕеems too complex and еxtremely broad for me.
Ӏ am looκing forward fоr yοur next post,
I'll try to get the hang of it!

My web site ... sell house Fast