No UiSlider remove decimal? - nouislider

How to remove decimals digit from linked output
I am using this code
$("#slider_01").noUiSlider({
start: [2000, 24000],
connect: true,
step: 0.01,
range: {
'min': 0,
'max': 28500
},
format: wNumb({
decimals: false,
thousand: ',',
prefix: '$ ',
})
});
$('#slider_01').Link('lower').to($('#value-lower_1'));
$('#slider_01').Link('upper').to($('#value-upper_1'));

I didn't have access to the wNumb library in the environment I was working with.
Had a look under the hood in the library and this also works:
$("#slider_01").noUiSlider({
...
format: {
to: (v) => parseFloat(v).toFixed(0),
from: (v) => parseFloat(v).toFixed(0)
}
});

Decimals decimals: false is invalid, use decimals: 0. Also, you are setting formatting for the .val() method. Use it like this:
$('#slider_01').Link('lower').to($('#value-lower_1'), null, wNumb({
decimals: 0,
thousand: ',',
prefix: '$ ',
}));

Change the step from 0.01 to 1.

I know it's a very old question, but I did not want to include another library Wnumb just to remove the decimal from one place. Here is my solution without using the wnumb.
var slider = document.getElementById('prcsldr');
noUiSlider.create(slider, {
start: [10000],
range: {
min: 1000,
max: 50000
},
step: 1000,
format:{
to: (v) => v | 0,
from: (v) => v | 0
}
});

Related

Link overlap, on target port

I have an issue with link, on target port device, it unusually overlaps the target port.... check my fiddle . I also have attached a screenshot overlap image. Someone have any suggestions? Thanks!
I think JointJS is calculating that your source and target should be considered an obstacle. Adding the excludeEnds option in your fiddle seems to resolve the issue. You can see the option in the following docs.
https://resources.jointjs.com/docs/jointjs/v3.5/joint.html#routers.manhattan
Your code example could be the following:
var link = new joint.dia.Link({
// source: { id: el1.id },
// target: { id: el2.id },
router: { name: 'manhattan', args: { excludeEnds: ['source', 'target'] } },
connector: { name: 'rounded' },
attrs: {
'.connection': {
stroke: 'red',
'stroke-width': 5
},
'.marker-target': {
fill: 'red',
d: 'M 10 0 L 0 5 L 10 10 z'
},
'.marker-source': { /*stroke: '#fe854f',*/ fill: 'red', d: 'M 10 0 L 0 5 L 10 10 z' },
}
});

Node.js - Get font properties description

Is it possible to access the Description part of a font properties, as shown when you right-click on the file?
Here, I'm interested in the Title attribute, for example.
I've used the get-file-properties package as described in Node JS - read file properties, but it doesn't seem to have access to it (it's using wmic behind the scenes, which doesn't return it either). For example, Title doesn't exist, and Description returns C:\\Windows\\Fonts\\Alegreya-Bold.ttf
Is there another way to access this information?
Thanks
As #RobinMackenzie mentionned, there's the ttfinfo package (https://github.com/trevordixon/ttfinfo), which will give you the info on a specific font in this form:
{
tables: {
name: {
'0': 'Copyright 2011 The Alegreya Project Authors (https://github.com/huertatipografica/Alegreya)',
'1': 'Alegreya',
'2': 'Bold',
'3': '2.003;HT ;Alegreya-Bold',
'4': 'Alegreya Bold',
'5': 'Version 2.003; ttfautohint (v1.6)',
'6': 'Alegreya-Bold',
'8': 'Huerta Tipografica',
'9': 'Juan Pablo del Peral',
'11': 'http://www.huertatipografica.com',
'12': 'http://www.huertatipografica.com',
'13': 'This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is available with a FAQ at: http://scripts.sil.org/OFL',
'14': 'http://scripts.sil.org/OFL',
'256': 'Roman numerals',
'257': 'Arrows, triangles and circles',
'258': 'Foundry icon',
'259': 'Dynamic arrows and triangles'
},
post: {
format: 2,
italicAngle: 0,
underlinePosition: 0,
underlineThickness: 0,
minMemType42: 16734720,
maxMemType42: 1509968640,
minMemType1: 1258291200,
maxMemType1: 0
},
'OS/2': { version: 4, weightClass: 700 }
}
}
A full list of the names (0, 1, 2,...) can be found here: https://learn.microsoft.com/en-us/typography/opentype/spec/name#name-ids
There's also node-system-fonts (https://github.com/jgilsaa/node-system-fonts), which requires a build step as it's a C++ module, but on the plus side, gives you a lot of the same info, for every installed font:
[
{
path: 'C:\\WINDOWS\\FONTS\\ARIAL.TTF',
postscriptName: 'ArialMT',
family: 'Arial',
style: 'Regular',
weight: 400,
width: 5,
italic: false,
monospace: false
},
{
path: 'C:\\WINDOWS\\FONTS\\ARIALN.TTF',
postscriptName: 'ArialNarrow',
family: 'Arial Narrow',
style: 'Regular',
weight: 400,
width: 3,
italic: false,
monospace: false
},
{
path: 'C:\\WINDOWS\\FONTS\\ARIALI.TTF',
postscriptName: 'Arial-ItalicMT',
family: 'Arial',
style: 'Italic',
weight: 400,
width: 5,
italic: true,
monospace: false
},
...
]

Can you remove the hover-coordinate-lines in Plotly Python Scatter3d

When using Plotly Scatter3D , the default mouse hover-over effect displays a kind of coordinate crosshairs. Is there a way to remove this effect and just show the tooltip?
The hover effect causing the lines to show up on the axis are called spikes in Plotly. You can disable them via layout = {'scene': {'xaxis': {'showspikes': False}}}.
Interactive Javascript example:
Plotly.d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/3d-scatter.csv', function(err, rows) {
function unpack(rows, key) {
return rows.map(function(row) {
return row[key];
});
}
var trace = {
x: unpack(rows, 'x2'),
y: unpack(rows, 'y2'),
z: unpack(rows, 'z2'),
mode: 'markers',
marker: {
color: 'rgb(127, 127, 127)',
size: 12,
symbol: 'circle',
line: {
color: 'rgb(204, 204, 204)',
width: 1
},
opacity: 0.9
},
type: 'scatter3d'
};
var data = [trace];
var layout = {
scene: {
xaxis: {
showspikes: false
},
yaxis: {
showspikes: false
},
zaxis: {
showspikes: false
}
}
};
Plotly.newPlot('myDiv', data, layout);
});
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<div id="myDiv" style="width:100%;height:100%"></div>

nouislider callback function when minval

I'm using the the NoUiSlider 7 (jQuery Version) and i want a callback function if the User types a value below min value.
$('#slider').noUiSlider({
start: 100,
step: 10,
range: {
'min': Number(range[0]),
'max': Number(range[1])
},
serialization: {
lower: [
$.Link({
target: $('#ausgabe_klassisch_betrag')
})
],
format: {
thousand: '.',
postfix: ' E',
mark: ',',
decimals:0
}
}
});
So i tried to slice the value (because i use 2 characters postfix) and if the value is below then alert:
$("#slider_klassisch_betrag").on({
change: function(){
$val = $("#slider_klassisch_betrag").val().slice(0,-1);
if($val < 30 ){ alert(); }
}
});
But this does not work. the change only works if the slider changes and not with change by the input field

Building dynamic HighCharts and image Highcharts with (mostly) one codebase?

We're already creating dynamic HighCharts for our webpages--these have a few javascript dependencies and a chart-generation script. We'd like to start creating PDFs of these charts using the new HighCharts/Node/PhantomJS suite HighCharts has rigged up (see press release). Our image-gen node server would run on a separate box/vm. How can we do this without having to maintain two separate codebases for the same chart? I'm not too familiar with Node yet, so I'm not sure how requesting the scripts with a web request would work. I'm guessing a lot of HighCharts users that want to start generating some of their charts as images server-side will run into a similar issue with managing two related codesets...
In essence, we already have have this:
Webserver -> JSON (data) + foo.js + bar.js + foo.html -> webpage with dynamic charts.
We'd like to build:
Web-server -> JSON (data) + separate Node Server + foo.js + bar.js -> images available via web request
Obviously some redundancy. How can we manage the dependencies?
While node is awesome, I felt that approach was needlessly complex, with having to many moving parts that could break. So I did the super simple solution of creating files dynamically. The only problem i faced was deleting the temporary file after adding it to the pdf. It would break the PDF from rendering. And setting the directory to /tmp, crashed phantomjs. The best idea i came up with currently is putting the tempory generated files, in a temp directory, then deleting everything in that directory every night, with a cronjob.
I post this out of code simplicity. It should be in a function, to maintain code re-usability.
<?php
$TmpInFileName = 'tmp/graph_'.md5($CurrentDate.rand(666,9482845713)).'.js';
$TmpGraphFileName = 'tmp/pnggraph_'.md5($CurrentDate.rand(2666,54713)).'.png';
$Data = "
{
chart: {
zoomType: 'xy',
width: 700,
height: 520
},
credits: {
enabled: false
},
colors: [
'#2f7ed8',
'#910000',
'#8bbc21',
'#1aadce',
'#492970',
'#f28f43',
'#77a1e5',
'#c42525',
'#a6c96a'
],
title: {
text: 'Sample Graph - created at ".date('m/d/Y g:i:s a')."',
style: {
fontSize: '16px',
}
},
xAxis: [{
categories: ['00:00', '00:15', '00:30', '00:45', '01:00', '01:15', '01:30']
}],
yAxis: [{
labels: {
format: '{value}',
style: {
fontSize: '14px',
color: Highcharts.getOptions().colors[1]
}
},
title: {
text: 'Y axis',
style: {
fontSize: '16px',
color: Highcharts.getOptions().colors[1]
}
}
}, { // Secondary yAxis
title: {
text: 'Sec Yaxis',
style: {
fontSize: '16px',
color: Highcharts.getOptions().colors[0]
}
},
labels: {
format: '{value}',
style: {
fontSize: '14px',
color: Highcharts.getOptions().colors[0]
}
},
opposite: true
}],
tooltip: {
shared: true
},
legend: {
layout: 'horizontal',
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
},
series: [{
name: 'first',
type: 'spline',
yAxis: 1,
data: [0, -119.9502311075212, -119.96203992145706, -119.98172620218355, -119.71898290168028, -119.97023935590325, -119.95230287195413]
},
{
name: 'second',
type: 'spline',
yAxis: 1,
data: [0, -119.24222667756482, -119.60905809195222, -119.63522965403729, -119.11011466187935, -119.63643171374981, -119.54969080301575]
},{
name: 'third',
type: 'column',
data: [10, 11, 9, 7, 5, 2, 7]
},{
name: 'fourth',
type: 'column',
data: [0, -0.7080044299563895, -0.35298182950484147, -0.34649654814626274, -0.6088682398009269, -0.33380764215343106, -0.40261206893838164]
}]
}";
try {
$myfile = fopen($TmpInFileName, "w") or die("Unable to open file!");
fwrite($myfile, $Data);
fclose($myfile);
} catch (Exception $e) {
echo 'Error: '.$e.' <br />';
}
$URL_Command = "phantomjs /highcharts/exporting-server/phantomjs/highcharts-convert.js -infile $TmpInFileName -outfile $TmpGraphFileName -width 600";
exec($URL_Command);
echo '<img src="'.$TmpGraphFileName.'" alt="Could not load img: '.$TmpGraphFileName.'">';
?>
I hope this helps. I couldn't find a good solution that didn't involve Node.JS or Java to do this. I wanted a pure PHP solution.
We decided to pass the entire highcharts config object (e.g. Highcharts.chart(configObj)) to the node server as a URL-encoded string. We had to put a few rendering functions over on the node server, but it wasn't too bad. We also stuck some of the rendering functions in the string config object. Not the most beautiful result, but it worked.

Resources