Highchart reduce gap size in heatmap and data missing - heatmap

Somehow the gap is not reduced, as shown in the picture below:
I am using a Highcharts Heatmap. Please help me to reduce the gap between the intervals and the line should be closer. When we increase the data, some data is not showing on the graph and they are skipped. The data seems to be missing somewhere.
Highcharts
.stockChart(
'container',
{
chart : {
type : 'heatmap',
marginTop : 40,
height : 500,
width : 900,
panning : true,
followTouchMove : true,
pinchType : 0,
followPointer : true,
inverted : true,
},
data : {
csv : data,
},
navigator : {
top : 40,
},
rangeSelector : {
buttons : [ {
count : 1,
type : 'minute',
text : '1M'
}, {
count : 5,
type : 'minute',
text : '5M'
}, {
type : 'all',
text : 'All'
} ],
inputEnabled : false,
enabled : false,
selected : 0
},
title : {
text : 'Live random data'
},
exporting : {
enabled : true,
buttons : {
contextButton : {
menuItems : [
{
textKey : 'viewData',
onclick : function() {
this.viewData();
$('#pausereset')
.toggleClass(
'optionsettable');
}
},
{
separator : true
},
{
textKey : 'downloadPNG',
onclick : function() {
var title = this.title.textStr;
this.exportChart({
type : 'image/png',
filename : title
});
}
},
{
textKey : 'downloadJPEG',
onclick : function() {
var title = this.title.textStr;
this
.exportChart({
type : 'image/jpeg',
filename : title
});
}
},
{
textKey : 'downloadPDF',
onclick : function() {
var title = this.title.textStr;
this
.exportChart({
type : 'application/pdf',
filename : title
});
}
},
{
textKey : 'downloadSVG',
onclick : function() {
var title = this.title.textStr;
this
.exportChart({
type : 'image/svg+xml',
filename : title
});
}
} ]
}
}
},
yAxis : {
scrollbar : {
enabled : true,
showFull : true
},
title : {
text : null
},
labels : {
format : '{value}:00'
},
/* minPadding : 50,
maxPadding : 20, */
/* tickPositions : [ 0, 6, 12, 18, 24 ], */
tickWidth : 0.5,
/* min : 0,
max : 33 */
},
xAxis : {
reversed : true,
scrollbar : {
enabled : true,
showFull : true
},
tickPixelInterval : 0.5,
},
plotOptions : {
dataLabels : {
enabled : true
},
heatmap : {
allowPointSelect : true
},
series : {
pointPadding : 0,
groupPadding : 0.1,
}
},
colorAxis : {
stops : [ [ 0, '#84D984' ], [ 0.5, '#127B12' ],
[ 0.9, '#005500' ] ],
min : -5
},
series : [ {
type : 'heatmap',
name : 'Random data',
borderWidth : 0,
showInNavigator : true,
turboThreshold : 0,
cropThreshold : 300,
/* colsize : 0.1 * 36e5, */
pointPadding : 0,
colsize : 0.1 * 36e5,
rowsize : 1,
tooltip : {
headerFormat : 'Temperature<br/>',
pointFormat : '{point.x: %H}:{point.x: %m} - {point.y}:00: <b>{point.value} ℃</b>'
},
} ]
});
Here is the jsfiddle link

You just need to increase the series.colsize value. In this case, you can set it equal to one hour interval, just like that:
series: [{
type:'heatmap',
borderWidth: 0,
pointWidth: '100%',
colsize: 36e5, // one hour
tooltip: {
headerFormat: 'Temperature<br/>',
pointFormat: '{point.x:%e %b, %Y} {point.y}:00: <b>{point.value} ℃</b>'
}
}]
Live example: http://jsfiddle.net/zpvdweab/1/

Related

MongoDB query with a LEFT JOIN

I am doing a mongodb query or I was using a LEFT JOIN for the SQL database.
Here is the document of a profil :
{
"_id" : ObjectId("5bd22f28f77cfb1f6ce503ca"),
"search" : "flarize",
"name" : "flarize",
"email" : "flarize.ba73#gmail.com",
"password" : "$2a$10$eYeOtEkEUyD7TFkjKvhZOuSSpvBolkL17TrPHuoHhOT8JrsQR0UKW",
"color" : 0,
"profil" : "",
"banner" : "",
"desc" : "",
"date" : 1540501286109,
"friend" : [
{
"id" : ObjectId("5bd19a92da24674fdabd26b6")
}
],
"groupes" : [ ]
}
I am currently using this request:
db.users.find({search: /f/}).limit(20);
this query just given profile according to the regex.
may I want more, if the id of the person who call this query is present in the section friend then we add :
is_friend: true
else add:
is_friend: false
EDIT :
For this query we have:
The id of the who call the request, and whe try to know if this id is present in the friend field.
EDIT
I try this but not working, return false.
herdb.users.aggregate([{$match:{"search":"flarize"}},
{$project:
{search: 1, name: 1, color: 1, profil: 1, banner: 1, desc: 1, date: 1, friend:10, groupes:10,
is_friend:
{$cond:[
{$eq:["$friend.id", ObjectId("5bd19a92da24674fdabd26b6")]},
true,
false]
}
}
}
]).pretty();
Thank you for helping me.
Use $unwind for a friend before matching it's id
$eq is not working for an array.
db.getCollection('tests').aggregate([
{ $match: {"search":"flarize"} },
{ $unwind: "$friend"},
{ $project:{
search: 1, name: 1, color: 1, profil: 1, banner: 1, desc: 1, date: 1, friend:10, groupes:10,
is_friend: { $cond: [
{ $eq :["$friend.id", ObjectId("5bd19a92da24674fdabd26b6")]}, true, false ]}
}
}
]);
Output:
/* 1 */
{
"_id" : ObjectId("5bd22f28f77cfb1f6ce503ca"),
"search" : "flarize",
"name" : "flarize",
"color" : 0,
"profil" : "",
"banner" : "",
"desc" : "",
"date" : NumberLong(1540501286109),
"friend" : {
"id" : ObjectId("5bd19a92da24674fdabd26b6"),
"id" : ObjectId("5bd19a92da24674fdabd26b4"),
"id" : ObjectId("5bd19a92da24674fdabd26b2"),
"id" : ObjectId("5bd19a92da24674fdabd26b1")
},
"groupes" : [],
"is_friend" : true
}
And if you want friend back it to an array list:
db.getCollection('tests').aggregate([
{ $match: {"search":"flarize"} },
{ $unwind: "$friend"},
{ $project:
{
search: 1, name: 1, color: 1, profil: 1, banner: 1, desc: 1, date: 1, friend:10, groupes:10,
is_friend: { $cond: [
{ $eq :["$friend.id", ObjectId("5bd19a92da24674fdabd26b6")]}, true, false ]}
}
},
{$group : {
_id: "$_id",
search : {$first: "$search"},
name : {$first: "$name"},
color : {$first: "$color"},
profil : {$first: "$profil"},
banner : {$first: "$banner"},
desc : {$first: "$desc"},
date : {$first: "$date"},
groupes : {$first: "$groupes"},
friend : {$push: "$friend"},
is_friend: {$first: "$is_friend"}
}}
])

KendoUI Grid Server Binding Example

I have successfully set up several KendoUI Grids, but I cannot get one using server-side paging to work.
I modified my rest service so I will return a total value (hard coded right now).
I also modified my javascript source. [see below].
Usually I just get a blank screen.
Would be very grateful for any assistance.
Script:
$(document).ready(function(){
// Setup Rest Service
var loc = ( location.href );
var url = loc.substring( 0, loc.lastIndexOf( "/" ) ) + "/xpRest.xsp/test/";
dataSource = new kendo.data.DataSource({
pageSize: 20,
serverPaging: true,
serverFiltering: true,
serverSorting: true, transport : {
read : {
url : url + "READ",
dataType : "json"
},
type : "READ"
},
schema : {
total: "total",
model : {
id : "unid",
fields : {
unid : {
type : "string",
nullable : false
},
tckNbr : {
type : "string",
editable : false
},
tckSts : {
type : "string",
editable : false
}
}
}
}
});
grid = $("#grid-databound-dataItem").kendoGrid({
dataSource : dataSource,
height: 550,
filterable: true,
sortable: true,
pageable: true,
columns : [
{field : "tckNbr", title : "Number", type: "string"},
{field : "tckSts", title : "Status", type: "string"}
]
}).data("kendoGrid");
});
JSON feed:
[
{
"total":100,
"data":
[
{
"tckNbr":"3031",
"tckSts":"1 Not Assigned",
"unid":"0014DA9095BF6D638625810700597A36",
"tckReqs":"Bryan S Schmiedeler",
"tckNts":
[
"Bryan DeBaun"
],
"tckBUs":
[
"NAP\/IFI"
],
"tckApps":"GTM",
"tckType":"Issue",
"tckPriority":"Medium"
},
{
"tckNbr":"3031",
"tckSts":"1 Not Assigned",
"unid":"00598976D88226D2862581070059AD25",
"tckReqs":"Bryan S Schmiedeler",
"tckNts":
[
"Bryan DeBaun"
],
"tckBUs":
[
"NAP\/IFI"
],
"tckApps":"GTM",
"tckType":"Issue",
"tckPriority":"Medium"
}
]
}
]
Correct your JSON feed, you need to return object not array:
{
"total": 10,
"data": []
}
After that say what is data and what is total in you schema:
schema : {
total: "total",
data: "data",
.
.
}
Note: if you mock data like in your case (total: 100, data -> size is 2) your paginatio will be created by total parameter not data itself. You will see 5 pages with same data (that is ok).

Query to return a field from a nested json using MongoDB

My database has data in the following format :
{ "_id" : ObjectId( "abcd" ),
"coordinate" : [somevalue, somevalue],
"value" : [
{ "time" : 1,
"characteristics" : "pqrs" },
{ "time" : 10,
"characteristics" : "pqrs" } ] }
I want to find the field closest coordinate and a time that is less than or equal to a given value.
Currently I'm using this query :
db.collection.aggregate({
coordinate: {
$geoNear: [latitude, longitude],
$maxDistance: 10
},
"value.time": {
$lte: 5
}
})
This one returned the entire entry, but what I wanted is the field:
{ "time" : 1, "characteristics" : "pqrs" }
Is it even possible to just return this field ? What if there are multiple result and I just want the one that's closest to my value.time input ?
You can perform an aggregation to :
$match items with specified coordinate and value.time
$filter value array to remove everything < 5
$unwind value array
$group by max value
Query is :
db.collection.aggregate({
$match: {
coordinate: {
$geoNear: [0, 0],
$maxDistance: 10
},
"value.time": {
$lte: 5
}
}
}, {
$project: {
value: {
$filter: {
input: "$value",
as: "value",
cond: { $lte: ["$$value.time", 5] }
}
}
}
}, {
$unwind: "$value"
}, {
$group: {
_id: "$_id",
time: { $max: "$value.time" },
characteristics: { $first: "$value.characteristics" }
}
})
Sample output :
{ "_id" : ObjectId("588a8c3080a14de2d654eb7b"), "time" : 4, "characteristics" : "pqrs" }
{ "_id" : ObjectId("588a89327fe89686fd2210b2"), "time" : 1, "characteristics" : "pqrs" }

Arrange the html text inside flag ( HighStock)

I have been trying to arrange the text inside the flag element for highstock similar to image below but been struggling for too long.
Was wondering if this is possible and how
Updated in jsfiddle
http://jsfiddle.net/wj9vvq6o/
$(function () {
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=usdeur.json&callback=?', function (data) {
// Create the chart
$('#container').highcharts('StockChart', {
rangeSelector : {
selected : 1
},
title : {
text : 'USD to EUR exchange rate'
},
yAxis : {
title : {
text : 'Exchange rate'
}
},
series : [{
name : 'USD to EUR',
data : data,
id : 'dataseries',
tooltip : {
valueDecimals: 4
}
}, {
type : 'flags',
data : [{
x : Date.UTC(2011, 1, 22),
title : 'A',
text : 'Shape: "squarepin"'
}, {
x : Date.UTC(2011, 3, 28),
title : 'Test Name goes here <br> Test 2 goes here',
text : 'Shape: "squarepin"'
}],
onSeries : 'dataseries',
shape : 'squarepin',
width : 140
}, {
type : 'flags',
data : [{
x : Date.UTC(2011, 2, 1),
title : 'B',
text : 'Shape: "circlepin"'
}, {
x : Date.UTC(2011, 3, 1),
title : 'B',
text : 'Shape: "circlepin"'
}],
shape : 'circlepin',
width : 16
}, {
type : 'flags',
data : [{
x : Date.UTC(2011, 2, 10),
title : 'C',
text : 'Shape: "flag"'
}, {
x : Date.UTC(2011, 3, 11),
title : 'C',
text : 'Shape: "flag"'
}],
color : Highcharts.getOptions().colors[0], // same as onSeries
fillColor : Highcharts.getOptions().colors[0],
onSeries : 'dataseries',
width : 16,
style : {// text style
color : 'white'
},
states : {
hover : {
fillColor : '#395C84' // darker
}
}
}]
});
});
});
This is all i have managed - i need to add the number 100 beside it
You can try to set a useHTML flag in series object. Then arrange your content by HTML elements and CSS styles.
series:
{
useHTML:true,
dataLabels:{
useHTML:true,
},
type : 'flags',
data : [{
x : Date.UTC(2011, 1, 22),
title : 'A',
text : 'Shape: "squarepin"'
}, {
x : Date.UTC(2011, 3, 28),
title : '<span style="text-align:right;width:100%;display:block;">Test Name goes here </span>100 <br><span style="text-align:right;width:100%;display:block;">Test 2 goes here</span>',
text : 'Shape: "squarepin"'
}],
onSeries : 'dataseries',
shape : 'squarepin',
width : 140
},
Simple example: http://jsfiddle.net/wj9vvq6o/4/

jqplot graph background seems to be black in ie8

I'm using jqplot in my website using the following code
$(document).ready(function(){
var xticks = [ '0', '1', '2', '3', '4','5', '6', '7', '8', '9', '10','11', '13','14','15','16','17','18','19','20','21','22','23'];
var data1 = [2,4,6,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,2,6,3,1,2,2,0,0,0,0,0,0,2,5,6,6,7,6,6,6,5,7,7,6,1,0,0,0,0];
var plot2 = jQuery.jqplot ('chart1', [data1],
{
animate : true,
// Will animate plot on calls to plot1.replot({resetAxes:true})
animateReplot : true,
seriesDefaults : {
pointLabels : {
show : true,
hideZeros : true,
location : 's',
ypadding : 12
},
renderer : $.jqplot.BarRenderer,
rendererOptions : {
varyBarColor : true,
barPadding : -20
}
},
axes : {
xaxis : {
label : 'X axis',
fontFamily : 'OpenSans-Regular',
textColor : '#414141',
renderer : $.jqplot.CategoryAxisRenderer,
labelRenderer : $.jqplot.CanvasAxisLabelRenderer,
tickRenderer : $.jqplot.CanvasAxisTickRenderer,
ticks : xticks,
tickOptions : {
fontFamily : 'OpenSans-Regular',
textColor : '#414141',
angle : -90,
fontSize : '10pt'
}
},
yaxis : {
min : 0,
//max : 30,
tickInterval:5,
label : 'Y axis',
fontFamily : 'OpenSans-Regular',
textColor : '#414141',
// labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
tickOptions : {
fontFamily : 'OpenSans-Regular',
textColor : '#414141',
formatString : '%.2f',
fontSize : '10pt'
}
}
},
cursor : {
show : true,
zoom : false,
showTooltip : true,
followMouse : true,
useAxesFormatters : true
/*
* To show both x and y values showTooltipDataPosition :true,
* showVerticalLine:true, useAxesFormatters:true
*/
},
legend : {
renderer : $.jqplot.EnhancedLegendRenderer,
show : true,
showSwatches : true,
fontFamily : 'OpenSans-Regular',
marginTop : '100px',
textColor : '#414141',
rowSpacing : '14px',
border : 'none',
background : 'transparent',
placement : 'outsideGrid'
},
grid : {
background : 'transparent',
gridLineColor : '#c5c5c5'
},
seriesColors : [ '#F6BD0F' ],
series : [ {
seriesColors : [ "#D85252" ],
//label : 's1',
color : [ '#D85252' ]
}, {
seriesColors : [ "#F6BD0F" ],
label : 's2',
color : [ '#F6BD0F' ]
} ],
highlighter : {
show : false
}
}
);
});
It works fine in Firefox and IE9 without any issues as in figure1. But in IE8 it looks very bad as in figure2.
I have included excanvas.js as follows
<script type="text/javascript" language="javascript" src="jQuery/jQplot/excanvas.min.js"></script>
IE9 and Firefox
IE8
Here is the working jsfiddle
Can anyone tell me how can I resolve this issue? What I'm doing wrong here? Any help will be appreciated..
Finally I got the answer after research for a day
The issue was with the background property used in jqplot options.
grid : {
background : 'transparent',
gridLineColor : '#c5c5c5'
}
I fixed it by replacing 'transparent' using 'rgba(255, 255, 255, 0.1)' in my code and it is working in all browsers including IE8. The same thing can be achieved by using background:url('blank.gif')
I got help from the following links
Highcharts chart option backgroundColor:'transparent' showing black on IE 8
IE CSS bug background color transparent behaves differently to background-color