forked from SyncfusionExamples/React-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror-bar.js
More file actions
200 lines (200 loc) · 12.9 KB
/
error-bar.js
File metadata and controls
200 lines (200 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Sample for error bar
*/
var React = require("react");
var ej2_react_charts_1 = require("@syncfusion/ej2-react-charts");
var property_pane_1 = require("../common/property-pane");
var sample_base_1 = require("../common/sample-base");
var theme_color_1 = require("./theme-color");
var ej2_react_dropdowns_1 = require("@syncfusion/ej2-react-dropdowns");
var ej2_react_inputs_1 = require("@syncfusion/ej2-react-inputs");
exports.data1 = [
{ x: 'IND', y: 24 }, { x: 'AUS', y: 20 }, { x: 'USA', y: 35 },
{ x: 'DEU', y: 27 }, { x: 'ITA', y: 30 },
{ x: 'UK', y: 41 }, { x: 'RUS', y: 26 }
];
exports.pointRender = function (args) {
var selectedTheme = location.hash.split('/')[1];
selectedTheme = selectedTheme ? selectedTheme : 'material';
if (selectedTheme && selectedTheme.indexOf('fabric') > -1) {
args.fill = theme_color_1.fabricColors[args.point.index % 10];
}
else if (selectedTheme === 'material') {
args.fill = theme_color_1.materialColors[args.point.index % 10];
}
else if (selectedTheme === 'highcontrast') {
args.fill = theme_color_1.highContrastColors[args.point.index % 10];
}
else {
args.fill = theme_color_1.bootstrapColors[args.point.index % 10];
}
};
var SAMPLE_CSS = "\n .control-fluid {\n\t\tpadding: 0px !important;\n\t}";
var ErrorBarChart = (function (_super) {
__extends(ErrorBarChart, _super);
function ErrorBarChart() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = [
{ value: 'Fixed' },
{ value: 'Percentage' },
{ value: 'StandardDeviation' },
{ value: 'StandardError' },
{ value: 'Custom' }
];
_this.emode = [
{ value: 'Vertical' },
{ value: 'Horizontal' },
{ value: 'Both' }
];
_this.directions = [
{ value: 'Both' },
{ value: 'Minus' },
{ value: 'Plus' }
];
return _this;
}
ErrorBarChart.prototype.change = function () {
this.chartInstance.series[0].errorBar.type = this.dropElement.value;
this.chartInstance.series[0].animation.enable = false;
this.chartInstance.refresh();
};
;
ErrorBarChart.prototype.mode = function () {
this.chartInstance.series[0].errorBar.mode = this.modeElement.value;
this.chartInstance.series[0].animation.enable = false;
this.chartInstance.refresh();
};
;
ErrorBarChart.prototype.errorBarVisible = function () {
this.chartInstance.series[0].errorBar.visible = this.checkElement.checked;
this.chartInstance.series[0].animation.enable = false;
this.chartInstance.refresh();
};
ErrorBarChart.prototype.errDirection = function () {
this.chartInstance.series[0].errorBar.direction = this.directionElement.value;
this.chartInstance.series[0].animation.enable = false;
this.chartInstance.refresh();
};
ErrorBarChart.prototype.vError = function () {
this.chartInstance.series[0].errorBar.verticalError = this.vErrElement.value;
this.chartInstance.series[0].animation.enable = false;
this.chartInstance.refresh();
};
ErrorBarChart.prototype.hError = function () {
this.chartInstance.series[0].errorBar.horizontalError = this.hErrElement.value;
this.chartInstance.series[0].animation.enable = false;
this.chartInstance.refresh();
};
ErrorBarChart.prototype.render = function () {
var _this = this;
return (React.createElement("div", { className: 'control-pane' },
React.createElement("style", null, SAMPLE_CSS),
React.createElement("div", { className: 'control-section row' },
React.createElement("div", { className: 'col-md-8' },
React.createElement(ej2_react_charts_1.ChartComponent, { id: 'charts', ref: function (chart) { return _this.chartInstance = chart; }, primaryXAxis: {
valueType: 'Category', interval: 1,
majorGridLines: { width: 0 }
}, chartArea: { border: { width: 0 } }, primaryYAxis: {
labelFormat: '{value}%', minimum: 15, maximum: 45,
lineStyle: { width: 0 }
}, pointRender: exports.pointRender, load: this.load.bind(this), title: "Sales Distribution of Car by Region", loaded: this.onChartLoad.bind(this), tooltip: { enable: true } },
React.createElement(ej2_react_charts_1.Inject, { services: [ej2_react_charts_1.ScatterSeries, ej2_react_charts_1.Category, ej2_react_charts_1.ErrorBar, ej2_react_charts_1.Tooltip] }),
React.createElement(ej2_react_charts_1.SeriesCollectionDirective, null,
React.createElement(ej2_react_charts_1.SeriesDirective, { dataSource: exports.data1, xName: 'x', yName: 'y', type: 'Scatter', marker: { height: 10, width: 10 }, errorBar: { visible: true, verticalError: 3, horizontalError: 3 }, width: 2, name: 'Sales' })))),
React.createElement("div", { className: 'col-md-4 property-section' },
React.createElement(property_pane_1.PropertyPane, { title: 'Properties' },
React.createElement("table", { id: 'property', title: 'Properties', className: 'property-panel-table', style: { width: '100%' } },
React.createElement("tr", { style: { height: '50px' } },
React.createElement("td", { style: { width: '60%' } },
React.createElement("div", null, "Error Bar Type: ")),
React.createElement("td", { style: { width: '40%' } },
React.createElement("div", null,
React.createElement(ej2_react_dropdowns_1.DropDownListComponent, { width: 120, id: "type", change: this.change.bind(this), ref: function (d) { return _this.dropElement = d; }, dataSource: this.type, fields: { text: 'value', value: 'value' }, value: "Fixed" })))),
React.createElement("tr", { style: { height: '50px' } },
React.createElement("td", { style: { width: '60%' } },
React.createElement("div", null, "Drawing Mode: ")),
React.createElement("td", { style: { width: '40%' } },
React.createElement("div", null,
React.createElement(ej2_react_dropdowns_1.DropDownListComponent, { width: 120, id: "modes", change: this.mode.bind(this), ref: function (d) { return _this.modeElement = d; }, dataSource: this.emode, fields: { text: 'value', value: 'value' }, value: "Vertical" })))),
React.createElement("tr", { style: { height: '50px' } },
React.createElement("td", { style: { width: '60%' } },
React.createElement("div", null, "Drawing Direction: ")),
React.createElement("td", { style: { width: '40%' } },
React.createElement("div", null,
React.createElement(ej2_react_dropdowns_1.DropDownListComponent, { width: 120, id: "directions", change: this.errDirection.bind(this), ref: function (d) { return _this.directionElement = d; }, dataSource: this.directions, fields: { text: 'value', value: 'value' }, value: "Both" })))),
React.createElement("tr", { style: { height: '50px' } },
React.createElement("td", { style: { width: '60%' } },
React.createElement("div", null, "Vertical Error:")),
React.createElement("td", { style: { padding: 10, width: '40%' } },
React.createElement(ej2_react_inputs_1.NumericTextBoxComponent, { width: 120, value: 3, min: 1, max: 20, step: 1, change: this.vError.bind(this), ref: function (d) { return _this.vErrElement = d; } }))),
React.createElement("tr", { style: { height: '50px' } },
React.createElement("td", { style: { width: '60%' } },
React.createElement("div", null, "Horizontal Error:")),
React.createElement("td", { style: { padding: 10, width: '40%' } },
React.createElement(ej2_react_inputs_1.NumericTextBoxComponent, { width: 120, value: 3, min: 1, max: 20, step: 1, change: this.hError.bind(this), ref: function (d) { return _this.hErrElement = d; } }))))))),
React.createElement("div", { id: "action-description" },
React.createElement("p", null, "This sample visualizes the errors in sales distribution of a car for a certain period with error bar in the chart. In property panel, the options are available to change error bar type, drawing mode, and drawing direction of error bar by means of dropdown")),
React.createElement("div", { id: "description" },
React.createElement("p", null,
"In this example, you can see how to render and configure the error bar charts. Line type charts are used for cartesian type series. You can use error bar by set ",
React.createElement("code", null, "visible"),
" property to true. You can change the error bar rendering type using ",
React.createElement("code", null, "type"),
" property like fixedValue, percentage, standardDeviation, standardError and custom option of errorBar. To change the error bar line length you can use ",
React.createElement("code", null, "verticalError"),
" property."),
React.createElement("p", null, "Chart supports the following error bar types."),
React.createElement("ul", null,
React.createElement("li", null,
React.createElement("code", null, "Fixed"),
" - Renders a fixed type error bar."),
React.createElement("li", null,
React.createElement("code", null, "Percentage"),
" - Renders a percentage type error bar."),
React.createElement("li", null,
React.createElement("code", null, "StandardDeviation"),
" - Renders a standard deviation type error bar."),
React.createElement("li", null,
React.createElement("code", null, "StandardError"),
" - Renders a standard error type error bar."),
React.createElement("li", null,
React.createElement("code", null, "Custom"),
" - Renders a custom type error bar.")),
React.createElement("p", null,
React.createElement("b", null, "Injecting Module")),
React.createElement("p", null,
"Chart component features are segregated into individual feature-wise modules. To use error bar, we need to inject",
React.createElement("code", null, "ErrorBar"),
" into the ",
React.createElement("code", null, "@services"),
" section."),
React.createElement("p", null,
"More information on the smart axis labels can be found in this \u00A0",
React.createElement("a", { target: "_blank", href: "http://ej2.syncfusion.com/react/documentation/chart/api-series.html#type-chartseriestype" }, "documentation section"),
"."))));
};
ErrorBarChart.prototype.onChartLoad = function (args) {
document.getElementById('charts').setAttribute('title', '');
};
;
ErrorBarChart.prototype.load = function (args) {
var selectedTheme = location.hash.split('/')[1];
selectedTheme = selectedTheme ? selectedTheme : 'Material';
args.chart.theme = (selectedTheme.charAt(0).toUpperCase() + selectedTheme.slice(1));
};
;
return ErrorBarChart;
}(sample_base_1.SampleBase));
exports.ErrorBarChart = ErrorBarChart;