@hisptz/react-ui
Version:
A collection of reusable complex DHIS2 react ui components.
114 lines (99 loc) • 3.05 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DHIS2Chart = void 0;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
class DHIS2Chart {
constructor(id, analytics, config) {
_defineProperty(this, "id", void 0);
_defineProperty(this, "analytics", void 0);
_defineProperty(this, "config", void 0);
this.id = id;
this.analytics = analytics;
this.config = config;
}
getChartConfig() {
var _this$config;
return {
renderTo: this.id,
zoomType: "xy",
type: this.getHighchartsType(),
height: (_this$config = this.config) === null || _this$config === void 0 ? void 0 : _this$config.height,
styledMode: false
};
}
getOptions() {
var _this$config$colors, _this$config2, _this$config$highChar, _this$config3;
return {
yAxis: this.getYAxis(),
chart: this.getChartConfig(),
colors: (_this$config$colors = (_this$config2 = this.config) === null || _this$config2 === void 0 ? void 0 : _this$config2.colors) !== null && _this$config$colors !== void 0 ? _this$config$colors : ["#2f7ed8", "#0d233a", "#8bbc21", "#910000", "#1aadce", "#492970", "#f28f43", "#77a1e5", "#c42525", "#a6c96a"],
series: this.getSeries(),
plotOptions: this.getPlotOptions(),
title: {
text: ""
},
xAxis: this.getXAxis(),
exporting: this.getExporting(),
legend: {
enabled: true
},
credits: {
enabled: false
},
...((_this$config$highChar = (_this$config3 = this.config) === null || _this$config3 === void 0 ? void 0 : _this$config3.highChartOverrides) !== null && _this$config$highChar !== void 0 ? _this$config$highChar : {})
};
}
getYAxis() {
return [{
title: {
text: "",
style: {
color: "#000000",
fontWeight: "normal",
fontSize: "14px"
}
},
labels: {
enabled: true,
style: {
color: "#000000",
fontWeight: "normal",
fontSize: "14px"
}
},
plotLines: [{
color: "#000000",
dashStyle: "Solid",
width: 2,
zIndex: 1000,
label: {
text: ""
}
}, {
color: "#bbbbbb",
dashStyle: "Solid",
zIndex: 1000,
width: 2,
label: {
text: ""
}
}]
}];
}
getExporting() {
var _this$config$name, _this$config4;
const name = (_this$config$name = (_this$config4 = this.config) === null || _this$config4 === void 0 ? void 0 : _this$config4.name) !== null && _this$config$name !== void 0 ? _this$config$name : "chart";
return {
filename: "".concat(name),
sourceWidth: 1200,
buttons: {
contextButton: {
enabled: false
}
}
};
}
}
exports.DHIS2Chart = DHIS2Chart;