KavaChart in Action - Examples and Documentation - ProServe

[ Back ] Basic Charts - Line Charts

Line charts are one of the most basic and versatile chart types. They can be used to display trends over time, to correlate one variable with another, or to find clusters of information. KavaChart's line chart collection includes charts that handle discontinuities, charts that have time axes, user-labeled axes, or numeric axes.

The KavaChart ProServe collection includes these line chart types:

  • lineApp
  • disLineApp
  • regressApp (scatter plots)
  • labelLineApp

Use the source code to this page as a guide in creating your own line charts. You can also use the KavaChart ChartWizard
 

This chart describes oil contract prices over time. In production, this chart's data parameters would likely be created by a database connection, but we're just putting the strings in directly. This means that in production the chart, like the rest of the data in your page will be completely dynamic.

Placing your mouse over a region in the chart will show what the actual prices are on a particular contract day. The format of the numbers is defined using dwell properties.

A reference line at "12.5" describes our contract purchase price so we can tell at a glance whether this contract is making money or not.

Contract Day: 0
Price USD: $17.10 Contract Day: 1
Price USD: $17.00 Contract Day: 2
Price USD: $18.70 Contract Day: 3
Price USD: $18.39 Contract Day: 4
Price USD: $17.39 Contract Day: 5
Price USD: $15.90 Contract Day: 6
Price USD: $16.10 Contract Day: 7
Price USD: $16.80 Contract Day: 8
Price USD: $16.10 Contract Day: 9
Price USD: $16.89 Contract Day: 10
Price USD: $18.00 Contract Day: 11
Price USD: $17.89 Contract Day: 12
Price USD: $18.00 Contract Day: 13
Price USD: $20.00 Contract Day: 14
Price USD: $21.00 Contract Day: 15
Price USD: $19.10 Contract Day: 16
Price USD: $18.30 Contract Day: 17
Price USD: $19.60 Contract Day: 18
Price USD: $20.60 Contract Day: 19
Price USD: $22.60 Contract Day: 20
Price USD: $24.20 Contract Day: 21
Price USD: $22.60 Contract Day: 22
Price USD: $23.90 Contract Day: 23
Price USD: $23.47 Contract Day: 24
Price USD: $20.83 Contract Day: 25
Price USD: $19.21 Contract Day: 26
Price USD: $17.47 Contract Day: 27
Price USD: $19.14 Contract Day: 28
Price USD: $17.55 Contract Day: 29
Price USD: $18.39 Contract Day: 30
Price USD: $18.71 Contract Day: 31
Price USD: $18.45 Contract Day: 32
Price USD: $19.85 Contract Day: 33
Price USD: $19.00 Contract Day: 34
Price USD: $17.00 Contract Day: 35
Price USD: $15.09 Contract Day: 36
Price USD: $14.06 Contract Day: 37
Price USD: $13.08 Contract Day: 38
Price USD: $13.41 Contract Day: 39
Price USD: $14.39 Contract Day: 40
Price USD: $12.06 Contract Day: 41
Price USD: $12.01 Contract Day: 42
Price USD: $11.88 Contract Day: 43
Price USD: $13.36 Contract Day: 44
Price USD: $12.56 Contract Day: 45
Price USD: $10.92 Contract Day: 46
Price USD: $9.80 Contract Day: 47
Price USD: $11.06 Contract Day: 48
Price USD: $10.19 Contract Day: 49
Price USD: $12.47 Contract Day: 50
Price USD: $15.30 Contract Day: 51
Price USD: $15.14
 

Using exactly the same parameters, but with "regressApp" instead of "lineApp", we get a scatter plot and regression analysis of our data.

Either of these applets can be used to create scatter plots by adding the param "plotLinesOff", while leaving line markers visible. You can also select different markers, or even choose an image ("dataset0Image") to use as a marker on the plot line. Markers and lines both appear on the chart's legend.

LineApp and regressApp both use numeric X and Y axes, which work well with many or few points. Numeric axes can also be scaled logarithmically (yAxisOptions|xAxisOptions=logAxis) for data that covers extremely large ranges.

Note that we also enabled antialiasing to make a very smooth regression line. A line like this would appear quite jagged without antialiasing.

Contract Day: 0
Price USD: $17.10 Contract Day: 1
Price USD: $17.00 Contract Day: 2
Price USD: $18.70 Contract Day: 3
Price USD: $18.39 Contract Day: 4
Price USD: $17.39 Contract Day: 5
Price USD: $15.90 Contract Day: 6
Price USD: $16.10 Contract Day: 7
Price USD: $16.80 Contract Day: 8
Price USD: $16.10 Contract Day: 9
Price USD: $16.89 Contract Day: 10
Price USD: $18.00 Contract Day: 11
Price USD: $17.89 Contract Day: 12
Price USD: $18.00 Contract Day: 13
Price USD: $20.00 Contract Day: 14
Price USD: $21.00 Contract Day: 15
Price USD: $19.10 Contract Day: 16
Price USD: $18.30 Contract Day: 17
Price USD: $19.60 Contract Day: 18
Price USD: $20.60 Contract Day: 19
Price USD: $22.60 Contract Day: 20
Price USD: $24.20 Contract Day: 21
Price USD: $22.60 Contract Day: 22
Price USD: $23.90 Contract Day: 23
Price USD: $23.47 Contract Day: 24
Price USD: $20.83 Contract Day: 25
Price USD: $19.21 Contract Day: 26
Price USD: $17.47 Contract Day: 27
Price USD: $19.14 Contract Day: 28
Price USD: $17.55 Contract Day: 29
Price USD: $18.39 Contract Day: 30
Price USD: $18.71 Contract Day: 31
Price USD: $18.45 Contract Day: 32
Price USD: $19.85 Contract Day: 33
Price USD: $19.00 Contract Day: 34
Price USD: $17.00 Contract Day: 35
Price USD: $15.09 Contract Day: 36
Price USD: $14.06 Contract Day: 37
Price USD: $13.08 Contract Day: 38
Price USD: $13.41 Contract Day: 39
Price USD: $14.39 Contract Day: 40
Price USD: $12.06 Contract Day: 41
Price USD: $12.01 Contract Day: 42
Price USD: $11.88 Contract Day: 43
Price USD: $13.36 Contract Day: 44
Price USD: $12.56 Contract Day: 45
Price USD: $10.92 Contract Day: 46
Price USD: $9.80 Contract Day: 47
Price USD: $11.06 Contract Day: 48
Price USD: $10.19 Contract Day: 49
Price USD: $12.47 Contract Day: 50
Price USD: $15.30 Contract Day: 51
Price USD: $15.14
 

Line charts can also include disontinuities, or breaks in the lines. Discontinuities provide a visual cue that a trend is interrupted by some significant event.

This sample is essentially the same as our first example, except that we've added some discontinuities in the data by using "x" instead of a number in the list of values for "dataset0yValues". We also changed some colors, and re-arranged the axes and legend.

We also changed the Y axis scaling to logarithmic. For scientific and financial data, it's sometimes important to see whether the data increases in an exponential fashion, which appears as a more or less straight line with logarithmic scaling.

Line chart variants that understand discontinuity handling include "disLineApp", "disLabelLineApp".

Pétrole brut Brent
Contract Day: 0
Price USD: $17.10 Pétrole brut Brent
Contract Day: 1
Price USD: $17.00 Pétrole brut Brent
Contract Day: 2
Price USD: $18.70 Pétrole brut Brent
Contract Day: 3
Price USD: $18.39 Pétrole brut Brent
Contract Day: 4
Price USD: $17.39 Pétrole brut Brent
Contract Day: 5
Price USD: $15.90 Pétrole brut Brent
Contract Day: 7
Price USD: $16.80 Pétrole brut Brent
Contract Day: 8
Price USD: $16.10 Pétrole brut Brent
Contract Day: 9
Price USD: $16.89 Pétrole brut Brent
Contract Day: 10
Price USD: $18.00 Pétrole brut Brent
Contract Day: 12
Price USD: $18.00 Pétrole brut Brent
Contract Day: 13
Price USD: $20.00 Pétrole brut Brent
Contract Day: 14
Price USD: $21.00 Pétrole brut Brent
Contract Day: 15
Price USD: $19.10 Pétrole brut Brent
Contract Day: 16
Price USD: $18.30 Pétrole brut Brent
Contract Day: 17
Price USD: $19.60 Pétrole brut Brent
Contract Day: 18
Price USD: $20.60 Pétrole brut Brent
Contract Day: 19
Price USD: $22.60 Pétrole brut Brent
Contract Day: 20
Price USD: $24.20 Pétrole brut Brent
Contract Day: 21
Price USD: $22.60 Pétrole brut Brent
Contract Day: 22
Price USD: $23.90 Pétrole brut Brent
Contract Day: 23
Price USD: $23.47 Pétrole brut Brent
Contract Day: 25
Price USD: $19.21 Pétrole brut Brent
Contract Day: 26
Price USD: $17.47 Pétrole brut Brent
Contract Day: 27
Price USD: $19.14 Pétrole brut Brent
Contract Day: 28
Price USD: $17.55 Pétrole brut Brent
Contract Day: 29
Price USD: $18.39 Pétrole brut Brent
Contract Day: 30
Price USD: $18.71 Pétrole brut Brent
Contract Day: 31
Price USD: $18.45 Pétrole brut Brent
Contract Day: 32
Price USD: $19.85 Pétrole brut Brent
Contract Day: 33
Price USD: $19.00 Pétrole brut Brent
Contract Day: 34
Price USD: $17.00 Pétrole brut Brent
Contract Day: 35
Price USD: $15.09 Pétrole brut Brent
Contract Day: 36
Price USD: $14.06 Pétrole brut Brent
Contract Day: 37
Price USD: $13.08 Pétrole brut Brent
Contract Day: 38
Price USD: $13.41 Pétrole brut Brent
Contract Day: 39
Price USD: $14.39 Pétrole brut Brent
Contract Day: 40
Price USD: $12.06 Pétrole brut Brent
Contract Day: 41
Price USD: $12.01 Pétrole brut Brent
Contract Day: 43
Price USD: $13.36 Pétrole brut Brent
Contract Day: 44
Price USD: $12.56 Pétrole brut Brent
Contract Day: 45
Price USD: $10.92 Pétrole brut Brent
Contract Day: 46
Price USD: $9.80 Pétrole brut Brent
Contract Day: 47
Price USD: $11.06 Pétrole brut Brent
Contract Day: 48
Price USD: $10.19 Pétrole brut Brent
Contract Day: 49
Price USD: $12.47 Pétrole brut Brent
Contract Day: 50
Price USD: $15.30 Pétrole brut Brent
Contract Day: 51
Price USD: $15.14
 

Another line chart variant is "labelLineApp". This chart takes textual label definitions for the X axis. If you don't define "xAxisLabels", they're derived from the first dataset's labels. If those don't exist, the first dataset's values are used for labels.

This chart is particularly useful for trends that don't have a strictly numeric or time oriented X axis. You can define the axis start and end values, and by setting the "xAxisOptions" to include "noAutoScale", you can define the number of labels, ticks, and grids. Since this approach gives you complete labelling and scaling control over the X axis, this chart is sometimes easier to use than "dateLineApp" (part of the timeseries collection) for creating time oriented charts, as well. This is especially true when your date/time values include missing data, like weekends and evenings.

Notice the Y axis on this chart. It uses percentage labels, in a format appropriate for your locale. Any line chart can use percentage or currency labels by adding the appropriate options to "yAxisOptions" or "xAxisOptions".

Percentage of Capacity: 0.493 Percentage of Capacity: 0.076 Percentage of Capacity: 0.654 Percentage of Capacity: 0.979 Percentage of Capacity: 0.77 Percentage of Capacity: 1 Percentage of Capacity: 0.831 Percentage of Capacity: 0.414 Percentage of Capacity: 0.064 Percentage of Capacity: 0.662 Percentage of Capacity: 0.422 Percentage of Capacity: 0.199 Percentage of Capacity: 0.109 Percentage of Capacity: 0.637 Percentage of Capacity: 0.452 Percentage of Capacity: 0.824