0.4.2 • Published 8 years ago

tayberry v0.4.2

Weekly downloads
2
License
LGPL-3.0
Repository
github
Last release
8 years ago

TayberryJS 0.4.2

© Reupen Shah 2015 – 2016

Build Status npm version devDependencies

TayberryJS is an HTML5 canvas-based JavaScript charting library. Currently featuring bar and line charts, with more features coming soon.

Demos

Click here for some demos and examples.

What's good about it?

Built on HTML5 canvas

That means a couple of DOM elements, not the 10s or even 100s you would face with SVG.

Self-contained

Zero external dependencies. No jQuery, no D3.

Easy-to-use and customisable

Creating a chart is as simple as:

<div id="chart-id" style="width: 600px; height: 350px"></div>
Tayberry.create('chart-id', {
    xAxis: [{
        categories: ['1', '2', '3', '4', '5+']
    }],
    series: [{
        data: [.306, .341, .156, .129, .069],
        name: '2011'
    }]
});

Supported browsers

TayberryJS only supports modern browsers. As of 0.2.2, it has been tested on:

  • Firefox 30+
  • Chrome for Windows 45+
  • Chrome for Android 45+
  • Internet Explorer 10+
  • Edge
  • Safari for OS X 7.1.6+

Usage

Create a container div in your page, with a set width and height, and load tayberry.min.js. Call Tayberry.create just like the example above. That's with the id of your div as the first argument, and an object specifying chart options as the second.

Available attributes on the option object are (full details still to be completed):

FieldAllowed valuesDescription
allAxes.font.*-Overrides font.* values for axis labels
allAxes.title.font.*-Overrides font.* values for axis titles
animations.enabledbooleanEnable animations
backgroundColourHTML colour code
barPlot.modenormal|stacked|overlaid
barPlot.barPaddinglogical pixelsPadding between bars in the same category
barPlot.categorySpacingpercentage in [0, 1)Spacing between categories
elementLargePaddinglogical pixels
elementSmallPaddinglogical pixels
font.colourHTML colour codeFont colour
font.facestringFont name
font.sizelogical pixelsFont size
font.stylestringbold, italic etc.
font.autoScalebooleanAuto-scale font with chart width
labels.enabledbooleanShow data labels in the plot area
labels.font.*-Overrides font.* values for data labels
labels.verticalAlignmenttop|middle|bottomWhere in each bar labels should appear
labels.verticalPositionoutside|inside|middle
legend.enabledboolean
legend.font.*-Overrides font.* values for the legend
legend.indicatorSizelogical pixelsWidth/height of the coloured box of each legend item
legend.placementleft|top|right|bottomLegend placement/position
linePlot.lineWidthlogical pixels
linePlot.highlightedLineWidthlogical pixels
linePlot.showMarkerstrue, false, auto
linePlot.noMarkersThresholdnumber
linePlot.markerSizelogical pixels
linePlot.highlightedMarkerSizelogical pixels
plotTypestringDefault plot type for series; currently can be line or bar
presetsarray of stringsUse this to override some of the default settings using a preset. Currently two presets: histogram and darkGrid
seriesn.colourHTML colour code
seriesn.dataarray
seriesn.markerTypesquare | diamond | triangle | triangle-down | circle
seriesn.namestring
seriesn.plotTypestringPlot type for this series; currently can be line or bar
seriesn.xAxisIndexnumber
seriesn.yAxisIndexnumber
swapAxesbooleanSwap the displayed positions of the x- and y-axes; set to true for a horizontal bar chart
title.font.*-Overrides font.* values for the chart title
title.textstringTitle for the chart
tooltips.font.*-Overrides font.* values for tooltips
tooltips.footerTemplatestringHTML template string used for tooltip footer.
tooltips.headerTemplatestringHTML template string used for tooltip header. Use {category} to sub in the category name
tooltips.sharedbooleanSet to true to share tooltips between all series
tooltips.valueTemplatestringHTML template string used for each series in a tooltip. Fields available: {name}, {value} and {colour}
xAxis|yAxis.categoriesarray(categorial/categorical axes only)
xAxis|yAxis.currencySymbolstring(linear axes only)
xAxis|yAxis.font.*-Overrides allAxes.font.* values for the axis labels
xAxis|yAxis.labelPositionleft|middle|right
xAxis|yAxis.gridLines.colourHTML colour code
xAxis|yAxis.labelFormatnumber|percentage|currency(linear axes only)
xAxis|yAxis.labelFormatterfunction
xAxis|yAxis.labelPrefixstring(linear axes only)
xAxis|yAxis.labelSuffixstring(linear axes only)
xAxis|yAxis.minnumberUse this to override the automatic axis minimum value calculation (linear axes only)
xAxis|yAxis.maxnumberUse this to override the automatic axis maximum value calculation (linear axes only)
xAxis|yAxis.placementstart|end
xAxis|yAxis.tickSteplogical pixelsHint used for the distance between ticks (linear axes only)
xAxis|yAxis.tickStepValueaxis unitsDistance between ticks in axis units; overrides tickStep (linear axes only)
xAxis|yAxis.title.textstring
xAxis|yAxis.title.font.*-Overrides allAxes.font.* values for the axis title
xAxis|yAxis.typelinear|categorial/categorical

See the demos for some examples.

Licence

TayberryJS is released under the Lesser GNU Public Licence. If this poses a problem for you, feel free to open an issue.

Downloads

Head over to the releases page for the current version.

TayberryJS is at an early alpha stage. There will be some bugs, but please do open issues to provide feedback.

Roadmap

Some upcoming planned features are:

  • dynamic chart updates
  • date/time axes