import * as React from 'react';
import JqxChart, { IChartProps, jqx } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxchart';
class App extends React.PureComponent<{}, IChartProps> {
constructor(props: {}) {
super(props);
const months: string[] = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
const source: any = {
datafields: [
{ name: 'Date' },
{ name: 'Referral' },
{ name: 'SearchPaid' },
{ name: 'SearchNonPaid' }
],
datatype: 'tab',
url: 'website_analytics.txt'
};
this.state = {
description: 'Daily unique visitors (stacked)',
padding: { left: 10, top: 5, right: 10, bottom: 5 },
seriesGroups: [
{
series: [
{ dataField: 'Referral', displayText: 'Referral Traffic' },
{ dataField: 'SearchPaid', displayText: 'Paid Search Traffic' },
{ dataField: 'SearchNonPaid', displayText: 'Organic Search Traffic' }
],
type: 'stackedline'
}
],
source: new jqx.dataAdapter(source, { async: false, autoBind: true, loadError: (xhr: any, status: any, error: any) => { alert('Error loading "' + source.url + '" : ' + error); } }),
title: 'Web Site Traffic Analysis',
titlePadding: { left: 50, top: 0, right: 0, bottom: 10 },
valueAxis: {
labels: { horizontalAlignment: 'right' },
maxValue: 4500,
minValue: 0,
title: { text: 'Daily Visits
' },
unitInterval: 500
},
xAxis: {
baseUnit: 'day',
dataField: 'Date',
labels: {
formatFunction: (value: any): string => {
return value.getDate();
}
},
toolTipFormatFunction: (value: any): string => {
return value.getDate() + '-' + months[value.getMonth()] + '-' + value.getFullYear();
},
type: 'date',
valuesOnTicks: false
}
};
}
public render() {
return (
);
}
}
export default App;