How to show daterangepicker all time? - datepicker

I need to show daterangepicker all time - not a popup like defualt. It is possible?

my solution is
$(function() {
var start = moment('1970-01-01');
var end = moment();
function cb(start, end) {
if(start.format('DD/MM/YYYY') == '01/01/1970') {
$('#reportrange span').html('All time');
}else {
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
}
}
$('#reportrange').daterangepicker({
startDate: start,
endDate: end,
ranges: {
'All time': [moment('1970-01-01'), moment()],
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
}
}, cb);
cb(start, end);
});

ranges: {
'Today': [moment(), moment()],
'This Week': [moment().startOf('week'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'All Time': [null, null]
}

ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
'This Year': [moment().startOf('year'), moment()],
'Last Year': [moment().subtract(1, 'year').add(1,'day'), moment()],
'All Time': ['01/01/2018', moment()],
}

You can do something like -
ranges: {
'All time':[null,null],
....
Edit your
daterangepicker.js
in line 1532 as
updateElement: function() {
if (this.element.is('input') && this.autoUpdateInput) {
var newValue = this.startDate.format(this.locale.format);
if (!this.singleDatePicker) {
newValue += this.locale.separator + this.endDate.format(this.locale.format);
}
if(newValue == "Invalid date - Invalid date"){
this.element.val("All Time").trigger('change');
}
else if (newValue !== this.element.val()) {
this.element.val(newValue).trigger('change');
}
}
}
If have any doubts please let me know.

Related

Change disabledHours during time of current day when other select option is changed

The task is a booking form for a restaurant. The disabled time is the same in every Restaurant except in one of them. All Restaurants can be chosen via select options. The select field already has a js function called show for different functions.
I have created js to set the time between 17 and and 23 to be disabled when the Restaurant has been Picked beforehand.
However I cannot get the picker to reload on change. I've tried it with function show() and $('#Restaurant').change(function(). I realize I am not telling the picker to change the values, but I'm not sure how.
<select name="Restaurant" id="Restaurant" onchange="show()" required data-msg-required="Please choose the restaurant">
<?php if (empty($_GET['Restaurant'])){echo '<option disabled selected
value="">Choose restaurant</option>';}?>
<?php booking(); ?>
</select>
<script>
$(function () {
$('#DatumZeit').datetimepicker({
locale: 'en',
minDate: moment().add(2, 'hours'),
disabledHours: disabledtime,
format: 'DD.MM.YYYY HH:mm',
showClose: true,
icons: {
close: 'OK'
},
widgetPositioning: {
horizontal: 'auto',
vertical: 'bottom'
},
});
});
function show(){
if(document.getElementById('Restaurant').value == "Düsseldorf") {
var currenttime = moment();
var timestart = moment().startOf('day').hour(10).add(7, 'hours');
var timeend = moment().startOf('day').hour(10).add(13, 'hours');
console.log(timestart);
console.log(timeend);
if (currenttime.isBetween(timestart, timeend)) {
console.log('is between');
var disabledtime= [10,9,8,7,6,5,4,3,2,1,00,24,23,17,18,19,20,21,22];
} else {
console.log('is not between');
var disabledtime= [10,9,8,7,6,5,4,3,2,1,00,24,23];
}
};
}
</script>
Maybe it can help someone else:
Basically I used $('#DatumZeit').data("DateTimePicker").disabledHours.
function show(){
if(document.getElementById('Restaurant').value == "Düsseldorf") {
var currenttime = moment();
var timestart = moment().startOf('day').hour(10).add(7, 'hours');
var timeend = moment().startOf('day').hour(10).add(13, 'hours');
if (currenttime.isBetween(timestart, timeend)) {
$('#DatumZeit').data("DateTimePicker").disabledHours([
10,9,8,7,6,5,4,3,2,1,00,24,23,17,18,19,20,21,22
]);
console.log('is between');
} else {
$('#DatumZeit').data("DateTimePicker").disabledHours([
10,9,8,7,6,5,4,3,2,1,00,24,23
]);
console.log('is not between');
}
};
if(document.getElementById('Restaurant').value != "Düsseldorf") {
$('#DatumZeit').data("DateTimePicker").disabledHours([
10,9,8,7,6,5,4,3,2,1,00,24,23
]);
}
}
I actually have a better version for my own needs that might work for other people as well.
function show(){
if(document.getElementById('Restaurant').value == "Düsseldorf") {
var myDate = new Date();
var currenttime = moment(myDate);
var timestart = moment().startOf('day').hour(17);
var timeend = moment().startOf('day').hour(23);
if (currenttime.isBetween(timestart, timeend)) {
$('#DatumZeit').data("DateTimePicker").date(moment().add(1, 'days')).disabledHours(
[0,1,2,3,4,5,6,7,8,9,10,23,24]
)
}
else {
$('#DatumZeit').data("DateTimePicker").date(moment(myDate)).disabledHours(
[0,1,2,3,4,5,6,7,8,9,10,23,24]
)
}
} else {
$('#DatumZeit').data("DateTimePicker").date(moment().add(2, 'hours')).enabledHours(
[11, 12 ,13 ,14 ,15, 17,16, 18, 19, 20, 21, 22]
)
}
}

ChartJS display tooltip at maximum/minimum value

I would like to display a tooltip at the top datapoint of a dataset in my chart. That way the user sees a value for the maximum and the minimum datapoints. That helps understanding the graph immediately.
It should look somewhat like this:
I have created a JSFiddle with the code over here: https://jsfiddle.net/h2zscw6s/1/
For reference please also find my chart config below. It's in coffeescript but I don't mind if you post answers in plain javascript.
dataWeather = [
{
label: 'January'
value: 22
}
{
label: 'February'
value: 23
}
{
label: 'March'
value: 24
}
{
label: 'May'
value: 26
}
{
label: 'June'
value: 30
}
{
label: 'July'
value: 34
}
{
label: 'August'
value: 38
}
{
label: 'September'
value: 36
}
{
label: 'October'
value: 30
}
{
label: 'November'
value: 28
}
{
label: 'December'
value: 26
}
]
dataPrices = [
{
label: 'January'
value: 5000
}
{
label: 'February'
value: 4500
}
{
label: 'March'
value: 4450
}
{
label: 'May'
value: 3700
}
{
label: 'June'
value: 3700
}
{
label: 'July'
value: 3000
}
{
label: 'August'
value: 2900
}
{
label: 'September'
value: 3100
}
{
label: 'October'
value: 3200
}
{
label: 'November'
value: 3900
}
{
label: 'December'
value: 5500
}
]
class WeatherPriceChart
setWeatherData: (weatherData)->
#weatherData = weatherData
setPriceData: (priceData)->
#priceData = priceData
minPrice: ->
_.sortBy(#priceData, (w)-> w.value)[0]?.value || 0
maxPrice: ->
_.sortBy(#priceData, (w)-> -w.value)[0]?.value || 0
minTemperature: ->
_.sortBy(#weatherData, (w)-> w.value)[0]?.value || 0
maxTemperature: ->
_.sortBy(#weatherData, (w)-> -w.value)[0]?.value || 0
isMaxTemperature: (value)->
#maxTemperature() == value
isMinTemperature: (value)->
#minTemperature() == value
isMaxPrice: (value)->
#maxPrice() == value
isMinPrice: (value)->
#minPrice() == value
getLabels: ->
_.map(#weatherData, (w)-> w.label)
getWeatherDataPoints: ->
_.map(#weatherData, (w)-> w.value)
getPriceDataPoints: ->
_.map(#priceData, (w)-> w.value)
getNormalizedWeatherDataPoints: ->
data = #weatherData
min = -10
max = 60
_.map data, (d)->
norm = d.value + (min * -1)
maxed = max + (min * -1)
norm / maxed * 100
getNormalizedPriceDataPoints: ->
data = #priceData
max = #maxPrice() * 2.5
_.map data, (d)->
d.value / max * 100
chart = new WeatherPriceChart
chart.setWeatherData(dataWeather)
chart.setPriceData(dataPrices)
ctx = document.getElementById('myChart')
myChart = new Chart(ctx,
type: 'line',
data:
xLabels: chart.getLabels(),
yLabels: [""],
datasets: [
{
label: 'Temperature'
data: chart.getWeatherDataPoints()
backgroundColor: 'rgba(239,88,42,0.2)'
borderColor: 'rgba(239,88,42,0.5)'
borderWidth: 1
},
{
label: 'Prices'
data: chart.getNormalizedPriceDataPoints()
backgroundColor: 'rgba(22,195,245,0.2)'
borderColor:'rgba(22,195,245,0.4)'
borderWidth: 1
}
]
options:
scales:
yAxes: [
{
ticks: {
beginAtZero: false,
display: false
},
display: false
},
]
legend:
display: false
)
I found an answer to this option and posted it in the linked jsfiddle. I had to add a plugin that would display all labels. That one then dynamically decided whether to show this tooltip or not.
Chart.pluginService.register
beforeRender: (chart) ->
if chart.config.options.showAllTooltips
# create an array of tooltips
# we can't use the chart tooltip because there is only one tooltip per chart
chart.pluginTooltips = []
chart.config.data.datasets.forEach (dataset, i) ->
min = _.min(dataset.data, (d)-> d)
max = _.max(dataset.data, (d)-> d)
minShown = false
maxShown = false
chart.getDatasetMeta(i).data.forEach (sector, j) ->
isMax = dataset.data[j] == max
isMin = dataset.data[j] == min
# only show the min and the max once. we can have duplicates min/maxes
if isMax && !maxShown || isMin && !minShown
minShown = true if isMin
maxShown = true if isMax
tooltip = new (Chart.Tooltip)({
_chart: chart.chart
_chartInstance: chart
_data: chart.data
_options: chart.options.tooltips
_active: [ sector ]
}, chart)
chart.pluginTooltips.push(tooltip)
return
return
# turn off normal tooltips
chart.options.tooltips.enabled = false
return
afterDraw: (chart, easing) ->
if chart.config.options.showAllTooltips
# we don't want the permanent tooltips to animate, so don't do anything till the animation runs atleast once
if !chart.allTooltipsOnce
if easing != 1
return
chart.allTooltipsOnce = true
# turn on tooltips
chart.options.tooltips.enabled = true
Chart.helpers.each chart.pluginTooltips, (tooltip) ->
tooltip.initialize()
tooltip.update()
# we don't actually need this since we are not animating tooltips
tooltip.pivot()
tooltip.transition(easing).draw()
return
chart.options.tooltips.enabled = false
return

Not able to view more than 4 dimensions in QlikSense

I have included Sankey JS as external plugin to Qlik sense. I have added total of 5 dimensions and 1 measure to my chart. But when I view the chart, I'm able to see only 4 dimensions and the last dimension replaces the previous dimensions. For Ex:
Dim1, Dim2, Dim3, Dim4 - It looks fine when I include only 4 dimensions.
Dim1, Dim2, Dim3, Dim5 - If I add 5th dimension to the chart.
The problem is when I view QDataPages[0] size object, I'm able to see only values for 4 dimensions under the qMatrix object. How do I crease the size or see more dimensions. Your help is really appreciated.
requirejs.config({
shim : {
"extensions/SenseSankey/sankeymore" : {
"deps" : ["extensions/SenseSankey/d3.min"]
}
}
});
//define(["jquery", "text!./style.css","extensions/SenseSankey/sankeymore"], function($, cssContent) {
define(["jquery", "text!./style.css","core.utils/theme","extensions/SenseSankey/md5.min","extensions/SenseSankey/sankeymore"], function($, cssContent, Theme, md5) {
'use strict';
$( "<style>" ).html( cssContent ).appendTo( "head" );
return {
initialProperties: {
version: 1.3,
qHyperCubeDef: {
qDimensions: [],
qMeasures: [],
qInitialDataFetch: [{
qWidth: 5,
qHeight: 2000
}]
},
selectionMode: "QUICK"
},
definition: {
type: "items",
component: "accordion",
items: {
dimensions: {
uses: "dimensions",
min: 2,
max: 7
},
measures: {
uses: "measures",
min: 1,
max: 1
},
//sorting: {
// uses: "sorting"
//},
settings: {
uses: "settings",
type: "items",
items : {
SankeyGroup:{
label : "Sankey Settings",
type:"items",
items : {
flowMax:{
type: "integer",
label: "Flow max (10 to 2000)",
ref: "flowMax (max is 2000)",
defaultValue: 500,
min : 10,
max : 2000
},
flowChoice:{
ref:"flowChoice",
type:"integer",
component:"dropdown",
label:"Color Flow",
options:
[
{
value:1,
label:"Qlik Color"
},
{
value:2,
label:"Custom Color"
}
],
defaultValue: 1
},
flowColor:{
type: "string",
component: "color-picker",
//component: "ColorsPickerComponent",
expression: "optional",
label: "Color Flow if no Hex Color",
ref: "flowColor",
defaultValue: 2,
show: function(layout) { return layout.flowChoice == 1 }
},
flowColorCustom:{
type: "string",
label: "Custom Hex Color for Flow",
ref: "flowColorCustom",
defaultValue: "#999999",
show: function(layout) { return layout.flowChoice == 2 }
},
Separateur:{
ref: "displaySeparateur",
type: "string",
component: "dropdown",
label: "Pop-up Separator",
options:
[
{
value:" - ",
label:"-"
},
{
value:" <-> ",
label:"<->"
},
{
value: " → ",
label: " → "
},
],
defaultValue: " - "
},
Format:{
ref: "displayFormat",
type: "string",
component: "dropdown",
label: "Pop-up Format",
options:
[
{
value: "Number2",
label: "1000.12"
},
{
value: "Number1",
label: "1000.1"
},
{
value: "Number",
label: "1000"
},
{
value: "Money2",
label: "1000.12 €"
},
{
value: "Money1",
label: "1000.1 €"
},
{
value: "Money",
label: "1000 €"
},
],
defaultValue: "Number"
},
Palette:{
ref:"displayPalette",
type:"string",
component: "dropdown",
label : "Palette",
options:
[
{
value: "D3-20",
label: "Ordinal Palette 20 colors"
},
{
value: "D3-20c",
label: "Blue-Grey Palette 20 colors"
},
{
value: "D3-20b",
label: "Blue-Purple Palette 20 colors"
},
{
value: "20",
label: "Palette 20 colors"
},
{
value: "20a",
label: "Other Palette 20 colors"
},
{
value: "20b",
label: "Spectral 14 color Palette" // Added by Anand.V.N for Spectral Color Palette
},
],
defaultValue: "D3-20"
},
colorPersistence:{
ref: "colorPersistence",
component: "switch",
type: "boolean",
translation: "Persistence",
defaultValue: false,
trueOption: {
value: true,
translation: "properties.on"
},
falseOption: {
value: false,
translation: "properties.off"
},
show: true
}
}
}
}
}
}
},
snapshot: {
canTakeSnapshot: true
},
paint: function ( $element, layout ) {
// Fonction format pop-up
function formatMoney(n, c, d, t, m, l){
var c = isNaN(c = Math.abs(c)) ? 2 : c,
d = d == undefined ? "." : d,
t = t == undefined ? "," : t,
s = n < 0 ? "-" : "",
i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return l + ' \n ' + s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "")+ m;
};
// Persistent color function
var hashScale = d3.scale.linear().domain([1, 4294967295]).range([ 0, 19.9999 ]);
function hashL(str) {
var hashL = 5381,
i = str.length
while(i)
hashL = (hashL * 33) ^ str.charCodeAt(--i)
//hash = md5(str)
return hashL >>> 0;
}
function getColorForNode(strValue) {
if (colorPersistence===true) {
return colours[parseInt(Math.floor(hashScale(hashL(md5(strValue)))))];
} else
{
return colours[Math.floor(Math.random() * (19))];
}
}
var _this = this;
var maxHeight = layout.flowMax;
var displayFormat = layout.displayFormat;
var displaySeparateur = layout.displaySeparateur;
var displayPalette = layout.displayPalette;
var colorPersistence = layout.colorPersistence;
if (displayPalette === "D3-20") {
var colours = ['#1f77b4','#aec7e8','#ff7f0e','#ffbb78','#2ca02c','#98df8a','#d62728','#ff9896','#9467bd','#c5b0d5','#8c564b',
'#c49c94','#e377c2','#f7b6d2','#7f7f7f','#c7c7c7','#bcbd22','#dbdb8d','#17becf','#9edae5' ];
}
else if (displayPalette === "D3-20b") {
var colours = ['#393b79','#5254a3','#6b6ecf','#9c9ede','#637939','#8ca252','#b5cf6b','#cedb9c','#8c6d31','#bd9e39',
'#e7ba52','#e7cb94','#843c39','#ad494a','#d6616b','#e7969c','#7b4173','#a55194','#ce6dbd','#de9ed6'];
}
else if (displayPalette === "D3-20c") {
var colours = ['#3182bd','#6baed6', '#9ecae1','#c6dbef','#e6550d','#fd8d3c','#fdae6b','#fdd0a2','#31a354',
'#74c476','#a1d99b','#c7e9c0','#756bb1','#9e9ac8','#bcbddc','#dadaeb','#636363','#969696','#bdbdbd','#d9d9d9' ];
}
else if (displayPalette === "20") {
var colours = [ '#1abc9c','#7f8c8d','#2ecc71','#bdc3c7','#3498db','#c0392b','#9b59b6','#d35400','#34495e','#f39c12',
'#16a085','#95a5a6','#27ae60','#ecf0f1','#2980b9','#e74c3c','#8e44ad','#e67e22','#2c3e50','#f1c40f' ];
}
else if (displayPalette === "20a") {
var colours = [ '#023FA5','#7D87B9','#BEC1D4','#D6BCC0','#BB7784','#FFFFFF','#4A6FE3','#8595E1','#B5BBE3','#E6AFB9',
'#E07B91','#D33F6A','#11C638','#8DD593','#C6DEC7','#EAD3C6','#F0B98D','#EF9708','#0FCFC0','#9CDED6'];
}
else if (displayPalette === "20b") { // Added by Anand.V.N for Spectral Color Palette
var colours = [ '#F46D43','#E78162','#FDAE61','#F0B880','#FEE08B','#F1CA5F','#E6F598','#D4E86D','#ABDDA4','#85D07B',
'#66C2A5','#44B591','#3288BD','#5E4FA2','#D9D9D9','#BFBFBF','#A6A6A6','#7F7F7F','#595959','#9CDED6'];
}
var flowColor = (layout.flowChoice == 2) ? layout.flowColorCustom : Theme.palette[layout.flowColor];
var qData = layout.qHyperCube.qDataPages[0];
// create a new array that contains the dimension labels
var qDim = layout.qHyperCube.qDimensionInfo.map(function(d) {
return d.qFallbackTitle;
});
console.log(layout.qHyperCube);
var divName = layout.qInfo.qId;
var qMatrix = qData.qMatrix.sort();
var source = qMatrix.map(function(d) {
var path = "";
var sep = "";
for (var i = 0; i < d.length - 1; i++) {
path += sep + (d[i].qText.replace('|', ' ')) + '|' + (d[i].qElemNumber);
sep = ",";
}
return {
//"Path":d[0].qText,
"Path": path,
"Frequency": d[d.length - 1].qNum
}
});
var id = "sk_"+ layout.qInfo.qId;
if (document.getElementById(id)) {
$("#" + id).empty();
}
else {
$element.append($('<div />').attr("id", id));
}
$("#" + id).width($element.width()).height($element.height());
var sLinks = [];
var endArr = [];
var catArray = [];
//********Creates Duplicate IDs*************
// $element.attr("id",id)
//******************************************
//var td = _this.Data;
var sNodes = [];
var jNodes = [];
var rev = 0; //permet de pivoter les dimensions
source=source.slice(0,maxHeight);
//source foreach
source.forEach(function(d) {
//var row = d;
var path = d.Path;
var val = parseFloat(d.Frequency);
if(val > 0) {
var tArr = path.split(",",4);
//tArr.sort();
if (rev == "1") {
tArr.reverse();
}
if (tArr.length > 1) {
$.each(tArr, function(i) {
if(tArr.length === (i + 1)){
tArr[i] = this.toString().trim() + "~end";
}else{
tArr[i] = this.toString().trim() + "~" + i;
}
});
$.each(tArr, function(i) {
if ($.inArray(this.toString().trim(), sNodes) === -1) {
sNodes.push(this.toString().trim());
}
});
}
}
});
sNodes.forEach(function(d) {
jNodes.push({
name: d.toString()
})
});
//source foreach
source.forEach(function(d) {
//var row = d;
var path = d.Path
var val = parseFloat(d.Frequency);
if(val > 0) {
var tArr = path.split(",");
if (rev == "1") {
tArr.reverse();
}
if (tArr.length > 1) {
$.each(tArr, function(i) {
if(tArr.length === (i + 1)){
tArr[i] = this.toString().trim() + "~end";
}else{
tArr[i] = this.toString().trim() + "~" + i;
}
});
$.each(tArr, function(i) {
var tFlag = "no";
if ((i + 1) != tArr.length) {
var cS = $.inArray(this.toString().trim(), sNodes);
var cT = $.inArray(tArr[i + 1].toString().trim(), sNodes);
$.each(sLinks, function(i, v) {
if ((v.source === cS) && (v.target === cT)) {
tFlag = "yes";
v.value = v.value + val;
}
});
if (tFlag == "no") {
sLinks.push({
"source" : cS,
"target" : cT,
"value" : val
});
}
}
});
}
}
});
var margin = {
top : 1,
right : 1,
bottom : 0,
left : 1
}, width = $element.width(), height = $element.height();
// Added svgHeader class for Scrollbars by Anand.V.N
var svg = d3.select("#sk_" + divName).attr("class","svgHeader").append("svg").attr("width", width + margin.left + margin.right).attr("height", height + margin.top + margin.bottom).append("g").attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var sankey = d3.sankey().nodeWidth(15).nodePadding(10).size([width -10 , height-10]);
var path = sankey.link();
sankey.nodes(jNodes).links(sLinks).layout(32);
var link = svg.append("g").selectAll(".link").data(sLinks).enter().append("path").attr("class", "link").attr("d", path).style("stroke-width",function(d) {
return Math.max(1, d.dy);
}).sort(function(a, b) {
return b.dy - a.dy;
});
//Color of Flow
link.style('stroke', flowColor);
// affiche la valeur sur le flux en popup
link.append("title").text(function(d) {
//Je supprime les tildes et les pipes
var start = d.source.name.split('|')[0];
//var start = d.source.name.substr(0, d.source.name.length - 2).split('|')[0];
var end = d.target.name.split('|')[0];
if (displayFormat === "Number"){
return formatMoney(d.value, 0, '.', ' ','' , start + displaySeparateur + end);
}
if (displayFormat === "Number1"){
return formatMoney(d.value, 1, '.', ' ','' , start + displaySeparateur + end);
}
if (displayFormat === "Number2"){
return formatMoney(d.value, 2, '.', ' ','' , start + displaySeparateur + end);
}
if (displayFormat === "Money"){
return formatMoney(d.value, 0, '.', ' ',' €' , start + displaySeparateur + end);
}
if (displayFormat === "Money1"){
return formatMoney(d.value, 1, '.', ' ',' €' , start + displaySeparateur + end);
}
if (displayFormat === "Money2"){
return formatMoney(d.value, 2, '.', ' ',' €' , start + displaySeparateur + end);
}
});
var node = svg
.append("g").selectAll(".node").data(jNodes).enter().append("g").attr("class", "node").attr("transform", function(d) {
return "translate(" + d.x + "," + d.y + ")";
})
node.on("click",function(d, i) {
//on passe a la fonction l'identifiant qElement precedemment stocké dans le nom et le nom de la dimension sous forme d'un tableau
_this.backendApi.selectValues(
parseInt(d.name.split('~')[1].replace('end', qDim.length - 1)),
[ parseInt(d.name.split('~')[0].split('|')[1]) ],
true
);
})
// Start of Node and Path/Link Color. Declared variables for the arrays to store unique colors for specific nodes Added by Anand.V.N
var nodeLinkColor='';
var nodeName='';
var colorArray= new Array();
var objColor={};
var tempArr=new Array();
// End of Node and Path/Link Color Added by Anand.V.N
// AVEC POPUP sur le carré de couleur
node.append("rect").attr("height", function(d) {
return d.dy;
}).attr("width", sankey.nodeWidth()).style("fill", function(d) {
// Implemented Logic for the arrays to store unique colors for specific nodes Added by Anand.V.N
nodeName= d.name.split('|')[0];
if (!tempArr.contains(nodeName)) {
d.color = getColorForNode(d.name);
nodeLinkColor=d.color;
objColor[nodeName]=nodeLinkColor
colorArray.push(objColor);
}
else
{
colorArray.forEach(function(i){
d.color=i[nodeName];
});
}
tempArr.push(nodeName);
// End of Node and Path/Link Color Added by Anand.V.N
return d.color;
}).style("stroke", function(d) {
return d3.rgb(d.color).darker(2);
}).append("title").text(function(d) {
var level = d.name.substr(d.name.indexOf("~")+1,1);
if (level === "e" ){level = qDim.length -1;}
var entete = qDim[level] + ' : ' + d.name.split('|')[0];
if (displayFormat === "Number"){
return formatMoney(d.value, 0, '.', ' ','', entete);
}
if (displayFormat === "Number1"){
return formatMoney(d.value, 1, '.', ' ','',entete);
}
if (displayFormat === "Number2"){
return formatMoney(d.value, 2, '.', ' ','',entete);
}
if (displayFormat === "Money"){
return formatMoney(d.value, 0, '.', ' ',' €',entete);
}
if (displayFormat === "Money1"){
return formatMoney(d.value, 1, '.', ' ',' €',entete);
}
if (displayFormat === "Money2"){
return formatMoney(d.value, 2, '.', ' ',' €',entete);
}
});
var link = svg.append("g").selectAll(".link").data(sLinks).enter().append("path").attr("class", "link").attr("d", path).style("stroke-width",function(d) {
return Math.max(1, d.dy);
}).sort(function(a, b) {
return b.dy - a.dy;
});
link.style('stroke', function(d) {
// Implemented Logic to compare node arrays for specific colors and assign to the link/path. Added by Anand.V.N
var start = d.source.name.split('|')[0];
var end = d.target.name.split('|')[0];
colorArray.forEach(function(i){
// console.log(i);
if(colorArray.indexOf(start)==-1)
d.color=i[start];
});
// End of Node and Path/Link Color Added by Anand.V.N
return d.color;
});
link.append("title").text(function(d) {
var start = d.source.name.split('|')[0];
//var start = d.source.name.substr(0, d.source.name.length - 2).split('|')[0];
var end = d.target.name.split('|')[0];
if (displayFormat === "Number"){
return formatMoney(d.value, 0, '.', ' ','' , start + displaySeparateur + end);
}
if (displayFormat === "Number1"){
return formatMoney(d.value, 1, '.', ' ','' , start + displaySeparateur + end);
}
if (displayFormat === "Number2"){
return formatMoney(d.value, 2, '.', ' ','' , start + displaySeparateur + end);
}
if (displayFormat === "Money"){
return formatMoney(d.value, 0, '.', ' ',' €' , start + displaySeparateur + end);
}
if (displayFormat === "Money1"){
return formatMoney(d.value, 1, '.', ' ',' €' , start + displaySeparateur + end);
}
if (displayFormat === "Money2"){
return formatMoney(d.value, 2, '.', ' ',' €' , start + displaySeparateur + end);
}
});
// Changes the 'x' attribute size for the <text> to include text within <rect> nodes. Also have updated <text> tag by appending it next to <rect> tag. Added by Anand.V.N
node.append("text").attr("class", "nodeTitle").attr("x", 5).attr("y", function(d) {
return d.dy / 2;
}).attr("dy", ".35em").attr("text-anchor", "middle").attr("alignment-baseline", "middle").attr("transform", null).text(function(d) {
var str = d.name.substring(0, d.name.indexOf("~")).split('|')[0];
return str
}).filter(function(d) {
return d.x < width / 2;
}).attr("text-anchor", "start");
// End of <text> tag. Added by Anand.V.N
/*
function dragmove(d) {
d3.select(this).attr("transform", "translate(" + d.x + "," + (d.y = Math.max(0, Math.min(height - d.dy, d3.event.y))) + ")");
sankey.relayout();
link.attr("d", path);
}
*/
}
};
} );
Regards,
Just an assumption: Did you change this code from qWidth=4 to qWidth=5?
qInitialDataFetch: [{
qWidth: 5,
qHeight: 2000
}
If this is the case, then remove the extension from your sheet, refresh the browser and re-add the extension again!
I think you just have to recreate the app, qwidth and max/min dimensions has been set correctly.
Just recreate the app or re-add the extension.
I faced the same problem, after recreating the app, the problem has been solved.

method inside parameters in coffeescript

Could anyone please tell me coffeescript doesn't treat that method `drop as another parameter?
$('#id-calendar').fullCalendar
aspectRatio: 0.5
editable: true
droppable: true
defaultView: 'agendaWeek'
slotMinutes: 120
minTime: 8
maxTime: 20
firstDay: startDate()
drop = (date, allDay, jsEvent, ui) ->
console.log(date)
console.log(allDay)
console.log(jsEvent)
console.log(ui)
originalEventObject = $(this).data('eventObject')
copiedEventObject = $.extend({}, originalEventObject)
copiedEventObject.start = date
copiedEventObject.allDay = allDay
$('#id-calendar').fullCalendar('renderEvent', copiedEventObject, true)
$(this).remove()
return true
The output is:
var drop;
$(document).ready(function() {
var startDate;
startDate = function() {
var day, today;
today = new Date();
day = today.getDay();
switch (day - 2) {
case -1:
return 6;
case -2:
return 5;
default:
return day - 2;
}
};
return $('#external-events div.external-event').each(function() {
var eventObject;
eventObject = {
title: $.trim($(this).text())
};
$(this).data('eventObject', eventObject);
return $(this).draggable({
zIndex: 999,
evert: true,
revertDuration: 0
});
});
});
$('#id-calendar').fullCalendar({
aspectRatio: 0.5,
editable: true,
droppable: true,
defaultView: 'agendaWeek',
slotMinutes: 120,
minTime: 8,
maxTime: 20,
firstDay: startDate()
}, drop = function(date, allDay, jsEvent, ui) { === BUG
var copiedEventObject, originalEventObject;
console.log(date);
console.log(allDay);
console.log(jsEvent);
console.log(ui);
originalEventObject = $(this).data('eventObject');
copiedEventObject = $.extend({}, originalEventObject);
copiedEventObject.start = date;
copiedEventObject.allDay = allDay;
$('#id-calendar').fullCalendar('renderEvent', copiedEventObject, true);
$(this).remove();
return true;
});
It should be
drop: (date, allDay, jsEvent, ui) ->
and not drop =.

GWT:creat a simple meteogram in GWTHighCharts

i am trying to build a meteogram as this
In this chart there's xaxis below with values like 00,06,12,18
These are fine but how can i add the above values like satNov14, sunNov15, MonNov16
as there's multiple Yaxis but no multiple xaxis.
I am trying this , but after that am not getting the above dates in proper order
final Chart chart = new Chart()
.setBorderColor("#C7D5D5")
.setBorderWidth(3)
.setBorderRadius(0)
.setBackgroundColor("#FFFFFF")
.setChartTitleText("Meteogram")
.setSpacingTop(5)
.setChartSubtitleText("yr.no")
.setColumnPlotOptions(new ColumnPlotOptions()
.setDataLabels(new DataLabels()
.setEnabled(true)
) )
.setToolTip(new ToolTip()
.setFormatter(new ToolTipFormatter() {
public String format(ToolTipData toolTipData) {
String s;
if (toolTipData.getPointName() != null) {
s = toolTipData.getPointName() + ": " +
toolTipData.getYAsLong() + " ,";
} else {
s = toolTipData.getXAsString() + ": " +
toolTipData.getYAsLong();
}
return s;
}
})
)
.setLabelItems(
new LabelItem()
.setHtml("")
.setStyle(new Style()
.setLeft("40px")
.setTop("8px")
.setColor("black")
)
);
// Primary yAxis
chart.getYAxis(0).setGridLineWidth(1).setAxisTitleText("test")
.setAxisTitle(new AxisTitle()
.setText("")
)
.setLabels(new YAxisLabels()
//// .setStyle(new Style()
//// .setColor("#89A54E")
// )
.setFormatter(new AxisLabelsFormatter() {
public String format(AxisLabelsData axisLabelsData) {
return axisLabelsData.getValueAsLong() + "°";
}
})
);
// Secondary yAxis
chart.getYAxis(1).setGridLineWidth(2)
.setAxisTitle(new AxisTitle()
.setText("")
)
.setOpposite(true)
.setLabels(new YAxisLabels()
.setFormatter(new AxisLabelsFormatter() {
public String format(AxisLabelsData axisLabelsData) {
return axisLabelsData.getValueAsLong() + "°";
}
})
);
Point p1 = new Point(5, 5);
Marker m = new Marker();
m.setEnabled(true);
m.setOption("symbol", "url(41.png)");
p1.setMarker(m);
Point p2 = new Point(4.5, 4.5);
p2.setMarker(m);
Point p3 = new Point(4, 4);
Marker m1 = new Marker();
m1.setEnabled(true);
m1.setOption("symbol", "url(41.png)");
p3.setMarker(m1);
chart.getXAxis(1).setGridLineWidth(1).setLinkedTo(0)
.setOpposite(true)
.setCategories("Sat Nov13", "Sat Nov14", "Sat Nov15", "Sat Nov16");
chart.getXAxis(0).setGridLineWidth(1)
.setCategories("18","00","06","12","18","00","06","12","18","00","06","12","18","00","06","12","18") ;
chart.addSeries(chart.createSeries()
.setName("")
.setType(Series.Type.COLUMN)
.setPlotOptions(new ColumnPlotOptions()
.setColor("#24CBE5"))
.setPoints(new Number[]{
0,0,0,3,5,3,0,1,3,1,0,0,0,0}
)
.setYAxis(1)
);
chart.addSeries(chart.createSeries()
.setName("")
.setType(Series.Type.SPLINE)
.setPoints(new Number[]{
5,4.5,4,5,1,0,0,0,3,5,6,3,7,2 })
.setPlotOptions(new ColumnPlotOptions()
.setMarker(m1)
.setColor("#4572A7"))
);
return chart;
}
Attached is my output
Any Suggestions
Thanks
Like #Strelok said, the code is in the <script> tag if you right click the page and view source.
xAxis: [
{
type: 'datetime',
tickInterval: 6 * 3600 * 1000,
tickPosition: 'inside',
tickLength: 30,
gridLineWidth: 1,
gridLineColor: '#F0F0F0',
startOnTick: false,
endOnTick: false,
minPadding: 0,
maxPadding: 0,
offset: 30,
showLastLabel: true,
labels: {
formatter: function(){
return Highcharts.dateFormat('%H', this.value);
}
}
},
{
linkedTo: 0,
tickInterval: 24 * 3600 * 1000,
labels: {
formatter: function(){
return Highcharts.dateFormat(
'<span style="font-size: 12px; font-weight: bold">%a</span>, %b %e', this.value);
},
align: 'left',
x: 3
},
opposite: true,
tickLength: 20,
gridLineWidth: 1
}],
Top part is for bottom labels, bottom part is for top labels from the looks of it.
edit:
Give this a shot.
chart.getXAxis(1)
.setLinkedTo(0)
.setGridLineWidth(1)
.setOpposite(true)
.setTickInterval(24 * 3600 * 1000) // 24 hour tick intervals
.setCategories("Sat Nov13", "Sat Nov14", "Sat Nov15", "Sat Nov16");
chart.getXAxis(0)
.setGridLineWidth(1)
.setCategories("18","00","06","12","18","00","06","12","18","00","06","12","18","00","06","12","18");
.setTickInterval(6 * 3600 * 1000) // 6 hour tick intervals
.setTickPosition("inside")
.setStartOnTick(false)
.setEndOnTick(false)
.setOffset(30)
.setShowLastLabel(true)
in case you use unix epoch timestamps for your dates and if you need it the timestamp to be displayed in date format - just set the type of the axis to datetime
for example:
xAxis: {
type: 'datetime'
}
});
check this fiddle: http://jsfiddle.net/HnwbQ/1/
reference: http://www.highcharts.com/ref/#xAxis--type