Is this code is correct to run ? because i have a question that is tag will execute without any built in libraries of
can this <rzslider> tag run directly in the page without any built-in packages of <rzslider>
running it using linux server.
<rzslider rz-slider-model="slider.minValue"
rz-slider-high="slider.maxValue"
rz-slider-options="slider.options"></rzslider>
$scope.slider = {
minValue: 10,
maxValue: 90,
options: {
floor: 0,
ceil: 100,
step: 1
}
};
using this tags i can't able to create a slider in the UI. so how can i execute it to show the slider in the UI?
You should try like as below
In view
<rzslider rz-slider-model="slider.value"
rz-slider-options="slider.options">
</rzslider>
In controller
$scope.slider = {
value: 10,
options: {
floor: 7,
ceil: 10,
showTicks: true,
showSelectionBar: true,
hidePointerLabels: true,
hideLimitLabels: true,
showTicksValues: false,
readOnly: true,
getTickColor: function (value) {
if (value < 3)
return 'red';
if (value < 6)
return 'orange';
if (value < 9)
return 'yellow';
return '#2AE02A';
}
},
}
Make sure you have add rzSlider module in your app.js
Related
I am trying to access values from the following in my react component.
sample JSON response
additionalinfo: {
totalCount : 10,
missingmetersregisters: {
missingCounts: {
mscsMeters: 0,
mdmsMeters: 0,
mscsRegisters: 0,
mdmsRegisters: 0
}
},
intervaldatadifference: {
intervaldatadifferencecount: 2
}
}
I am able to access totalCount like this {additionalinfo.totalCount} working fine.
But when I try to access intervaldatadifferencecount like this throwing exception/error in react component.
{additionalinfo.intervaldatadifference.intervaldatadifferencecount}
// error case
is there any way to handle this flat single JSON object? I am not an expert in react.
I also tried to iterate create individual iteration like this.
Object.keys(additionalinfo.missingmetersregisters.missingCounts).map((key) => {
console.log(key) // this returned keys only and I need values also
})
or is there any better way to do this?
Thanks
Object.keys(additionalinfo.missingmetersregisters.missingCounts).map((key)
=> { console.log(key) // this returned keys only and I need values also })
To get values use
Object.keys(additionalinfo.missingmetersregisters.missingCounts).map((key) => {
console.log(key) // key
console.log(additionalinfo.missingmetersregisters.missingCounts[key]) //value
})
Hi you can use it like this
Object.entries(additionalinfo.missingmetersregisters.missingCounts).map(data=>{console.log('data',data[0],data[1])});
//data[0] will be the key and data[1] will be the value
Accessing the objects inside object is straight forward thing. Only that there could be scenarios where one of the objects in the chain could be missing then you need to be cautious while accessing.
Optional chaining can be used when there's such scenario and you are not sure whether all the keys in the object will be available or not. Having said that this is a new feature and please make sure to check the compatibility check in the docs before using in your application.
Below is an example for the same
let data = {
additionalinfo: {
totalCount: 10,
missingmetersregisters: {
missingCounts: {
mscsMeters: 0,
mdmsMeters: 0,
mscsRegisters: 0,
mdmsRegisters: 0,
},
},
intervaldatadifference: {
intervaldatadifferencecount: 2,
},
},
}
console.log(data.additionalinfo?.totalCount)
console.log(data.additionalinfo?.intervaldatadifference?.intervaldatadifferencecount)
console.log(data?.additionalinfo?.missingmetersregisters?.test)
console.log(data?.additionalinfo?.intervaldatadifferenc?.intervaldatadifferencecount)
If this is not compatible with your supported devices or technology versions then there's another way you can access, please refer below for the same.
This is another way of accessing object chain when you know some of the levels in the object chain might be missing.
let data = {
additionalinfo: {
totalCount: 10,
missingmetersregisters: {
missingCounts: {
mscsMeters: 0,
mdmsMeters: 0,
mscsRegisters: 0,
mdmsRegisters: 0,
},
},
intervaldatadifference: {
intervaldatadifferencecount: 2,
},
},
}
const {additionalinfo = {}} = data;
const {intervaldatadifference = {}} = additionalinfo;
const {missingmetersregisters = {}} = additionalinfo;
const {intervaldatadifferenc = {}} = additionalinfo;
console.log(additionalinfo.totalCount)
console.log(intervaldatadifference.intervaldatadifferencecount)
console.log(missingmetersregisters.test)
console.log(intervaldatadifferenc.intervaldatadifferencecount)
Here I have created a utility to list all the key-value pairs of an object by passing the object as a param to the utility.
let data = {
additionalinfo: {
totalCount: 10,
missingmetersregisters: {
missingCounts: {
mscsMeters: 0,
mdmsMeters: 0,
mscsRegisters: 0,
mdmsRegisters: 0,
},
},
intervaldatadifference: {
intervaldatadifferencecount: 2,
},
},
}
const listAll = obj => {
for (let [key, value] of Object.entries(obj)) {
console.log(`${key} - ${JSON.stringify(value)}`)
}
}
listAll(data.additionalinfo.missingmetersregisters.missingCounts)
Hope this helps.
Using Terser I can not get the desired results.
I am trying to minify the testing code below and the function names do not get minified whatever I try.
The variable names stay the same too, only within local functions that have parameters, they get changed.
I have set toplevel to true and tried about every option I can think off.
The deadcode in neverBeCalled does not go away either.
Using Terser v4.3.4 and have no problem using another minifier if that would do the trick.
My config:
var options = {
warnings: "verbose",
keep_fnames: false,
mangle: {
toplevel: true,
},
compress: {
passes: 20,
dead_code: true,
sequences: false,
conditionals: false,
drop_console: true,
},
output: {
ecma: 6,
semicolons: false
}
};
The testing source file:
init = function(){
test="testing";
bla = "blabla"
shameVar=903
}
update = function(){
test+="test"
test+="123"
x=10;
bla=bla+"x"
tester = myFuncWithLongName(23,24);
shameVar=shameVar-1;
}
myfuncWithLongName = function(eat,sleep){
resting=sleep+shameVar;
some = eat+resting;
return some;
}
neverBeCalled = function(){
thisdoesnot=0;
return thisdoesnot;
}
The result
init=function(){test="testing"
bla="blabla"
shameVar=903}
update=function(){test+="test"
test+="123"
x=10
bla+="x"
tester=myFuncWithLongName(23,24)
shameVar-=1}
myfuncWithLongName=function(t,e){resting=e+shameVar
some=t+resting
return some}
neverBeCalled=function(){thisdoesnot=0
return thisdoesnot}
This is not possible because without adding var the variables are global and Terser does not mangle them..
I try to show some events from database in my fullCalendar but it doesn't work? My app is on Symfony 3. First I installed the ancarebeca/fullcalendar, I followed the installation step by step and my agenda is here! In my controller, I have a method to return a JSON array like this:
[{"1":{"id":1,"title":"test","start":"2017-08-01
18:00:00","end":"2017-08-01
20:00:00","allDay":true,"editable":true,"startEditable":true,"durationEditable":true,"overlap":true,"url":"","backgroundColor":"","textColor":"","className":"","rendering":"","constraint":1,"source":"","color":""},"2":{"id":2,"title":"test2","start":"2017-08-02
15:00:00","end":"2017-08-02
16:00:00","allDay":true,"editable":true,"startEditable":true,"durationEditable":true,"overlap":true,"url":"","backgroundColor":"","textColor":"","className":"","rendering":"","constraint":1,"source":"","color":""}}]
If you want look my method:
public function loadAction()
{
//dump($calendarService);die();
$em = $this->getDoctrine()->getManager();
$evenements = $em->getRepository('MALrmBundle:CalendarEvent')->findAll();
$calendarService = $this->get('ma_lrm_bundle.service.listener');
$events = array();
foreach ($evenements as $key => $evenement)
{
$events[$evenement->getId()]=$calendarService->loadData($evenement);
}
$response = new JsonResponse($events);
return $response->setData(array($events));
}
At the end, in my js file, i just call the url, like this:
events: 'http://localhost/ligne_rh/web/app_dev.php/admin/accueil/calendar',
...But i have no return in my calendar...
i also post my full Js file:
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev, next',
center: 'title',
right: 'month, agendaWeek, agendaDay'
},
timezone: ('Europe/London'),
businessHours: {
start: '09:00',
end: '17:30',
dow: [1, 2, 3, 4, 5]
},
allDaySlot: false,
defaultView: 'agendaWeek',
lazyFetching: true,
firstDay: 1,
selectable: true,
timeFormat: {
agenda: 'h:mmt',
'': 'h:mmt'
},
/*columnFormat: {
month: 'ddd',
week: 'ddd D/M',
day: 'dddd'
},*/
editable: true,
eventDurationEditable: true,
events: 'http://localhost/ligne_rh/web/app_dev.php/admin/accueil/calendar',
});
});
Please help me.
Your JSON is structured differently than it expects.
[{"1":{"title":"test","start":"2017-08-01 18:00"}}]
should be like
[{"title":"Title","test":"2017-08-01 18:00"}]
To fix, try changing
$events[$evenement->getId()]=$calendarService->loadData($evenement);
to
$events[]=$calendarService->loadData($evenement);
As an aside, I'm not familiar with Symphony but the return may be as easy as return $response;
since you already use $events in the $response = new JsonResponse($events);
or just return new JsonResponse($events);
I have a simple line graph with data in the format:
[
{
label: "lebel1",
x: 0,
y: 128
},
{
label: "lebel1",
x: 1,
y: 128
},
....
{
label: "lebel2",
x: 25,
y: 128
},
....
{
label: "lebel8",
x: 285,
y: 128
},
....
}
and I pass this into my nvd3 object:
nv.addGraph(function()
{
var chart = nv.models.lineChart();
chart.xAxis
.axisLabel("My X-Axis")
.ticks(36)
.tickFormat(function(d) { return d; });
chart.yAxis
.axisLabel('Voltage (v)')
.tickFormat(d3.format('.02f'));
d3.select('div svg')
.datum(myData)
.transition().duration(500)
.call(chart);
nv.utils.windowResize(function() { d3.select(gridSvgId).call(chart) });
return chart;
});
How can I have my x-axis ticks to show:
* eight labels: label1 - label8
Rather than have the grids broken up into a variable number of lines?
Try something like this
chart.xAxis.tickValues(['Label 1','Label 2','Label 3','Label 4','Label 5','Label 6','Label 7','Label 8']);
or if you want to get it from the dataset, you could try something like this,
chart.xAxis.tickValues(function(d) {
// do all you stuff and return an array
var dataset = ['Build Array from data'];
return dataset;
};)
Hope it helps
i am facing a problem which i want to generate a button in grid column by using reconfigure function.
i find my code consist of the Extjs error during renderer function 'Uncaught TypeError: Cannot read property 'dom' of null'
i checked that it should be come from "renderTo: id3", do you have any idea on it? Do i do something wrong in my render button function in the grid?
Although i pop up error message, but the UI still can show the button i genereated. it is very confused.
var createColumns = function (json) {
var keys = getKeysFromJson(json[0]);
return keys.map(function (field) {
if(field!='unread'&&field!='linkerType'&&field!='linkParam'&&field!='refNumber'&&field!='oid'&&field!='refOwner'){
return {
text: Ext.String.capitalize(field),
//flex : 1,
dataIndex: field,
sortable: true,
menuDisabled: true,
renderer: function (val, metadata, record) {
if(field=='action') {
var str = val.split(":");
metadata.style = "text-align: left";
if(str[2]=='true'&&str[1]=='false'){
var id3 = Ext.id();
Ext.defer(function () {
Ext.widget('button', {
renderTo: id3,
margin: '0 0 0 10',
iconAlign: 'center',
tooltip:'Ok to Ship Again',
cls: 'x-btn-default-small',
text: '<img src="images/OKToShipAgain.png">',
handler: function() {
items=[];
items.push({
"oid" : record.get('oid'),
"refNumber" : record.get('refNumber'),
"refOwner" : record.get('refOwner')
});
Ext.Ajax.request({
url: '#{csMenuBean.contextPath}/ws3/todolistservice/submitOktoship',
params: {data: Ext.encode(items)},
success : function(response){
}
});
}
})
}, 50);
return Ext.String.format('<span id="{0}"></span>', id3);
}