I have this filter:
$http.get('data.json').then(function(response){
$scope.dataCopy = response.data;
$scope.detMaq = $filter('filter')(angular.copy($scope.dataCopy), {index:hielo, frecuencia:frec, prod_24_h_kg:peso }, false);
console.log($scope.detMaq);
});
And I'm building a few div's full of info with data from that data.json.
However, let's say that peso is 1.000, so in my filter I want only data that match completely to show up. This however it'll bring up data with 10.000 also, because the filter is not exact.
If I put true instead of false in the filter, the page will always be blank. even though it should bring information.
Am I missing something? Since it's a triple filter should I put 3 true's?
Here's the json.data
[{
"codigo": 21420,
"desc": "......",
"desc_n": "......",
"sistema": "DUCHAS",
"material_carroceria": "A.....",
"refrigerada": "AIRE",
"modelo_cubito_nombre": "ALFA",
"modelo_cubito_nombre_comercial": "",
"modelo_cubito_gr": 17,
"prod_24_h_kg": 22,
"almacen_cubitos_kg": "6",
"almacen_cubitos_cubitos": 400,
"ciclo_cubitos": 18,
"datos_comerciales_ciclo_cubitos": 18,
"compresor_cv": " 1/5",
"remota": null,
"potencia_w_1": 340,
"potencia_w_2": 270,
"voltaje": 220,
"frecuencia": 50,
"fases": "I",
"uk": null,
"gas_tipo": "R404a",
"gas_carga_gr": 180,
"mse_ancho": 350,
"mse_alto": 590,
"mse_fondo": 475,
"mse_alto_con_patas": "SIN PATAS",
"mce_ancho": 430,
"mce_alto": 720,
"mce_fondo": 540,
"peso_neto": 32,
"peso_bruto": 36,
"index": 99,
"enlace_catalogo": "..........",
"familia": ".........."
}, {
"codigo": 21421,
"desc": "...........",
"desc_n": "..........",
"sistema": "DUCHAS",
"material_carroceria": "ACERO INOXIDABLE AISI 304",
"refrigerada": "AGUA",
"modelo_cubito_nombre": "ALFA",
"modelo_cubito_nombre_comercial": "",
"modelo_cubito_gr": 17,
"prod_24_h_kg": 24,
"almacen_cubitos_kg": "6",
"almacen_cubitos_cubitos": 400,
"ciclo_cubitos": 18,
"datos_comerciales_ciclo_cubitos": 18,
"compresor_cv": " 1/5",
"remota": null,
"potencia_w_1": 340,
"potencia_w_2": 210,
"voltaje": 220,
"frecuencia": 50,
"fases": "I",
"uk": null,
"gas_tipo": "R404a",
"gas_carga_gr": 140,
"mse_ancho": 350,
"mse_alto": 590,
"mse_fondo": 475,
"mse_alto_con_patas": "SIN PATAS",
"mce_ancho": 430,
"mce_alto": 720,
"mce_fondo": 540,
"peso_neto": 32,
"peso_bruto": 36,
"index": 99,
"enlace_catalogo": "....",
"familia": "....."
}]
Related
that's my dataset:
[
{_id: "628d54495995f1e6589675b3", age: 52, sex: 1, cp: 0, trestbps: 125,
chol: 212, fbs: 0, restecg: "1", thalach: 168, exang: "0", oldpeak: 1},
{_id: "628d54495995f1e6589675b4", age: 53, sex: 1, cp: 1, trestbps: 140,
chol: 203, fbs: 1, restecg: "0", thalach: 155, exang: "1", oldpeak: 3.1},
]
... and so on
I want to group for 2 classes of age (under 40 (included) and over 40 (not included)) and for each class to determine which value of cp is the most frequent.
cp can have four different values: 0, 1, 2, 3
I thought bucket could be the right operator, but I can't get it to work
Thanks for helping
Given the follow example: https://codesandbox.io/s/l49mrmvj67
Will it be possible to add a custom footer that will sum the current page Salary column and display it in the footer?
Thanks for the help.
For simplicity I put everything in the same component:
import React from "react";
import ReactDOM from "react-dom";
import MUIDataTable from "mui-datatables";
import { TableFooter, TableCell, TableRow } from "#material-ui/core";
class App extends React.Component {
render() {
const columns = ["Name", "Title", "Location", "Age", "Salary"];
let data = [
["Gabby George", "Business Analyst", "Minneapolis", 30, 100000],
["Aiden Lloyd", "Business Consultant", "Dallas", 55, 200000],
["Jaden Collins", "Attorney", "Santa Ana", 27, 500000],
["Franky Rees", "Business Analyst", "St. Petersburg", 22, 50000],
["Aaren Rose", "Business Consultant", "Toledo", 28, 75000],
["Blake Duncan", "Business Management Analyst", "San Diego", 65, 94000],
["Frankie Parry", "Agency Legal Counsel", "Jacksonville", 71, 210000],
["Lane Wilson", "Commercial Specialist", "Omaha", 19, 65000],
["Robin Duncan", "Business Analyst", "Los Angeles", 20, 77000],
["Mel Brooks", "Business Consultant", "Oklahoma City", 37, 135000],
["Harper White", "Attorney", "Pittsburgh", 52, 420000],
["Kris Humphrey", "Agency Legal Counsel", "Laredo", 30, 150000],
["Frankie Long", "Industrial Analyst", "Austin", 31, 170000],
["Brynn Robbins", "Business Analyst", "Norfolk", 22, 90000],
["Justice Mann", "Business Consultant", "Chicago", 24, 133000],
[
"Addison Navarro",
"Business Management Analyst",
"New York",
50,
295000
],
["Jesse Welch", "Agency Legal Counsel", "Seattle", 28, 200000],
["Eli Mejia", "Commercial Specialist", "Long Beach", 65, 400000],
["Gene Leblanc", "Industrial Analyst", "Hartford", 34, 110000],
["Danny Leon", "Computer Scientist", "Newark", 60, 220000],
["Lane Lee", "Corporate Counselor", "Cincinnati", 52, 180000],
["Jesse Hall", "Business Analyst", "Baltimore", 44, 99000],
["Danni Hudson", "Agency Legal Counsel", "Tampa", 37, 90000],
["Terry Macdonald", "Commercial Specialist", "Miami", 39, 140000],
["Justice Mccarthy", "Attorney", "Tucson", 26, 330000],
["Silver Carey", "Computer Scientist", "Memphis", 47, 250000],
["Franky Miles", "Industrial Analyst", "Buffalo", 49, 190000],
["Glen Nixon", "Corporate Counselor", "Arlington", 44, 80000],
[
"Gabby Strickland",
"Business Process Consultant",
"Scottsdale",
26,
45000
],
["Mason Ray", "Computer Scientist", "San Francisco", 39, 142000]
];
const options = {
filter: true,
selectableRows: true,
filterType: "dropdown",
rowsPerPage: 3,
customFooter: (
count,
page,
rowsPerPage,
changeRowsPerPage,
changePage
) => {
const startIndex = page * rowsPerPage;
const endIndex = (page + 1) * rowsPerPage;
return (
<TableFooter>
<TableRow>
<TableCell colSpan={6}>
Total Salery for current page: {sumSalery(startIndex, endIndex)}
</TableCell>
</TableRow>
</TableFooter>
);
}
};
const sumSalery = (startIndex, endIndex) => {
return data
.slice(startIndex, endIndex)
.map(a => a[4])
.reduce((total, salery) => (total += salery), 0);
};
return (
<MUIDataTable
title={"ACME Employee list"}
data={data}
columns={columns}
options={options}
/>
);
}
}
ReactDOM.render(<App />, document.getElementById("root"));
In case of the salery you just need to find the start and end index of the data object that is currently displayed (the current page). Using these two you can simply add up the saleries of the sub array.
If you have any questions let me know.
You can use customTableBodyFooterRender in mui datatable options to create custom footer which is responsive with the columns.
I have created a table footer for total marks using mui datatable.
https://codesandbox.io/s/mui-datatable-custom-footer-rfu9zk
Eg:
https://i.stack.imgur.com/E8lg8.png
I've setup an authentication process using Google Firebase. I'm now looking to start working with the Firestore database - because I need multiple collections to work with - and have a large amount of data in a JSON file that needs importing.
The JSON file looks like this. I'll post just the first two entries but there are 60 total and not something that's feasible to just type in myself.
If someone could walk me through the steps on how to utilize a script for this issue, that would be greatly appreciated. Thanks!
I've tried to utilize some of the other posts on Stack but it's the use of scripts that has me all tripped up.
[
{
"FirstName": "Nickeil",
"LastName": "Alexander-Williams",
"Position": 2,
"Age": 19,
"CollegeYear": 2,
"Height": 77,
"DisplayHeight": "6-5",
"Weight": 205,
"College": "Virginia Tech",
"Consistency": 46,
"Greed": 72,
"Loyalty": 58,
"PlayForWinner": 16,
"PlayingTime": 26,
"Personality": 53,
"Durability": 47,
"WorkEthic": 75,
"DunkRate": 56,
"RARate": 3,
"DriveKick": 58,
"DriveShot": 0,
"PostUp": 0,
"PullUp": 17,
"CS": 32,
"Pass": 68,
"LocATB": 30,
"LocCorner": 81,
"LocMidrange": 27,
"LocPaint": 42,
"FG_RA": 58,
"FG_ITP": 58,
"FG_MID": 31,
"FG_COR": 18,
"FG_ATB": 67,
"FT": 0,
"Scoring": 35,
"Passing": 40,
"Handling": 41,
"OReb": 51,
"DReb": 61,
"Block": 52,
"Steal": 23,
"DrawFoul": 5,
"Defender": 54,
"Discipline": 75,
"BballIQ": 65,
"FG_RA_POT": 65,
"FG_ITP_POT": 65,
"FG_MID_POT": 38,
"FG_COR_POT": 25,
"FG_ATB_POT": 74,
"FT_POT": 7,
"Scoring_POT": 42,
"Passing_POT": 47,
"Handling_POT": 48,
"OReb_POT": 58,
"DReb_POT": 68,
"Block_POT": 59,
"Steal_POT": 30,
"DrawFoul_POT": 12,
"Defender_POT": 61,
"Discipline_POT": 82,
"BballIQ_POT": 72
},
{
"FirstName": "RJ",
"LastName": "Barrett",
"Position": 2,
"Age": 19,
"CollegeYear": 1,
"Height": 78,
"DisplayHeight": "6-6",
"Weight": 210,
"College": "Duke",
"Consistency": 61,
"Greed": 83,
"Loyalty": 77,
"PlayForWinner": 80,
"PlayingTime": 81,
"Personality": 76,
"Durability": 44,
"WorkEthic": 79,
"DunkRate": 80,
"RARate": 17,
"DriveKick": 51,
"DriveShot": 28,
"PostUp": 20,
"PullUp": 40,
"CS": 45,
"Pass": 35,
"LocATB": 40,
"LocCorner": 84,
"LocMidrange": 35,
"LocPaint": 54,
"FG_RA": 54,
"FG_ITP": 54,
"FG_MID": 39,
"FG_COR": 26,
"FG_ATB": 66,
"FT": 2,
"Scoring": 40,
"Passing": 27,
"Handling": 36,
"OReb": 57,
"DReb": 65,
"Block": 37,
"Steal": 39,
"DrawFoul": 13,
"Defender": 61,
"Discipline": 54,
"BballIQ": 58,
"FG_RA_POT": 61,
"FG_ITP_POT": 61,
"FG_MID_POT": 46,
"FG_COR_POT": 33,
"FG_ATB_POT": 73,
"FT_POT": 9,
"Scoring_POT": 47,
"Passing_POT": 34,
"Handling_POT": 43,
"OReb_POT": 64,
"DReb_POT": 72,
"Block_POT": 44,
"Steal_POT": 46,
"DrawFoul_POT": 20,
"Defender_POT": 68,
"Discipline_POT": 61,
"BballIQ_POT": 65
},
.
.
.
]
I faced same issue while code. For import JSON to your firebase DB have no specific method but you can insert it by script. For that purpose I make this script. This might help you too.
const fcm = require('nodefire-realtime');
//For Initialize Firebase DB
let serviceAccountKey = require("./serviceAccountKey.json");
let dbUrl = "https://<Your-project-id>.firebaseio.com/";
fcm.init(dbUrl, serviceAccountKey);
const data = require('./<your-JSON-file-name>.json');
//For insert
let dbReference = 'data/user/';
let data =data;
fcm.insert(data, dbReference);
Just make a simple JS file e.g. app.js and paste above code to it. You can get serviceAccountKey.json from project settings(firebase).
And if you get stuck with this package, follow steps from nodefire-realtime. I wish this will help.
I have created a network topography map using react-3d-graph and I am trying to access functions which are native to react-3d-graph outside of the graph itself. For example, I have a button which needs to utilize highlight behavior to highlight an individual node and its related nodes/links. Is there a way to do this? Here is the code for the graph:
const myConfig = {
"automaticRearrangeAfterDropNode": false,
"collapsible": true,
"height": 700,
"highlightDegree": 1,
"highlightOpacity": 0.2,
"linkHighlightBehavior": true,
"maxZoom": 8,
"minZoom": 0.1,
"nodeHighlightBehavior": true,
"panAndZoom": false,
"staticGraph": false,
"width": 1100,
"d3": {
"alphaTarget": 0.05,
"gravity": -200,
"linkLength": 300,
"linkStrength": 1
},
"node": {
"color": "#57a3ff",
"fontColor": "black",
"fontSize": 12,
"fontWeight": "bold",
"highlightColor": "red",
"highlightFontSize": 12,
"highlightFontWeight": "bold",
"highlightStrokeColor": "SAME",
"highlightStrokeWidth": 1.5,
"labelProperty": "name",
"mouseCursor": "pointer",
"opacity": 1,
"renderLabel": true,
"size": 450,
"strokeColor": "none",
"strokeWidth": 1.5,
"svg": "",
"symbolType": "square"
},
"link": {
"color": "#d3d3d3",
"opacity": 1,
"semanticStrokeWidth": false,
"strokeWidth": 4,
"highlightColor": "blue"
}
};
And here is the Graph component.
<Graph
id="graph-id"
data={data}
config={myConfig}
onClickNode={this.props.toggle}
onClickGraph={onClickGraph}
onClickLink={onClickLink}
/>
The function I am trying to access is "nodeHighlightBehavior". Is there a way to do this?
In the Flex app, the metadata is loaded as xml which has very good functions for searching deep into the xml nodes. In the extjs version I have converted the xml data to json, keeping the deep hierarchical content, and am loading to an extjs Store using a json reader. I have not created a model, deeming this not necessary as the model does not add add any search functionality(?). I am looking at store.find, store.findBy which can use a function, store.findRecord etc, but these functions look very 'one-levelish'. I need to go to the 'Tabs' "node", find its child 'Tab' with 'Name' of 'Tab1', and find the value of its attribute 'Title' ... am using the description "node" but it is hierarchical json data. Am I missing store functionality that would do this, should I use the store's raw json data - does json have better search functionality, or shall I revert to brute-force javascript by looping through all the "nodes"? I was hoping to avoid looping and find a function of some kind. As always, tia
Well, what I understood from our comments is that you need a kinda storage to access your JSON data as quickly and easily as possible.
JSON means JavaScript Object Notation, so it's an object!
Ok, I give you two examples.
First of all, setup JSON data:
{
"users": [{
"user": {
"id": 0 ,
"name": "foo" ,
"age": 22 ,
"skills": [{
"type": "bowcrafting" ,
"skillLevel": 50 ,
"levels": [10, 25, 50, 75, 90, 95, 99, 100]
}]
}} , {
"user": {
"id": 1 ,
"name": "bar" ,
"age": 71 ,
"skills": [{
"type": "fencing" ,
"skillLevel": 32 ,
"levels": [10, 25, 50, 90, 95, 99, 100]
} , {
"type": "swordsmanship" ,
"skillLevel": 73 ,
"levels": [10, 25, 50, 75, 80, 85, 90, 95, 99, 100]
}]
}} , {
"user": {
"id": 2 ,
"name": "foobar" ,
"age": 132 ,
"skills": [{
"type": "tactics" ,
"skillLevel": 90 ,
"levels": [10, 25, 50, 90, 95, 99, 100]
} , {
"type": "carpentery" ,
"skillLevel": 86 ,
"levels": [10, 25, 50, 75, 90, 95, 99, 100]
} , {
"type": "hiding" ,
"skillLevel": 100 ,
"levels": [10, 25, 50, 65, 75, 80, 85, 90, 95, 99, 100]
}]
}
}]
}
And now here we got two ways to follow:
First way: we can imagine the above JSON saved into a file called nested-json.json and we read it with a simple store. Than, we can use findBy search to find what we need:
var jstore = Ext.create ('Ext.data.Store', {
fields: ['id', 'name', 'age', 'skills'] ,
proxy: {
type: 'ajax' ,
url: 'nested-json.json' ,
reader: {
type: 'json' ,
root: 'users' ,
record: 'user' ,
idProperty: 'id'
}
} ,
autoLoad: true
});
Ext.create ('Ext.button.Button', {
text: 'Push me' ,
renderTo: Ext.getBody () ,
handler: function (btn) {
var index = jstore.findBy (function (user, id) {
// Here's the hint
if (user.data.skills.skillLevel === 50) return id;
else return -1;
});
if (index != -1) {
// It will print 'foo' because it's the user
// that has the skillLevel equal to 50
console.log (jstore.getAt(index).get ('name'));
}
}
});
The other way is to imagine the above JSON as an object, read directly from a raw JSON data. At this point, just use it as a javascript object:
// Users model: required by JSON reader
Ext.define ('Users', {
extend: 'Ext.data.Model' ,
fields: ['id', 'name', 'age', 'skills']
});
// JSON reader
var jreader = Ext.create ('Ext.data.reader.Json', {
model: 'Users' ,
root: 'users' ,
record: 'user' ,
idProperty: 'id'
});
// Reads records directly from raw JSON
var users = jreader.readRecords ({
"users": [{
"user": {
"id": 0 ,
"name": "foo" ,
"age": 22 ,
"skills": [{
"type": "bowcrafting" ,
"skillLevel": 50 ,
"levels": [10, 25, 50, 75, 90, 95, 99, 100]
}]
}} , {
"user": {
"id": 1 ,
"name": "bar" ,
"age": 71 ,
"skills": [{
"type": "fencing" ,
"skillLevel": 32 ,
"levels": [10, 25, 50, 90, 95, 99, 100]
} , {
"type": "swordsmanship" ,
"skillLevel": 73 ,
"levels": [10, 25, 50, 75, 80, 85, 90, 95, 99, 100]
}]
}} , {
"user": {
"id": 2 ,
"name": "foobar" ,
"age": 132 ,
"skills": [{
"type": "tactics" ,
"skillLevel": 90 ,
"levels": [10, 25, 50, 90, 95, 99, 100]
} , {
"type": "carpentery" ,
"skillLevel": 86 ,
"levels": [10, 25, 50, 75, 90, 95, 99, 100]
} , {
"type": "hiding" ,
"skillLevel": 100 ,
"levels": [10, 25, 50, 65, 75, 80, 85, 90, 95, 99, 100]
}]
}
}]
});
// Here's the magic
Ext.each (users.records, function (user) {
console.log ('*** USER ***');
console.log (user);
console.log ('id: ' + user.get ('id'));
console.log ('name: ' + user.get ('name'));
console.log ('age: ' + user.get ('age'));
Ext.each (user.get ('skills'), function (skill) {
console.log ('*** SKILL ***');
console.log (skill);
console.log ('type: ' + skill.type);
console.log ('level: ' + skill.skillLevel);
console.log ('*** LEVELS ***');
Ext.each (skill.levels, function (level) {
console.log (level);
});
});
});
Here's a jsfiddle to test this last one: jsfiddle
I hope to have understood what you requested. If I didn't, please let me know with an example made by yourself ;)