Chart fixes during git dashboard creation

This commit is contained in:
Dennis Eichhorn 2016-05-26 22:53:38 +02:00
parent 16c57fb777
commit 7e11669ca3
5 changed files with 49 additions and 20 deletions

18
Chart/Chart.js vendored
View File

@ -7,19 +7,19 @@
this.title = {
visible: true,
text: "Title",
text: "",
anchor: "middle",
position: "center"
};
this.subtitle = {
visible: true,
text: "This is a short subtitle",
text: "",
anchor: "middle",
position: "center"
};
this.footer = {
visible: true,
text: "(c) Orange Management Solutions",
text: "",
anchor: "end",
position: "right"
};
@ -107,7 +107,7 @@
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
if (Object.keys(this.dataset).length > 0) {
@ -143,7 +143,7 @@
jsOMS.Chart.prototype.setTitle = function (title)
{
this.title = title;
this.title = jsOMS.merge(this.title, title);
};
jsOMS.Chart.prototype.getTitle = function ()
@ -183,7 +183,7 @@
jsOMS.Chart.prototype.setLegend = function (legend)
{
this.legend = legend;
this.legend = jsOMS.merge(this.legend, legend);
};
jsOMS.Chart.prototype.getLegend = function ()
@ -332,7 +332,7 @@
let temp, pos = 0, topmargin = 0;
/* 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);
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);
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;
// if no x axis available an element less will be drawn and the footer

View File

@ -68,6 +68,7 @@
height: box.height
};
// todo: allow ordinal data axis
x = d3.scale.linear().range([
0,
this.chart.dimension.width
@ -83,6 +84,7 @@
]);
// axis
// todo: implement manual tick (e.g. .ticks(6)) setting for axis
xAxis1 = d3.svg.axis().scale(x).tickFormat(function (d)
{
return self.chart.axis.x.tick.prefix + d;
@ -329,7 +331,8 @@ for (i = k = 1; k <= 3; i = ++k) {
count = i;
data.push(dataGen());
}
/*
var mychart = new jsOMS.Chart.LineChart('chart');
mychart.getChart().setData(data);
mychart.draw();
*/

View File

@ -87,8 +87,8 @@
return pie(d.points);
}).enter().append('path')
.attr("transform", "translate("
+ (this.chart.dimension.width / 2) + ","
+ (this.chart.dimension.height / 2 - this.chart.margin.bottom - this.chart.margin.top + 10) + ")")
+ ((this.chart.dimension.width - this.chart.margin.left - this.chart.margin.right) / 2 ) + ","
+ ((this.chart.dimension.height - this.chart.margin.bottom - this.chart.margin.top) / 2) + ")")
.attr('fill', function (d)
{
return self.chart.color(d.data.name);
@ -142,6 +142,10 @@ for (i = k = 1; k <= 1; i = ++k) {
data.push(dataGen());
}
/*
var mychart = new jsOMS.Chart.PieChart('chart');
mychart.getChart().setData(data);
mychart.draw();
*/

View File

@ -314,12 +314,18 @@
{
if (self.xhr.readyState === 4 && self.xhr.status === 200) {
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 (typeof this.requestHeader !== 'undefined' && this.requestHeader['Content-Type'] === 'application/json') {
console.log(JSON.stringify(this.data));
self.xhr.send(JSON.stringify(this.data));
} else {
self.xhr.send(this.queryfy(this.data));

View File

@ -264,20 +264,36 @@
*/
jsOMS.merge = function (target, source)
{
for (var p in source) {
let out = jsOMS.clone(target);
for (let p in source) {
try {
if (source[p].constructor == Object) {
target[p] = merge(target[p], source[p]);
// Property in destination object set; update its value.
if ( source[p].constructor==Object ) {
out[p] = jsOMS.merge(out[p], source[p]);
} else {
target[p] = source[p];
out[p] = source[p];
}
} catch (e) {
target[p] = source[p];
} catch(e) {
// 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 || {}));