Migration Guide to Davisor Chart 4

Content

Introduction

This document serves as a guide when upgrading earlier versions of Davisor Chart to Davisor Chart 4. To learn more about the new features, we recommend that you see also the new Users' Guide and XML Reference.

There are significant architectural changes made for Davisor Chart 4, especially in data import. At the same time, the deprecated attributes were removed to keep the architecture clean. This means that Davisor Chart 4 is not backwards compatible. However, with the instructions in this document you should be able to do the migration easily.

The purpose of the changes was that the usage of Davisor Chart would be easier and more intuitive. Especially we have retought how to connect to data sources, because the integration into data sources is often the most time consuming part. We hope that the new data source interface will save an important amount of time for you.

New Features of Davisor Chart 4

Changes in Chart XML

One of the biggest changes in XML attributes is that rendering element is renamed to series element. In addition to the renaming, the series element is placed under plot element and not directly under attributes. Moreover rendering attributes can't be given in data section anymore. All channel specific rendering information is given with <series> tag. In practice, this means that no color, font, paint, shape, or stroke attributes exist in <column> and <group> tags anymore. Also 'cumulative' and 'hidden' attributes have been moved to <series> tag. (In the case of the rendering (or now series) attributes of a grouped column need to be set, use nested series tags with the same ids as the group and the column have got. The need for that feature is very rare.) See the example below.

Old. Chart 3.xNew! Chart 4
<chart> <data> <column id="series1" type="value" name="Orders" color="blue" pointPaint="red" pointShape="circle" pointStroke="solid" lineStroke="2-dash-5:5" values="14 27 18 32 71" /> </data> <attributes chartType="line"> <image height="100" width="143"/> </attributes> </chart> <chart> <data> <column id="series1" type="value" name="Orders" values="14 27 18 32 71" /> </data> <attributes chartType="line"> <image height="100" width="143"/> <plot> <series idRef="series1" color="blue" pointPaint="red" pointShape="circle" pointStroke="solid" lineStroke="2-dash-5:5" /> </plot> </attributes> </chart>
<chart> <data> <column id="series1" type="value" hidden="true" values="14 20 18" /> <column id="series2" type="value" cumulative="true" values="6 4 5" /> </data> <attributes chartType="column"> <image height="100" width="143"/> </attributes> </chart> <chart> <data> <column id="series1" type="value" values="14 20 18" /> <column id="series2" type="value" values="6 4 5" /> </data> <attributes chartType="column"> <image height="100" width="143"/> <plot> <series idRef="series1" hidden="true" /> <series idRef="series2" cumulative="true" /> </plot> </attributes> </chart>

Also the following tag attributes have been removed or replaced (some of them may have been marked deprecated for a while):

Old. Chart 3.xNew! Chart 4
<attributes altFormat="{.label}" /> and <plot altFormat="{.label}" /> <plot> <annotation > <text>{.label}</text> </annotation > </plot>
<attributes antialias="on" /> and <attributes antialiasMode="on" /> and <image antialias="on" /> <image antialiasMode="on" />
<attributes urlFormat="foo" /> and <plot urlFormat="foo" /> <plot> <annotation href="foo"/> </plot>
<attributes valueFormat="{.value}" /> <plot valueFormat="{.value}" />
<axes axisPaint="red" /> <axes backPaint="red" />
<axes chartType="column" /> <axes subChartType="column" />
<axes format="yyyy-MM-dd" /> <axes labelFormat="yyyy-MM-dd" />
<axes id="x" /> Removed.
<axis axisPaint="red" /> <axis backPaint="red" />
<axis format="yyyy-MM-dd" /> <axis labelFormat="yyyy-MM-dd" />
<axis id="x" /> Removed.
<column altFormat="{.label}" /> and <group altFormat="{.label}" /> and <rendering altFormat="{.label}" /> <plot> <series> <annotation > <text>{.label}</text> </annotation > </series> <plot>
<column urlFormat="foo" /> and <group urlFormat="foo" /> and <rendering urlFormat="foo" /> <plot> <series> <annotation href="foo"/> </series> </plot>
<directional color="red" /> <directional lightColor="red" />
<image mimeType="image/png" /> <image encoderType="image/png" />
<legend alignment="left" /> <legend legendAlignment="left" />
<series id="sales" paint="red" /> <series idRef="sales" paint="red" />

Angles

Y-axis rotation direction for Real3D charts has been reversed. It is now the same as for isometric charts (see Axes in Users' Guide).

Point and Line Attributes

Data point visualizations (i.e. bars, columns, pie slices, points in scatter plot, shapes in line charts, stock chart symbols, etc.) are all now controlled by pointColor, pointPaint, pointShape, and pointStroke. In previous versions bars, columns, and pie slices took their rendering parameters from lineColor, linePaint, and lineStroke. The principle behind this change is that "point-something" defines how one data point will be visualized, when "line-something" defines the appearance of the lines adjancing data points. Those adjancing lines exist currently only in line and scatter charts and in their variations (like area chart).

In "bar", "column", and "pie" charts, change "line-paramters" to "point-parameters" as follows:
Old. Chart 3.xNew! Chart 4
lineColor pointColor
linePaint pointPaint
lineStroke pointStroke
Other chart types have already been consistent with the principle described above.

Default Paints and Colors

The default color has earlier been always black and the default fill paint for data point visualizations has been null. In Chart 4 the default colors and fill paints are chart type specific. Typically the default outline color is still black, but in most cases the fill paint is a color palette named "default". In practice, this means that you do not need to give paint for bar, column, or pie chart to get suitable results. The changes in defaults are listed in the table below.

Chart TypeAttributeOld Default.
Chart 3.x
New Default.
Chart 4
bar, column, pie, line, scatter pointPaint null default
line, scatter pointColor black default
line, scatter lineColor black single series mode: black
multi series mode: default
area (new chart type) linePaint default
area (new chart type) lineColor black

To let some area remain unfilled, use paint "null", "transparent", or some fully transparent paint like "white-0%".

Annotations

There is a new <annotation> tag to give hyperlink annotations and description texts. That possiblity has been since version 3.6, but now the old urlFromat and altFormat attributes are not available anymore. The <annotation> tag can be nested inside <plot> or <series> tags. The wanted URL is given by href attribute and description can be given using a nested <text> tag. All other attributes wanted to be appearing in the result can be given using nested <attr> tag. Macros, like "{.value}" or "{series1}", can be used in all annotation attributes.

The way annotation attributes are given in paints is also changed. Now the syntax is:

  paint: paint_definition "?" annotation
  paint_definition: as earlier, see e.g. Users' Guide
  annotation: annotation_attribute [ "&" annotation_attribute*]
  annotation_attribute: name "=" URL_encoded_value
  name: a valid XML attribute name, href and alt have well known meaning.
  URL_encoded_value: URL encoded value for the attribute. Will be decoded.
Example: "red?href=index.html&alt=Home+Page&onMouseOver=javascript:myfunc1()". Here, "red" is the used paint. Annotation consists of three attributes "href"m "alt", and "onMouseOver", which have their values URL encoded. When creating HTML imagemap, this will produce the following <area> tag:
<area coords="..." href="index.html" alt="Home Page" onMouseOver="javascript:myfunc1()" />

The defaulting mechanism for annotations has been made uniform for all chart types. Now the order is the following:

  1. annotation given in <series> tag
  2. "url" and "alt" data channels
  3. annotation given in <plot> tag
  4. paint annotation

Changes in custom JSP tag library

The biggest change in JSP tag library is that the different data source tags are moved to XML tags and the <chart:data> tag is replaced with a new <chart:def> tag.

Data source tags

The table below shows how to replace the old JSP-tag based data definitions. The common architecture is that the data source is defined with a data source type specific tag and the selected columns are defined with data source type specific column tags. Even if these tags are data source specific, they share the same attributes, like source, column, and type.

Data SourceOld. Chart 3.xNew! Chart 4
XML <chart:data> <chart:xml> <chart> <data> <column id="series1" type="value" values="25 27 60 50" /> <column type="label"> <e>label 1</e> <e>label 2</e> <e>label 3</e> <e>label 4</e> </column> </data> <attributes > <rendering id="series1" paint="red" /> </attributes> </chart> </chart:xml> </chart:data> <chart:def> <chart> <data> <column id="series1" type="value" values="25 27 60 50" /> <column type="label"> <e>label 1</e> <e>label 2</e> <e>label 3</e> <e>label 4</e> </column> </data> <attributes > <plot> <series idRef="series1" paint="red" /> <plot> </attributes> </chart> </chart:def>
CSV <chart:csv url="chartdata.csv"> <chart> <data> <column id="column0" type="label" dataType="text"/> <column id="column1" type="value" dataType="float"/> </data> </chart> </chart:csv> <chart:xml> <chart> <attributes > <rendering id="column1" paint="red" /> </attributes> </chart> </chart:xml> <chart:def> <chart> <data> <csv source="chartdata.csv"> <csvColumn column="1" type="label" dataType="text"/> <csvColumn id="s1" column="2" type="value" dataType="float"/> </csv> </data> <attributes > <plot > <series idRef="s1" paint="red" /> </plot > </attributes> </chart> </chart:def>
SQL <chart:sql query="SELECT c1,name FROM table2"> <chart> <data> <column id="c1" type="value"/> <column id="name" type="label"/> </data> </chart> </chart:sql> <chart:xml> <chart> <attributes > <rendering id="c1" paint="red" /> </attributes> </chart> </chart:xml> <chart:def> <chart> <data> <sql source="jdbc/chart" query="SELECT c1,name FROM table2" > <sqlColumn column="c1" type="value"/> <sqlColumn column="name" type="label"/> </sql> </data> <attributes > <plot> <series idRef="c1" paint="red" /> </plot> </attributes> </chart> </chart:def>
List <% java.util.List list = new java.util.ArrayList(); list.add(new Integer(20)); list.add(new Integer(21)); %> <chart:list id="myList" type="value" values="<%=list%>"/> <% java.util.List list = new java.util.ArrayList(); list.add(new Integer(20)); list.add(new Integer(21)); pageContext.setAttribute("myList", list); %> <chart:def> <chart> <data> <collection source="myList"> <collectionColumn name="summer"/> </collection> </data> </chart> </chart:def>
Bean <jsp:useBean id="dataBean" scope="request" class="test.ExampleDataBean" /%> <chart:list id="myList" type="value" beanName="dataBean" propertyName="values"/> <jsp:useBean id="dataBean" scope="request" class="test.ExampleDataBean" /%> <chart:def> <chart> <data> <bean source="dataBean"> <beanColumn column="values" type="value" /> </bean> </data> </chart> </chart:def>
XPath Not possible. <chart:def> <chart> <data> <xpath source="employees.xml" select="//employees/employee"> <xpathColumn column="name" type="label" /> <xpathColumn column="salary" type="value" /> </xpath> </data> </chart> </chart:def>

Data Source Attributes

When the JSP data source tags are changed to XML elements also some of the attribute names has changed. This is made to keep the attribute names uniform, and in some cases to clarify the meaning of the attribute.

Old. Chart 3.xNew! Chart 4
<chart:csv headerLines="n" /> <csv firstDataRow="n+1" />
<chart:csv dataNameLine="n" /> <csv dataNameRow="n" />

Data Processing

In Davisor Chart 3.x there have been a possibility to do some data processing with list and table data sources. Now these are possible for all data sources. However, currently only the most common functions are implemented.

FunctionOld. Chart 3.xNew! Chart 4
Pivot Not really possible. <chart:def> <chart> <data> <pivot> <csv source="soldItems.csv" /> </pivot> </data> </chart> </chart:def>
Sort <chart:list id="sorted" formula="sort(s1[min]:s1[max])" > <chart:def> <chart> <data> <sort> <sortColumns/> any data source here </sort> </data> </chart> </chart:def>
Moving Average <chart:data> <chart:xml id="s1" url="rate.xml"/> <!-- Import from file --> <chart:list id="level" formula="sma(s1[min]:s1[max].level;10)="/> </chart:data> <chart:def> <chart> <data> <movingAverage period="10" avgType="simple" > <movAvgColumn column="input" id="level" name="SMA" type="value"/> <xml source="rate.xml" /> </movingAverage> </data> </chart> </chart:def>

Output - Images and Tables

<chart:image> and <chart:table> tags are replaced with <chart:out> tag which is able to produce:

Attribute changes between old <chart:image> and new <chart:out>:
Old. Chart 3.xNew! Chart 4
dataId def
servletUrl servlet
chartWidth width
chartHeight height
attributesId
imageType contentType
imageParams Removed.
output file
srcOnly

HTML attributes, like onMouseOver, which were available in <chart:image> tag are removed. They can be defined now with <attr> tags nested inside the <chart:out> tag. See example below.

Old. Chart 3.xNew! Chart 4
<chart:image dataId="xxx" onMouseOver="..." /> <chart:out def="xxx" > <attr name="onMouseOver" value="..." /> </chart:out>

Caching

Earlier <chart:data> tag defined the caching policy. Now there is a special <chart:cache> tag for that. If caching is wanted, <chart:def> tag is placed inside <chart:cache> tag.

Old. Chart 3.xNew! Chart 4
<chart:data expires=" ? " /> <chart:cache timeout=" ? "> <chart:def ...> </chart:def> </chart:cache>
<chart:data scope="application" /> <chart:cache shared="true"> <chart:def ...> </chart:def> </chart:cache>
<chart:data scope="session" /> <chart:cache shared="false"> <chart:def ...> </chart:def> </chart:cache>

Changes in Java API

There are numerous changes in Davisor Chart Java API. For example, lots of deprecated constructors and methods have been removed. For example, methods getAddress(), getDescription(), and getTarget() of com.davisor.core.Annotated were deprecated for Chart 3.6. Now they are removed, and the getProperty(String) method need to be used instead with arguments "href", "alt", or "target" respectively.

One of the main changes is that com.davisor.graphics.chart.Chart has been changed from class to interface and most of its methods have been removed or changed. This affects for example to servlet coding:
Old. Chart 3.xNew! Chart 4
Chart chart = XMLDocHandler.createChart(); response.setContentType( chart.getAttributes().getEncoderType() ); chart.putImage( response.getOutputStream() ); Chart chart = XMLDocHandler.createChart(); response.setContentType( chart.getContentType() ); chart.putContent( response.getOutputStream() );