2013년 2월 27일 수요일

Creating a Realtime HTML5 chart



KoolChart is a charting engine which allows you to add more than 30 types of 2D/3D charts to your web pages. It is a pure HTML5/Javascript-based solution and you don’t need to have any plugin installed in your web browser. To create a chart using KoolChart you just need to manage 2 variables (or files), one is for the data and the other is for the layout.




This article will show you how to add a Real-Time chart which has two line series and one column series to your web page using KoolChart. Let’s start with a simple html.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="Content-Script-Type" content="text/javascript"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>KoolChart for HTML5 - Real-Time Chart</title>
</head>
<body>
  <div class="container">
    <div class="header">
      <p>KoolChart - Premium Real-Time Chart</p>
    </div>
    <div class="content">
      <div id="chartHolder" style="width:800px; height:400px;">
      </div>
    </div>
  </div>
</body>
</html>

Step 1. Prepare an html document to which you want to add a chart. By using the above html document, we are going to add a Real-Time chart into the id=”chartHolder” div.

Step 2Include KoolChart.js inside the <head> element of your html document. KoolChart.js is a JavaScript library which is the charting engine for KoolChart.

<script language="javascript" type="text/javascript" src="KoolChart.js"></script>

Step 3Add Javascript statements calling KoolChart-provided Javascript functions inside the <script> element of your HTML document.

var chartVars = "KoolOnLoadCallFunction=chartReadyHandler";

KoolChart.create("chart1", "chartHolder", chartVars, "100%", "100%"); 

function chartReadyHandler(id) {
  document.getElementById(id).setLayout(layoutStr);
}

KoolChart.create() function takes 5 arguments, chart ID, DIV id into which the chart is created, a variable name used by the KoolChart engine. In the above sample, only the function name of the chart ready handler is assigned to the variable. And the last 2 arguments are for the chart’s size, width and height. 100% means that the same size of the chart defined in the id=”chartHolder” div (style="width:800px; height:400px;") is created.


Step 4Set the layout variable.

var layoutStr =
  '<KoolChart backgroundColor="0xFFFFFF" cornerRadius="12" borderStyle="solid">'

    +'<Options>'
      +'<Caption text="Different Cycle (1)"/>'
      +'<SubCaption text="random data" textAlign="right" fontSize="11"/>'
      +'<Legend fontSize="11" useVisibleCheck="true"/>'
    +'</Options>'
    +'<DateFormatter id="dateOrgFmt" FormatString="YYYY/MM/DD HH:NN:SS"/>' 
    +'<DateFormatter id="dateFmt" formatString="HH:NN:SS"/>'
    +'<DateFormatter id="dateFmt2" formatString="HH:NN"/>'
    +'<NumberFormatter id="numFmt"/>'
    +'<NumberFormatter id="numFmt2" precision="2"/>'
    +'<Combination2DChart id="chart" showDataTips="true" dataTipMode="multiple">'
      +'<series>'
        +'<Line2DSeries id="lineSeries" xField="date" yField="data5"  displayName="Data(5 Sec)">'
          +'<lineStroke>'
            +'<Stroke color="0xFF6666" weight="2" alpha="1"/>'
          +'</lineStroke>'
          +'<horizontalAxis>'
            +'<DateTimeAxis id="hAxis2" displayLocalTime="true" labelUnits="minutes" dataUnits="seconds" interval="1" formatter="{dateOrgFmt}" displayName="Time"/>'
          +'</horizontalAxis>'
          +'<verticalAxis>'
            +'<LinearAxis id="vAxis2" minimum="0" maximum="150"/>'
          +'</verticalAxis>'
        +'</Line2DSeries>'
        +'<Line2DSeries id="lineSeries2" xField="date" yField="data3" displayName="Data(3 Sec)" verticalAxis="{vAxis2}" horizontalAxis="{hAxis2}">'
          +'<lineStroke>'
            +'<Stroke color="0x339966" weight="1" alpha="1"/>'
          +'</lineStroke>'
        +'</Line2DSeries>'
        +'<Column2DSeries id="columnSeries" xField="date" yField="data60" displayName="Cumulative Sum">'
          +'<horizontalAxis>'
            +'<DateTimeAxis id="hAxis" displayLocalTime="true" labelUnits="hours" dataUnits="minutes" interval="3" dataInterval="10" formatter="{dateOrgFmt}" displayName="Time"/>'
          +'</horizontalAxis>'
          +'<verticalAxis>'
            +'<LinearAxis id="vAxis" minimum="0" maximum="999"/>'
          +'</verticalAxis>'
          +'<fill>'
            +'<SolidColor color="0x6666FF"/>'
          +'</fill>'
        +'</Column2DSeries>'
      +'</series>'
      +'<horizontalAxisRenderers>'
        +'<Axis2DRenderer axis="{hAxis}" placement="bottom" formatter="{dateFmt2}"  tickLength="30" 
minorTickLength="0" tickPlacement="inside" showLine="false">'
          +'<axisStroke>'
            +'<Stroke weight="1" color="0x999999"/>'
          +'</axisStroke>'
          +'<tickStroke>'
            +'<Stroke weight="1" color="0x6666FF" alpha="0.5"/>'
          +'</tickStroke>'
        +'</Axis2DRenderer>'
        +'<Axis2DRenderer axis="{hAxis2}" placement="bottom" formatter="{dateFmt}">'
          +'<axisStroke>'
            +'<Stroke weight="1" color="0x999999"/>'
          +'</axisStroke>'
        +'</Axis2DRenderer>'
      +'</horizontalAxisRenderers>'
      +'<verticalAxisRenderers>'
        +'<Axis2DRenderer axis="{vAxis}" placement="right" formatter="{numFmt}"/>'
        +'<Axis2DRenderer axis="{vAxis2}" placement="left" formatter="{numFmt}"/>'
      +'</verticalAxisRenderers>'
    +'</Combination2DChart>'
    +'<HttpMultiServiceRepeater baseURL="http://www.koolchart.com/realtimeSample/" targetController="{chart}" 
requestTimeout="30">'
      +'<RPCList>'
        +'<RPCItem name="rpc1" url="data3Interval.php" target="{lineSeries2}" interval="3" concurrency="last" 
retryCount="30"/>'
        +'<RPCItem name="rpc2" url="data5Interval.php" target="{lineSeries}" interval="5" concurrency="last" 
retryCount="30"/>'
        +'<RPCItem name="rpc3" url="data23ToCurrent2.php" target="{columnSeries}" interval="600" concurrency="last" retryCount="30"/>'
      +'</RPCList>'
    +'</HttpMultiServiceRepeater>'
  +'</KoolChart>';

KoolChart provides two types of Real-Time charts, Real-Time chart and Real-Time premium chart. The Real-time premium chart is the upgraded version of the Real-Time chart as it has more useful features than the Real-Time chart. This sample chart has been created by using the features of the Real-Time premium chart.

The above layout can be broken down into four parts, <options>, 5 <formatter>s, <Combination2DChart> and <HttpMultiServiceRepeater>.
1. <Options> : To add a caption or a legend to the chart, you need to define <Caption> or <Legend> into <Options>
2. <formatter> : In this sample, 5 formatters are defined, three formatters for the date and two formatters for the number. Those can be used by setting the ID to the value of the formatter attribute.
3. <Combination2DChart> : This sample chart is a combination chart which has two Line2DSeries and one Column2DSeries. Each series should be defined in <Combination2DChart>.
4. <HttpMultiServiceRepeater> : Unlike the Real-Time chart, the definition of the Real-Time premium chart does not start with <RealTimeChart> (This sample layout starts with <Combination2DChart>). You can create the Real-Time premium chart for any type of KoolChart as long as the <HttpMultiServiceRepeater>.

The above sample layout generates a Real-Time premium chart which has two Line2DSeries and one Column2DSeries and their intervals are 3 seconds, 5 seconds and 10 minutes. The RPC request scenario is that the first RPC request is sent after the initial chart loading is finished and then the next RPC request is sent at an interval specified for each series. In this example, two line series have no initial data and the column series has the initial data. It displays data after the initial loading for 10 minutes then it refreshes the chart with the new data based on the interval of each series for the next 10 minutes. The accumulated sum for 10 minutes is displayed as a column.

Creating a Circular gauge Javascript Chart



KoolChart is a charting engine which allows you to add more than 30 types of 2D/3D charts to your web pages. It is a pure HTML5/Javascript-based solution and you don’t need to have any plugin installed in your web browser. To create a chart using KoolChart you just need to manage 2 variables (or files), one is for the data and the other is for the layout.




This article will show you how to add a circular gauge to your web page using KoolChart. Let’s start with a simple html.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="Content-Script-Type" content="text/javascript"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>KoolChart for HTML5 - Circular Gauge</title>
</head>
<body>
  <div class="container">
    <div class="header">
      <p>KoolChart – Circular Gauge</p>
    </div>
    <div class="content">
      <div 
id="chartHolder" style="width:600px; height:400px;">
      </div>
    </div>
  </div>
</body>
</html>


Step 1. Prepare an html document to which you want to add a gauge. By using the above html document, we are going to add a circular gauge into the id="chartHolder" div.

Step 2Include KoolChart.js inside the <head> element of your html document. KoolChart.js is a JavaScript library which is the charting engine for KoolChart.

<script language="javascript" type="text/javascript" src="KoolChart.js"></script>

Step 3. Add Javascript statements calling KoolChart-provided Javascript functions inside the <script> element of your HTML document.

var chartVars = "KoolOnLoadCallFunction=chartReadyHandler";

KoolChart.create("chart1", "chartHolder", chartVars, "100%", "100%"); 

function chartReadyHandler(id) {
  document.getElementById(id).setLayout(layoutStr);
  document.getElementById(id).setData(chartData);
}

The KoolChart.create() function takes 5 arguments which are chart id("chart1"), DIV id("chartHolder"), a variable name("chartVars") and the size of the chart(width and height). "chart id" is the DIV id of the chart and the DIV is created and used internally by the KoolChart engine. The second argument is the DIV id into which the gauge is created and the third argument is the variable name which has the values used by the KoolChart engine. In the above sample, only the function name of the chart ready handler is assigned to the variable. And the last two arguments are for the chart’s size, width and height. 100% means that the same size of the chart defined in the id=”chartHolder” div (style="width:800px; height:400px;") is created.


Step 4Set the layout variable.

var layoutStr 

  '<KoolChart frameColor="0xEEEEEE" cornerRadius="12" borderStyle="solid">'
    +'<Options>'
      +'<Caption text="Circular Gauge - Orange"/>'
      +'<SubCaption text="The gauge, color and gradient can be changed." textAlign="right" paddingRight="10" fontSize="12"/>'
    +'</Options>'
    +'<NumberFormatter id="numFmt" precision="0"/>' 
    +'<CircularGauge width="300" height="300" startAngle="0" minimumAngle="20" maximumAngle="340" minimum="0" maximum="500" value="200" interval="50" minorInterval="10" formatter="{numFmt}" tickLabelStyleName="tickText" valueLabelStyleName="valueText" dataTipJsFunction="dataTipFunction" editMode="true" liveDragging="true" tickGap="50" labelGap="20" showDataTip="false" tickLabelPlacement="outside" tickColor="0x1B699A" enableFilter="false" needleCoverRadius="30" needleThickness="40" pointThickness="10" needleLengthRatio="0.6" needlePointStyle="rounding" isValueTop="true" animationDuration="1000" bounceAnimating="true">'
      +'<frameStroke>'
        +'<Stroke color="0xFF699A" weight="4"/>'
      +'</frameStroke>'
      +'<frameFill>'
        +'<SolidColor color="0xdf8c2b"/>'
      +'</frameFill>'
      +'<needleFill>'
        +'<LinearGradient angle="90">'
          +'<entries>'
            +'<GradientEntry color="0xFFFFFF" ratio="0" alpha="1"/>'
            +'<GradientEntry color="0xdf8c2b" ratio="0.8" alpha="1"/>'
            +'<GradientEntry color="0xFF6600" ratio="1" alpha="1"/>'
          +'</entries>'
        +'</LinearGradient>'
      +'</needleFill>'
      +'<needleCoverFill>'
        +'<SolidColor color="0xFF8800"/>'
      +'</needleCoverFill>'
    +'</CircularGauge>'
    +'<Style>'
      +'.valueText{'
        +'fontSize:18;'
        +'fontFamily:Myriad;'
        +'textAlign:center;'
        +'borderColor:#000000;'
        +'backgroundColor:#FFFFFF;'
        +'backgroundAlpha:0;'
        +'paddingTop:0;'
        +'borderThickness:0;'
        +'borderAlpha:0;'
        +'borderStyle:solid;'
      +'}'
      +'.tickText{'
        +'fontFamily:Myriad;'
        +'fontSize:15;'
      +'}'
    +'</Style>'
  +'</KoolChart>';
 

The above layout can be broken down into four parts, <options>, <formatter> ( NumberFormatter), < CircularGauge> and < Style>.
1. <Options> : To add a caption or a legend to the chart, you need to define <Caption> or <Legend> into <Options>
2. <formatter> : In this sample, one number formatter has been defined. NumberFormatter, DateFormatter, CurrencyFormatter can be used in KoolChart.
3. <CircularGauge> : The definition of the Circular gauge starts with  <CircularGauge>  and ends with </CircularGauge>.
4. <Style> : <Style> specifies the CSS style sheet to use to format the output of the gauge. In the above example, two style names have been defined. The valueText style is used to format the output of the gauge value and the tickText style is used to format the tick label of the gauge.

The Circular gauge has a range of 0 to 360 degrees. The default starting angle, 0 degrees, is toward 3 o'clock (or east), and positive angle measurement is clockwise. The Circular gauge is composed of three parts: a background frame, a needle, and a needle cover. You can make various shapes by using the properties of the three parts.


Step 5Set the data variable.

var chartData = [200];

The complete HTML is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="Content-Script-Type" content="text/javascript"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>KoolChart for HTML5 - Circular Gauge</title>

<script language="javascript" type="text/javascript" src="KoolChart.js"></script>

<script type="text/javascript">

var chartVars = "KoolOnLoadCallFunction=chartReadyHandler";

KoolChart.create("chart1", "chartHolder", chartVars, "100%", "100%"); 

function chartReadyHandler(id) {
  document.getElementById(id).setLayout(layoutStr);
  document.getElementById(id).setData(chartData);
}

var layoutStr 
  '<KoolChart frameColor="0xEEEEEE" cornerRadius="12" borderStyle="solid">'
    +'<Options>'
      +'<Caption text="Circular Gauge - Orange"/>'
      +'<SubCaption text="The gauge, color and gradient can be changed." textAlign="right" paddingRight="10" fontSize="12"/>'
    +'</Options>'
    +'<NumberFormatter id="numFmt" precision="0"/>'
    +'<CircularGauge width="300" height="300" startAngle="0" minimumAngle="20" maximumAngle="340" minimum="0" maximum="500" value="200" interval="50" minorInterval="10" formatter="{numFmt}" tickLabelStyleName="tickText" valueLabelStyleName="valueText" dataTipJsFunction="dataTipFunction" editMode="true" liveDragging="true" tickGap="50" labelGap="20" showDataTip="false" tickLabelPlacement="outside" tickColor="0x1B699A" enableFilter="false" needleCoverRadius="30" needleThickness="40" pointThickness="10" needleLengthRatio="0.6" needlePointStyle="rounding" isValueTop="true" animationDuration="1000" bounceAnimating="true">'
      +'<frameStroke>'
        +'<Stroke color="0xFF699A" weight="4"/>'
      +'</frameStroke>'
      +'<frameFill>'
        +'<SolidColor color="0xdf8c2b"/>'
      +'</frameFill>'
      +'<needleFill>'
        +'<LinearGradient angle="90">'
          +'<entries>'
            +'<GradientEntry color="0xFFFFFF" ratio="0" alpha="1"/>'
            +'<GradientEntry color="0xdf8c2b" ratio="0.8" alpha="1"/>'
            +'<GradientEntry color="0xFF6600" ratio="1" alpha="1"/>'
          +'</entries>'
        +'</LinearGradient>'
      +'</needleFill>'
      +'<needleCoverFill>'
        +'<SolidColor color="0xFF8800"/>'
      +'</needleCoverFill>'
    +'</CircularGauge>'
    +'<Style>'
      +'.valueText{'
        +'fontSize:18;'
        +'fontFamily:Myriad;'
        +'textAlign:center;'
        +'borderColor:#000000;'
        +'backgroundColor:#FFFFFF;'
        +'backgroundAlpha:0;'
        +'paddingTop:0;'
        +'borderThickness:0;'
        +'borderAlpha:0;'
        +'borderStyle:solid;'
      +'}'
      +'.tickText{'
        +'fontFamily:Myriad;'
        +'fontSize:15;'
      +'}'
    +'</Style>'
  +'</KoolChart>';
</head>

var chartData = [200];

</script>
</head>

<body>
  <div class="container">
    <div class="header">
      <p>KoolChart – Circular Gauge</p>
    </div>
    <div class="content">
      <div 
id="chartHolder" style="width:600px; height:400px;">
      </div>
    </div>
  </div>
</body>
</html>

2013년 2월 26일 화요일

Kool HTML5 Chart supported smartphones and pads


Kool HTML5 Chart supported smartphones and pads

 - iPhone 3gs, 4, 4s, 5
 - Galaxy S, S2, S3
 - HTC
 - Blackberry
 - Galaxy Tab, Note
 - Nexus7, 10
 - iPad mini, 2, 3, 4


You can make mobile chart, smartphone chart what you want everything.
Here is demo chart. also, you can get trial version.
Try now!
http://koolchart.com

2013년 2월 6일 수요일

The Best Super Bowl commercials of 2013 HTML5 Chart - KoolChart


The Best Super Bowl commercials of 2013 HTML5 Chart
Super Bowl is the day of the year when our TVs are filled with stars, comedians and cute kids. It is best way for commercial.
Koolchart makes chart what you want.
The best way to charting your data.
Here is demo chart. also, you can get trial version Koolchart.
Try now!