I am currently trying to create a basic heat timer function.I have six switches per day with hour, minutes and temperature. My knowledge is very limited and I am hacking and fudging things a lot from this site to help me move along.
The most basic way for me to create something with my limited programming knowledge is to use Jquery Mobile Select Widget.
I created it all via html successfully but my code was huge, with 24 hours in a day, Minutes are at 5 min intervals giving 12 minute options, and 35 temperature range options.
Once I had it working, I looked around for ways to then reduce the code size and repeat via JavaScript.
I found this http://jsfiddle.net/qsafmw5g/1/ which was excellent and helped me to realise how to load the data multiple times.
var data = [{"chapterId":1,"chapterName":"First"},{"chapterId":2,"chapterName":"Second"}];
$(data).each(function() {
var option = $('<option />');
option.attr('value', this.chapterId ).text(this.chapterName );
$('#comboChapters').append(option);
});
$('#comboChapters').selectmenu('refresh', true);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<select name="comboChapters" id="comboChapters" data-native-menu="false">
</select>
I have since created my own code from this (still crude) but now my software is only loading the values in to the last switch (number 6) and leaving the other five switches blank.
I have tried to reduce my code to just show Mondays bank of six switches and remove my other things.
JSFiddle Here https://jsfiddle.net/adonegan/3yx2p7rf/
// Data Setup for Heater Controls
var hour_data = [{
"optionId": 0,
"optionValue": "00"
}, {
"optionId": 1,
"optionValue": "01"
}, {
"optionId": 2,
"optionValue": "02"
}, {
"optionId": 3,
"optionValue": "03"
}, {
"optionId": 4,
"optionValue": "04"
}, {
"optionId": 5,
"optionValue": "05"
}, {
"optionId": 6,
"optionValue": "06"
}, {
"optionId": 7,
"optionValue": "07"
}, {
"optionId": 8,
"optionValue": "08"
}, {
"optionId": 9,
"optionValue": "09"
}, {
"optionId": 10,
"optionValue": "10"
}, {
"optionId": 11,
"optionValue": "11"
}, {
"optionId": 12,
"optionValue": "12"
}, {
"optionId": 13,
"optionValue": "13"
}, {
"optionId": 14,
"optionValue": "14"
}, {
"optionId": 15,
"optionValue": "15"
}, {
"optionId": 16,
"optionValue": "16"
}, {
"optionId": 17,
"optionValue": "17"
}, {
"optionId": 18,
"optionValue": "18"
}, {
"optionId": 19,
"optionValue": "19"
}, {
"optionId": 20,
"optionValue": "21"
}, {
"optionId": 22,
"optionValue": "22"
}, {
"optionId": 23,
"optionValue": "23"
}];
var min_data = [{
"optionId": 0,
"optionValue": "00"
}, {
"optionId": 1,
"optionValue": "05"
}, {
"optionId": 2,
"optionValue": "10"
}, {
"optionId": 3,
"optionValue": "15"
}, {
"optionId": 4,
"optionValue": "20"
}, {
"optionId": 5,
"optionValue": "25"
}, {
"optionId": 6,
"optionValue": "30"
}, {
"optionId": 7,
"optionValue": "35"
}, {
"optionId": 8,
"optionValue": "40"
}, {
"optionId": 9,
"optionValue": "45"
}, {
"optionId": 10,
"optionValue": "50"
}, {
"optionId": 11,
"optionValue": "55"
}];
var temp_data = [{
"optionId": 0,
"optionValue": "0°c"
}, {
"optionId": 1,
"optionValue": "1°c"
}, {
"optionId": 2,
"optionValue": "2°c"
}, {
"optionId": 3,
"optionValue": "3°c"
}, {
"optionId": 4,
"optionValue": "4°c"
}, {
"optionId": 5,
"optionValue": "5°c"
}, {
"optionId": 6,
"optionValue": "6°c"
}, {
"optionId": 7,
"optionValue": "7°c"
}, {
"optionId": 8,
"optionValue": "8°c"
}, {
"optionId": 9,
"optionValue": "9°c"
}, {
"optionId": 10,
"optionValue": "10°c"
}, {
"optionId": 11,
"optionValue": "11°c"
}, {
"optionId": 12,
"optionValue": "12°c"
}, {
"optionId": 13,
"optionValue": "13°c"
}, {
"optionId": 14,
"optionValue": "14°c"
}, {
"optionId": 15,
"optionValue": "15°c"
}, {
"optionId": 16,
"optionValue": "16°c"
}, {
"optionId": 17,
"optionValue": "17°c"
}, {
"optionId": 18,
"optionValue": "18°c"
}, {
"optionId": 19,
"optionValue": "19°c"
}, {
"optionId": 20,
"optionValue": "21°c"
}, {
"optionId": 22,
"optionValue": "22°c"
}, {
"optionId": 23,
"optionValue": "23°c"
}];
$(hour_data).each(function() {
var option = $('<option />');
option.attr('value', this.optionId).text(this.optionValue),
$('#mon_hour_timer_one').append(option);
$('#mon_hour_timer_two').append(option);
$('#mon_hour_timer_three').append(option);
$('#mon_hour_timer_four').append(option);
$('#mon_hour_timer_five').append(option);
$('#mon_hour_timer_six').append(option);
});
$(min_data).each(function() {
var option = $('<option />');
option.attr('value', this.optionId).text(this.optionValue);
$('#mon_min_timer_one').append(option);
$('#mon_min_timer_two').append(option);
$('#mon_min_timer_three').append(option);
$('#mon_min_timer_four').append(option);
$('#mon_min_timer_five').append(option);
$('#mon_min_timer_six').append(option);
});
$(temp_data).each(function() {
var option = $('<option />');
option.attr('value', this.optionId).text(this.optionValue);
$('#mon_temp_range_one').append(option);
$('#mon_temp_range_two').append(option);
$('#mon_temp_range_three').append(option);
$('#mon_temp_range_four').append(option);
$('#mon_temp_range_five').append(option);
$('#mon_temp_range_six').append(option);
});
$('#mon_hour_timer_one').selectmenu('refresh', true);
$('#mon_hour_timer_two').selectmenu('refresh', true);
$('#mon_hour_timer_three').selectmenu('refresh', true);
$('#mon_hour_timer_four').selectmenu('refresh', true);
$('#mon_hour_timer_five').selectmenu('refresh', true);
$('#mon_hour_timer_six').selectmenu('refresh', true);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<!-- Heating Controls & Settings Page -->
<div id="heating" data-role="page">
<div data-role="content">
<div class="ui-field-contain">
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>Switch1:</legend>
<select name="mon_hour_timer_one" id="mon_hour_timer_one" data-mini="true"></select>
<select name="mon_min_timer_one" id="mon_min_timer_one" data-mini="true"></select>
<select name="mon_temp_range_one" id="mon_temp_range_one" data-mini="true"></select>
</fieldset>
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>Switch2:</legend>
<select name="mon_hour_timer_two" id="mon_hour_timer_two" data-mini="true"></select>
<select name="mon_min_timer_two" id="mon_min_timer_two" data-mini="true"></select>
<select name="mon_temp_range_two" id="mon_temp_range_two" data-mini="true"></select>
</fieldset>
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>Switch3:</legend>
<select name="mon_hour_timer_three" id="mon_hour_timer_three" data-mini="true"></select>
<select name="mon_min_timer_three" id="mon_min_timer_three" data-mini="true"></select>
<select name="mon_temp_range_three" id="mon_temp_range_three" data-mini="true"></select>
</fieldset>
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>Switch4:</legend>
<select name="mon_hour_timer_four" id="mon_hour_timer_four" data-mini="true"></select>
<select name="mon_min_timer_four" id="mon_min_timer_four" data-mini="true"></select>
<select name="mon_temp_range_four" id="mon_temp_range_four" data-mini="true"></select>
</fieldset>
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>Switch5:</legend>
<select name="mon_hour_timer_five" id="mon_hour_timer_five" data-mini="true"></select>
<select name="mon_min_timer_five" id="mon_min_timer_five" data-mini="true"></select>
<select name="mon_temp_range_five" id="mon_temp_range_five" data-mini="true"></select>
</fieldset>
<fieldset data-role="controlgroup" data-type="horizontal">
<legend>Switch6:</legend>
<select name="mon_hour_timer_six" id="mon_hour_timer_six" data-mini="true"></select>
<select name="mon_min_timer_six" id="mon_min_timer_six" data-mini="true"></select>
<select name="mon_temp_range_six" id="mon_temp_range_six" data-mini="true"></select>
</fieldset>
</div>
</div>
</div>
I have played with the first jsfiddle and realised that will also not allow me to load multiple selects from that one function.
Would somebody be kind enough to help show me how my function can be made to work to populate all of my lists.
Welcome to dynamic page creation!
As you can see, when you have to repeat something in your code you know it can be done in another way. Here's mine:
HTML
<div id="heating" data-role="page">
<div data-role="content">
<div class="ui-field-contain" id="content">
</div>
</div>
</div>
JavaScript
$(document).on("pageinit", "#heating", function(event)
{
var switch_number = 6;
var html = "";
for (var s = 0; s != switch_number; s++)
{
html += '<fieldset data-role="controlgroup" data-type="horizontal">';
html += '<legend>Switch ' + s + ':</legend>';
html += '<select id="mon_hour_timer_' + s + '" data-mini="true">';
for (var h = 0; h != 24; h++)
html += '<option value="' + h + '">' + h + '</option>';
html += '</select>';
html += '<select id="mon_min_timer_' + s + '" data-mini="true">';
for (var m = 0; m != 60; m += 5)
html += '<option value="' + m + '">' + m + '</option>';
html += '</select>';
html += '<select id="mon_temp_range_' + s + '" data-mini="true">';
for (var t = 0; t != 24; t++)
html += '<option value="' + t + '">' + t + ' ° C</option>';
html += '</select>';
html += '</fieldset>';
}
$("#content").html(html);
$("#content").trigger("create");
});
Related
enter image description here
suppose student has many projects and wants to upload that projects on web(system).
Now system wants to track or keep records of number of projects of that particular student.
Now system gives entire details about the projects of student(user)
like when project was uploaded, which day and month.
This data will be shown in the form of chart (like bubble chart).
There are three parameters
1) Y-axis
include week day's only. days will be constant. It'll not change irrespective of data (like input).
2) X-axis
include months only. months will be constant.It'll not change irrespective of data (like input).
3) Z-axis
include data from database.Data could be anything like number of projects(only digits).
Suppose I'm a student(user) and I upload project on Monday in the month of Jan.
Then on bubble chart it should display number of projects I have uploaded on which days of the week and month.
It is similar to GitHub chart where it gives all the details about the of user activities.
I have no idea from where to start.
I have tried various libraries for charts like chart.js,highchart.js....
I have tried this.
https://jsfiddle.net/h0Lm1jgz/
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Heat Map</title>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/heatmap.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
</head>
<body>
<div id="container" style="height: 400px; min-width: 310px; max-width: 800px; margin: 0 auto"></div>
<script>
Highcharts.chart('container',
{
chart: {
type: 'heatmap',
marginTop: 40,
marginBottom: 80,
plotBorderWidth: 1
},
title: {
text: 'Project Details'
},
xAxis: {
categories: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
},
yAxis: {
categories: ['Mon','Tue','Wed','Thur','Fri','Sat','Sun'],
title: null
},
colorAxis: {
min: 0,
minColor: '#FFFFFF',
maxColor: Highcharts.getOptions().colors[0]
},
legend: {
align: 'right',
layout: 'vertical',
margin: 0,
verticalAlign: 'top',
y: 25,
symbolHeight: 280
},
tooltip: {
formatter: function () {
return '<b>' + this.series.xAxis.categories[this.point.x] + ' ' +
this.point.value + '</b> projecys uploaded on <br><b>' + this.series.yAxis.categories[this.point.y] + '</b>';
}
},
series: [{
borderWidth: 1,
data: [
[0, 0, 10],
[0, 1, 19],
[0, 2, 8],
[0, 3, 24],
[0, 4, 67],
[1, 0, 92],
[1, 6, 58],
[1, 2, 78],
[1, 3, 117],
[1, 4, 48],
[2, 0, 35],
[2, 1, 15],
[2, 2, 123],
[2, 3, 64],
[2, 4, 52],
[3, 0, 72],
[3, 1, 132],
[3, 2, 114],
[3, 3, 19],
[3, 4, 16],
[4, 0, 38],
[4, 1, 5],
[4, 2, 8],
[4, 3, 117],
[4, 4, 115],
[5, 0, 88],
[5, 1, 32],
[5, 2, 12],
[5, 3, 6],
[5, 4, 120],
[6, 0, 13],
[6, 1, 44],
[6, 2, 88],
[6, 3, 98],
[6, 4, 96],
[7, 0, 31],
[7, 1, 1],
[7, 2, 82],
[7, 3, 32],
[7, 4, 30],
[8, 0, 85],
[8, 1, 97],
[8, 2, 123],
[8, 3, 64],
[10, 4, 84],
[9, 0, 47],
[9, 1, 114],
[9, 2, 31],
[9, 3, 48],
[11, 4, 91]],
dataLabels: {
enabled: true,
color: '#000000'
}
}]
});
</script>
</body>
</html>
code
<!-- highcharts library -->
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/heatmap.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div class="container">
<div class="card">
<div class="card-body">
<div id="heap_map_chart" style="height: 400px; min-width: 310px; max-width: 800px; margin: 0 auto"></div>
</div>
</div>
<div class="card border-success mb-3" style="max-width: 18rem;" id="moreInfo">
</div>
</div>
<script>
$(document).ready(function()
{
requestData();
function requestData()
{
$.ajax(
{
url: '/profile/heap_map_data',
type: 'GET',
success: function(response)
{
console.log(response);
var chart_data = [];
var count = 0;
for(var i = 0, len = response.length; i < len; i++)
{
date_value = response[i].event_start_date;
var d = new Date(date_value);
var year = d.getFullYear();
var month = d.getMonth();
var day = d.getDay();
var actualDay = day -1;
chart_data.push([month,actualDay,response[i].user_id]);
}
console.log("chart_data ==",chart_data);
Highcharts.chart('heap_map_chart',
{
chart: {
type: 'heatmap',
marginTop: 40,
marginBottom: 80,
plotBorderWidth: 1,
},
title: {
text: 'Project Details'
},
xAxis: {
categories: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
},
yAxis: {
categories: ['Mon','Tue','Wed','Thur','Fri','Sat','Sun'],
title: null
},
colorAxis: {
min: 0,
minColor: '#FFFFFF',
maxColor: Highcharts.getOptions().colors[0]
},
legend: {
align: 'right',
layout: 'vertical',
margin: 0,
verticalAlign: 'top',
y: 25,
symbolHeight: 280
},
tooltip: {
formatter: function ()
{
return + this.point.value + ' <b> project was uploaded on ' + this.series.xAxis.categories[this.point.x] + ' date, 2019' + '<br /> click to view more' ;
}
},
plotOptions:
{
series:
{
cursor: 'pointer',
point:
{
events:
{
click: function ()
{
var year = 2019;
var month = this.x;
var y_axis_day = this.y;
$.ajax(
{
url: '/profile/heap_map_event_details',
type: "POST",
data: {year:year,month:month},
success: function (response)
{
var $message_list= document.getElementById("moreInfo");
$message_list.innerHTML = '';
for(var i = 0, len = response.length; i < len; i++)
{
var date = new Date(response[i].event_start_date);
var day = date.getDay();
var actualDay = day -1;
actualDay = Number(actualDay)
if(y_axis_day == actualDay)
{
$message_list.innerHTML = $message_list.innerHTML + `<div class="card online_user" ><li class="list-group-item link-class" style="cursor: pointer;"> <div class="d-flex bd-highlight"> <div class="img_cont"><img src="../public/image/${response[i].e_imagepath}" class="rounded-circle user_img"><span class="online_icon offline"></span> </div><div class="user_info">${response[i].event_name}}<br/><small style="color:#F44336"><strong>${response[i].event_start_date} message</strong></small><br/><small>Last seen <small>${response[i].event_end_date}</small></small></div> </div> </li></div>`;
}
}
},
error : function(jqXHR, textStatus, errorThrown)
{
console.log('jqXHR:');
console.log(jqXHR);
console.log('textStatus:');
console.log(textStatus);
console.log('errorThrown:');
console.log(errorThrown);
alert(errorThrown);
}
});
}
}
}
}
},
series: [
{
data: chart_data,
borderWidth: 1,
dataLabels: {
enabled: true,
color: '#000000'
}
}]
});
},
error : function(jqXHR, textStatus, errorThrown)
{
console.log('jqXHR:');
console.log(jqXHR);
console.log('textStatus:');
console.log(textStatus);
console.log('errorThrown:');
console.log(errorThrown);
alert(errorThrown);
}
});
}
})
</script>
API
router.get('/profile/heap_map_data', function(req,res)
{
console.log("No. of time being called 1")
const user_id = req.session.user_id;
Posts.findAll()
.then((data)=>
{
res.send(data);
})
.catch((err)=>
{
res.send(err);
})
})
router.post('/profile/heap_map_event_details', function(req,res)
{
const year = Number(req.body.year);
var month = Number(req.body.month);
month = month + 1;
if(month < 10)
{
month = "0"+month;
}
Posts.findAll({where:{event_start_date:{[Op.endsWith]: '%' + "2019-"+month+"-" +'%'}}})
.then((data)=>
{
console.log(data);
res.send(data);
})
.catch((err)=>
{
res.send(err);
})
})
When I generate my Highchart chart it generates complete. The only thing that doesn't show up is the export option.
Can anybody figure out what I am doing wrong?
Do I need to specify extra CSS styling options of some sort or include another JS script to allow this to work? I can't really figure it out at the moment.
chart1 = new Highcharts.Chart({
"chart": {
"renderTo": "container",
"type": "column"
},
"title": {
"text": "Doorlooptijd exploten"
},
"subtitle": {
"text": "Databron: Digibieb"
},
"xAxis": {
"categories": {
"2": "> xx",
"1": "< xx",
"0": "< xx"
}
},
"yAxis": {
"min": 0,
"title": {
"text": "Aantallen"
}
},
"legend": {
"layout": "vertical",
"backgroundColor": "#FFFFFF",
"align": "left",
"verticalAlign": "top",
"x": 100,
"y": 100,
"floating": 0,
"shadow": 1
},
"exporting": {
"enabled": true
},
"credits": {
"enabled": false
},
"plotOptions": {
"column": {
"pointPadding": 0.2,
"borderWidth": 0
}
},
"series": [{
"name": "asd",
"data": [1, 1, 1]
}, {
"name": "asd2",
"data": [1, 1, 1]
}, {
"name": "asd3",
"data": [1, 1, 1]
}, {
"name": "asd4",
"data": [0, 0, 25]
}, {
"name": "asd5",
"data": [54, 19, 53]
}, {
"name": "asd6",
"data": [0, 0, 4]
}, {
"name": "asd8",
"data": [22, 4, 28]
}, {
"name": "asd7",
"data": [23, 40, 19]
}, {
"name": "asd9",
"data": [23, 13, 8]
}, {
"name": "asd10",
"data": [3, 0, 0]
}]
});
You need to load the exporting.js script like this after the main Highcharts script
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
Fiddle
I am trying to retrieve the selected node.
I have done:
s.graph.nodes()
but this command returns all the graph node?
Do you know how to do this?
You can create some lookup functions to find the node by its ID.
function lookupNodesByKeyValue(sigmaInstance, key, value) {
return sigmaInstance.graph.nodes().filter(node => node[key] === value);
}
function lookupNodeByKeyValue(sigmaInstance, key, value) {
return lookupNodesByKeyValue(sigmaInstance, key, value).pop();
}
function lookupNodeById(sigmaInstance, value) {
return lookupNodeByKeyValue(sigmaInstance, 'id', value);
}
var graphData = {
"nodes": [
{ "id": "n0", "label": "A node", "x": 0, "y": 0, "size": 3 },
{ "id": "n1", "label": "Another node", "x": 3, "y": 1, "size": 2 },
{ "id": "n2", "label": "And a last one", "x": 1, "y": 3, "size": 1 },
],
"edges": [
{ "id": "e0", "source": "n0", "target": "n1" },
{ "id": "e1", "source": "n1", "target": "n2" },
{ "id": "e2", "source": "n2", "target": "n0" },
]
};
// Initialize Sigma object
var s = new sigma({
graph: graphData,
container: 'sigma-container',
settings: { defaultNodeColor: '#ec5148' }
});
// Set initial zoom
s.cameras[0].goTo({ x: 1, y: 1, angle: 0, ratio: 2.0 });
console.log("Node 'n2' => " + lookupNodeById(s, "n2").label);
body {
background: #ddd;
}
.sigma-wrapper {
max-width: 240px;
background: #fff;
border: 2px solid #AAA;
margin: auto;
}
#sigma-container {
max-width: 240px;
height: 240px;
}
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/sigma.js/1.2.1/sigma.min.js"></script>
<div class="sigma-wrapper">
<div id="sigma-container"></div>
</div>
I have a basic column chart. With smaller data sets, the chart displays as it should. See this fiddle:
http://jsfiddle.net/hmg0y2a3/1/
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 600px; height: 400px; margin: 0 auto"></div>
Highcharts.chart('container', {
"chart": {
"type": "column"
},
"title": {
"text": "High Net Income"
},
"xAxis": {
"type": "datetime",
"tickInterval": 604800000,
"dateTimeLabelFormats": {
"millisecond": "%m/%d/%Y",
"second": "%m/%d/%Y",
"minute": "%m/%d/%Y",
"hour": "%m/%d/%Y",
"day": "%m/%d/%Y",
"week": "%m/%d/%Y",
"month": "%m/%d/%Y",
"year": "%m/%d/%Y"
},
"labels": {
"rotation": -45
}
},
"yAxis": {
"min": 0,
"title": {
"text": "Audience Reach"
}
},
"plotOptions": {
"borderWidth": 0,
"pointPadding": 0.2
},
"legend": {
"enabled": false
},
"credits": {
"enabled": false
},
"series": [{
"name": "Distribution Count",
"data": [
[1504342376000, 6403],
[1504423639000, 1086],
[1504510033000, 1089]
]
}, {
"name": "Unique VELO Count",
"data": [
[1504342376000, 2973],
[1504423639000, 597],
[1504510033000, 599]
]
}]
});
I like that it's displaying each series side by side for a specific date.
However, when the data sets get larger, I get skinny little stacked 1px columns and I don't like it one bit, but I don't know what I need to do to keep the columns side by side, not stacked, and have a width that is usable. See this fiddle:
http://jsfiddle.net/hmg0y2a3/
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto">
Highcharts.chart('container', {
"chart": {
"type": "column"
},
"title": {
"text": "High Net Income"
},
"xAxis": {
"type": "datetime",
"tickInterval": 604800000,
"dateTimeLabelFormats": {
"millisecond": "%m/%d/%Y",
"second": "%m/%d/%Y",
"minute": "%m/%d/%Y",
"hour": "%m/%d/%Y",
"day": "%m/%d/%Y",
"week": "%m/%d/%Y",
"month": "%m/%d/%Y",
"year": "%m/%d/%Y"
},
"labels": {
"rotation": -45
}
},
"yAxis": {
"min": 0,
"title": {
"text": "Audience Reach"
}
},
"plotOptions": {
"borderWidth": 0,
"pointPadding": 0.2
},
"legend": {
"enabled": false
},
"credits": {
"enabled": false
},
"series": [{
"name": "Distribution Count",
"data": [
[1504342376000, 6403],
[1504423639000, 1086],
[1504510033000, 1089],
[1504597165000, 1103],
[1504683776000, 1099],
[1504770376000, 1210],
[1504858167000, 1242],
[1504942932000, 1224],
[1505027910000, 1227],
[1505114658000, 1229],
[1505201998000, 1214],
[1505289935000, 1110],
[1505289941000, 1110],
[1505418941000, 930],
[1505419065000, 930]
]
}, {
"name": "Unique VELO Count",
"data": [
[1504342376000, 2973],
[1504423639000, 597],
[1504510033000, 599],
[1504597165000, 598],
[1504683776000, 590],
[1504770376000, 637],
[1504858167000, 636],
[1504942932000, 625],
[1505027910000, 628],
[1505114658000, 639],
[1505201998000, 638],
[1505289935000, 617],
[1505289941000, 617],
[1505418941000, 557],
[1505419065000, 557]
]
}]
});
Try to set static pointWidth: for series object in plotOptions, like below:
"plotOptions": {
"series": {
"pointWidth": 15
},
},
API Reference: http://api.highcharts.com/highcharts/series%3Cbar%3E.pointWidth
Live working: http://jsfiddle.net/daniel_s/qetr9p0p/
Best regards!
The dates in the series were the issue. If I mutate the dates by setting to UTC and truncating to the day, the bars will not stack and they will not be 1px wide if there is over 12 points of data:
time_series = broadcast_data.time_series_data[b];
date = new Date(time_series.broadcast_dt);
date = Date.UTC(date.getFullYear(),date.getMonth(),date.getDate());
as a noob in groovy/grails , i'd like to learn how to make or use a plugin for charts .
i tried zing chart , tried the exemples , but nothing as a result , sometimes i have the area of the chart and nothing else.
So to display the chart i used zing :
<zing:chart type="area" width="700" height="350" container="acceptToConvertChart" data="${data}" xLabels="${labels}" effect="4" />
And for the script :
<script> def labels = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
def data = [
'Visitors': [100, 300, 200, 240, 500, 100, 80],
'Purchases': [30, 50, 12, 20, 55, 20, 10]
]</script>
when i use it , nothing hapen , the area just disapear
for include :
<zing:include/>
and it's underlined in yellow like every thing that's in relation with zing chart and when i hover it ,it says that zing is unknown , so what i should do?
Please help .
When you explain ,just know that i am not java developper .
Thank you in advance.
you need something like this in your HTML:
<head>
<script src= "https://cdn.zingchart.com/zingchart.min.js"></script>
<script> zingchart.MODULESDIR = "https://cdn.zingchart.com/modules/";
ZC.LICENSE =["569d52cefae586f634c54f86dc99e6a9","ee6b7db5b51705a13dc2339db3edaf6d"]; </script>
</head>
<body>
Here is your ZingChart:
<div id='myChart'></div>
</body>
and something like this javascript:
zingchart.THEME = "classic";
var myConfig =
{
"type": "area",
"background-color": "#fff",
"stacked": false,
"title": {
"text": "Visitors & Sales",
"background-color": "#fff",
"font-color": "#05636c",
"adjust-layout":true
},
"tooltip": {
"visible": false
},
"plot": {
"aspect": "stepped",
"line-width": "1px",
"marker": {
"visible": false
},
"hover-state": {
"visible": false
},
"shadow": false
},
"plotarea": {
"margin": "dynamic"
},
"scale-x": {
"values": [
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
],
"line-color": "#000",
"line-width": "1px",
"guide": {
"visible": false
},
"tick": {
"line-color": "#000",
"line-width": "1px"
},
"label": {
"text": "Days of the Week",
"font-size": "14px",
"font-family": "helvetica",
"font-weight": "normal",
"offset-y": "5%",
"font-color":"#05636c"
},
"item": {
"font-color": "#05636c",
"font-weight": "normal",
"font-family": "helvetica",
"font-size": "12px",
"offset-y": "3%"
}
},
"scale-y": {
"values": "0:600:50",
"line-color": "#000",
"line-width": "1px",
"tick": {
"line-color": "#000",
"line-width": "1px"
},
"label": {
"text": "Volume",
"font-size": "14px",
"font-family": "helvetica",
"font-weight": "normal",
"font-color":"#05636c"
},
"item": {
"font-color": "#05636c",
"font-weight": "normal",
"font-family": "helvetica",
"font-size": "12px",
"offset-x": "-5%"
},
"guide": {
"visible": false
}
},
"crosshair-x": {
"line-color": "#ffffff",
"marker": {
"visible": false
},
"plot-label": {
"text": "<strong>%v</strong> %t",
"shadow": 0,
"font-size": "12px",
"font-color": "#05636c",
"font-family": "helvetica",
"border-width": "1px",
"border-color": "#05636c",
"background-color": "#ffffff",
"text-align": "center"
},
"scale-label": {
"font-size": "12px",
"font-color": "#000000",
"font-family": "helvetica",
"background-color": "#ffffff",
"offset-y": "3%"
}
},
"series": [
{
"values": [
30, 50, 12, 20, 55, 20, 10
]
},
{
"values": [
100, 300, 200, 240, 500, 100, 80]
}
]
};
zingchart.render({
id : 'myChart',
data : myConfig,
height: 300,
width: 500
});
please take a look at this working example
note that you will probably have for populate the section
"values": [
30, 50, 12, 20, 55, 20, 10
]
with your actual values coming from your grails controller