mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-02-12 23:58:39 +00:00
Chart fixes during git dashboard creation
This commit is contained in:
parent
16c57fb777
commit
7e11669ca3
18
Chart/Chart.js
vendored
18
Chart/Chart.js
vendored
|
|
@ -7,19 +7,19 @@
|
||||||
|
|
||||||
this.title = {
|
this.title = {
|
||||||
visible: true,
|
visible: true,
|
||||||
text: "Title",
|
text: "",
|
||||||
anchor: "middle",
|
anchor: "middle",
|
||||||
position: "center"
|
position: "center"
|
||||||
};
|
};
|
||||||
this.subtitle = {
|
this.subtitle = {
|
||||||
visible: true,
|
visible: true,
|
||||||
text: "This is a short subtitle",
|
text: "",
|
||||||
anchor: "middle",
|
anchor: "middle",
|
||||||
position: "center"
|
position: "center"
|
||||||
};
|
};
|
||||||
this.footer = {
|
this.footer = {
|
||||||
visible: true,
|
visible: true,
|
||||||
text: "(c) Orange Management Solutions",
|
text: "",
|
||||||
anchor: "end",
|
anchor: "end",
|
||||||
position: "right"
|
position: "right"
|
||||||
};
|
};
|
||||||
|
|
@ -107,7 +107,7 @@
|
||||||
|
|
||||||
jsOMS.Chart.prototype.setAxis = function (id, axis)
|
jsOMS.Chart.prototype.setAxis = function (id, axis)
|
||||||
{
|
{
|
||||||
this.axis[id] = axis;
|
this.axis[id] = jsOMS.merge(this.axis[id], axis);
|
||||||
|
|
||||||
// Setting axis dimensions in case dataset existss
|
// Setting axis dimensions in case dataset existss
|
||||||
if (Object.keys(this.dataset).length > 0) {
|
if (Object.keys(this.dataset).length > 0) {
|
||||||
|
|
@ -143,7 +143,7 @@
|
||||||
|
|
||||||
jsOMS.Chart.prototype.setTitle = function (title)
|
jsOMS.Chart.prototype.setTitle = function (title)
|
||||||
{
|
{
|
||||||
this.title = title;
|
this.title = jsOMS.merge(this.title, title);
|
||||||
};
|
};
|
||||||
|
|
||||||
jsOMS.Chart.prototype.getTitle = function ()
|
jsOMS.Chart.prototype.getTitle = function ()
|
||||||
|
|
@ -183,7 +183,7 @@
|
||||||
|
|
||||||
jsOMS.Chart.prototype.setLegend = function (legend)
|
jsOMS.Chart.prototype.setLegend = function (legend)
|
||||||
{
|
{
|
||||||
this.legend = legend;
|
this.legend = jsOMS.merge(this.legend, legend);
|
||||||
};
|
};
|
||||||
|
|
||||||
jsOMS.Chart.prototype.getLegend = function ()
|
jsOMS.Chart.prototype.getLegend = function ()
|
||||||
|
|
@ -332,7 +332,7 @@
|
||||||
let temp, pos = 0, topmargin = 0;
|
let temp, pos = 0, topmargin = 0;
|
||||||
|
|
||||||
/* No subtitle without title */
|
/* No subtitle without title */
|
||||||
if (this.subtitle !== undefined && this.subtitle.visible && this.title !== undefined && this.title.visible) {
|
if (this.subtitle !== undefined && this.subtitle.text !== '' && this.subtitle.visible && this.title !== undefined && this.title.text !== '' && this.title.visible) {
|
||||||
pos = this.calculateHorizontalPosition(this.subtitle.position);
|
pos = this.calculateHorizontalPosition(this.subtitle.position);
|
||||||
|
|
||||||
temp = svg.append("text")
|
temp = svg.append("text")
|
||||||
|
|
@ -353,7 +353,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.title !== undefined && this.title.visible) {
|
if (this.title !== undefined && this.title.text !== '' && this.title.visible) {
|
||||||
pos = this.calculateHorizontalPosition(this.title.position);
|
pos = this.calculateHorizontalPosition(this.title.position);
|
||||||
|
|
||||||
temp = svg.append("text")
|
temp = svg.append("text")
|
||||||
|
|
@ -371,7 +371,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.footer !== undefined && this.footer.visible) {
|
if (this.footer !== undefined && this.footer.text !== '' && this.footer.visible) {
|
||||||
let spacer = 0;
|
let spacer = 0;
|
||||||
|
|
||||||
// if no x axis available an element less will be drawn and the footer
|
// if no x axis available an element less will be drawn and the footer
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@
|
||||||
height: box.height
|
height: box.height
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// todo: allow ordinal data axis
|
||||||
x = d3.scale.linear().range([
|
x = d3.scale.linear().range([
|
||||||
0,
|
0,
|
||||||
this.chart.dimension.width
|
this.chart.dimension.width
|
||||||
|
|
@ -83,6 +84,7 @@
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// axis
|
// axis
|
||||||
|
// todo: implement manual tick (e.g. .ticks(6)) setting for axis
|
||||||
xAxis1 = d3.svg.axis().scale(x).tickFormat(function (d)
|
xAxis1 = d3.svg.axis().scale(x).tickFormat(function (d)
|
||||||
{
|
{
|
||||||
return self.chart.axis.x.tick.prefix + d;
|
return self.chart.axis.x.tick.prefix + d;
|
||||||
|
|
@ -329,7 +331,8 @@ for (i = k = 1; k <= 3; i = ++k) {
|
||||||
count = i;
|
count = i;
|
||||||
data.push(dataGen());
|
data.push(dataGen());
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
var mychart = new jsOMS.Chart.LineChart('chart');
|
var mychart = new jsOMS.Chart.LineChart('chart');
|
||||||
mychart.getChart().setData(data);
|
mychart.getChart().setData(data);
|
||||||
mychart.draw();
|
mychart.draw();
|
||||||
|
*/
|
||||||
|
|
@ -87,8 +87,8 @@
|
||||||
return pie(d.points);
|
return pie(d.points);
|
||||||
}).enter().append('path')
|
}).enter().append('path')
|
||||||
.attr("transform", "translate("
|
.attr("transform", "translate("
|
||||||
+ (this.chart.dimension.width / 2) + ","
|
+ ((this.chart.dimension.width - this.chart.margin.left - this.chart.margin.right) / 2 ) + ","
|
||||||
+ (this.chart.dimension.height / 2 - this.chart.margin.bottom - this.chart.margin.top + 10) + ")")
|
+ ((this.chart.dimension.height - this.chart.margin.bottom - this.chart.margin.top) / 2) + ")")
|
||||||
.attr('fill', function (d)
|
.attr('fill', function (d)
|
||||||
{
|
{
|
||||||
return self.chart.color(d.data.name);
|
return self.chart.color(d.data.name);
|
||||||
|
|
@ -142,6 +142,10 @@ for (i = k = 1; k <= 1; i = ++k) {
|
||||||
data.push(dataGen());
|
data.push(dataGen());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
var mychart = new jsOMS.Chart.PieChart('chart');
|
var mychart = new jsOMS.Chart.PieChart('chart');
|
||||||
mychart.getChart().setData(data);
|
mychart.getChart().setData(data);
|
||||||
mychart.draw();
|
mychart.draw();
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
|
||||||
|
|
@ -314,12 +314,18 @@
|
||||||
{
|
{
|
||||||
if (self.xhr.readyState === 4 && self.xhr.status === 200) {
|
if (self.xhr.readyState === 4 && self.xhr.status === 200) {
|
||||||
self.success(self.xhr);
|
self.success(self.xhr);
|
||||||
|
} else if(self.xhr.readyState === 2) {
|
||||||
|
// todo: handle server received request
|
||||||
|
} else if(self.xhr.readyState === 3) {
|
||||||
|
// todo: server is handling request
|
||||||
|
} else {
|
||||||
|
// todo: create handler for error returns
|
||||||
|
console.log(self.xhr)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.type === jsOMS.Message.Request.RequestType.JSON) {
|
if (this.type === jsOMS.Message.Request.RequestType.JSON) {
|
||||||
if (typeof this.requestHeader !== 'undefined' && this.requestHeader['Content-Type'] === 'application/json') {
|
if (typeof this.requestHeader !== 'undefined' && this.requestHeader['Content-Type'] === 'application/json') {
|
||||||
console.log(JSON.stringify(this.data));
|
|
||||||
self.xhr.send(JSON.stringify(this.data));
|
self.xhr.send(JSON.stringify(this.data));
|
||||||
} else {
|
} else {
|
||||||
self.xhr.send(this.queryfy(this.data));
|
self.xhr.send(this.queryfy(this.data));
|
||||||
|
|
|
||||||
|
|
@ -264,20 +264,36 @@
|
||||||
*/
|
*/
|
||||||
jsOMS.merge = function (target, source)
|
jsOMS.merge = function (target, source)
|
||||||
{
|
{
|
||||||
for (var p in source) {
|
let out = jsOMS.clone(target);
|
||||||
|
|
||||||
|
for (let p in source) {
|
||||||
try {
|
try {
|
||||||
if (source[p].constructor == Object) {
|
// Property in destination object set; update its value.
|
||||||
target[p] = merge(target[p], source[p]);
|
if ( source[p].constructor==Object ) {
|
||||||
|
out[p] = jsOMS.merge(out[p], source[p]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
target[p] = source[p];
|
out[p] = source[p];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch(e) {
|
||||||
target[p] = source[p];
|
// Property in destination object not set; create it and set its value.
|
||||||
|
out[p] = source[p];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return target;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* todo: implement deep clone/copy
|
||||||
|
* @param obj
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
jsOMS.clone = function (obj)
|
||||||
|
{
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
}(window.jsOMS = window.jsOMS || {}));
|
}(window.jsOMS = window.jsOMS || {}));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user