我正在尝试制作一个切换按钮,您可以在其中冻结比例。如果再次单击,则会自动重新计算比例(这是 highcharts 中的默认设置)。
根据 API 参考,如果y-axis = {max:null}
规模是自动的。但是如果我锁定比例,我必须以某种方式提取 y 轴比例,以便我可以手动将 y 轴设置为当前值。当我切换回来时,y 轴设置为空。
当它设置为空时,是否有提取y轴比例的方法?我一直无法在 API 中找到任何内容。
这是我的 highchart 对象
chartFactory.getBarChart = function(data, duration){
//console.log(chartData);
var chart = $('.chart').highcharts({
chart: {
renderTo: 'chartContainer',
type: 'column',
height: windowHeight - 220, //Set chartsize depending on size of window
reflow: true
},
title: {
text: "title"
},
subtitle: {
text: "Source: "
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun','Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
},
yAxis: {
min: 0, …
Run Code Online (Sandbox Code Playgroud) 尝试查询生成器 knex.js,http://knexjs.org/
exports.deleteProduct = function(inputs, callback) {
//Working
knex( "products" ).select().exec(function(err, resp) { console.log(resp) });
//Not working
knex( "products" ).del().where( "pr_id", 349).exec(function(err, resp) { console.log(resp) });;
}
Run Code Online (Sandbox Code Playgroud)
select 语句工作得很好。但删除不了,也尝试过更新。响应为0。该记录尚未删除,已检查数据库。如果我运行 console.log(err) 也不会收到任何错误。
有任何想法吗?
试图复制文件.首先,我找到它.然后删除_id.然后插入它.但是calculate._id仍然存在.所以我得到了一个重复错误.我究竟做错了什么?
mongoose.model('calculations').findOne({calcId:req.params.calcId}, function(){
if(err) handleErr(err, res, 'Something went wrong when trying to find calculation by id');
delete calculation._id;
console.log(calculation); //The _.id is still there
mongoose.model('calculations').create(calculation, function(err, stat){
if(err) handleErr(err, res, 'Something went wrong when trying to copy a calculation');
res.send(200);
})
});
Run Code Online (Sandbox Code Playgroud) 我使用节点js,express和postgresql作为后端.这是我用来制作rest API的方法:
exports.schema = function (inputs, res) {
var query = knex('schema')
.orderBy('sch_title', 'asc')
.select();
query.exec(function (err, schemas) {
if(err){
var response = {
message: 'Something went wrong when trying to fetch schemas',
thrownErr: err
};
console.error(response);
res.send(500, response);
}
if(schemas.length === 0){
var message = 'No schemas was found';
console.error(message);
res.send(400, message);
return;
}
res.send(200, schemas);
});
};
Run Code Online (Sandbox Code Playgroud)
它工作但过了一段时间postgres记录错误,它不再工作:
sorry, too man clients already
Run Code Online (Sandbox Code Playgroud)
我是否需要以某种方式关闭每个请求?在快递文档中找不到任何相关内容.有什么不对?
此错误仅发生在生产服务器上.不在开发机器上.
更新 应用程序仅在一个"模块"中制动.应用程序的其余部分工作正常.因此,只有一些查询会产生错误.
我想在架构中使用验证。因此,我不能使用findOneAndUpdate
(?)。我必须使用保存。
问题是,如果我使用findOne,然后用要替换的对象替换该对象,它将不再具有保存功能。
mongoose.model('calculations').findOne({calcId:req.params['calcId']}, function(err, calculation){
if(err) {errHandler.serverErr(err, res, 'Something went wrong when trying to update a calculation'); return;}
calculation = calculationToReplace;
calculation.save(function(err, calc){ //No longer exists
if(err) {errHandler.serverErr(err, res, 'Something went wrong when trying to update a calculation'); return;}
res.send(200);
});
});
Run Code Online (Sandbox Code Playgroud)
这必须是一项常见的任务,但我找不到任何解决方案。我该如何解决?
我正在使用https://github.com/open-xml-templated/docxtemplater
我的数据:
var person = {
name: 'Joe',
address: {
city: 'Stockholm',
postal: 45123
}
}
Run Code Online (Sandbox Code Playgroud)
如何使用这个嵌套对象在 docx 中编写语法?
这是行不通的:
{address.city}
Run Code Online (Sandbox Code Playgroud)
在文档中找不到任何示例。
这是我的docker-compose-file:
version: "2"
services:
rest-api:
build: .
ports:
- "3007:3007"
links:
- mongo
mongo:
image: mongo
volumes:
- /data/mongodb/db:/data/db
ports:
- "27017:27017"
Run Code Online (Sandbox Code Playgroud)
这是我的Dockerfile:
FROM mhart/alpine-node:latest
RUN rm -rf /tmp/node_modules
ADD package.json /tmp/package.json
RUN cd /tmp && npm install
RUN mkdir -p /opt/app && cp -a /tmp/node_modules /opt/app/
WORKDIR /opt/app
ADD . /opt/app
EXPOSE 3007
CMD ["node", "index.js"]
Run Code Online (Sandbox Code Playgroud)
当我运行图像时,节点无法连接到mongo:
MongoError: failed to connect to server [localhost:27017] on first connect
Run Code Online (Sandbox Code Playgroud)
有什么不对?我该怎么调试呢?
更新:
在我的节点应用程序中,我有:
let connection = mongoose.connect('mongodb://localhost/myapp');
Run Code Online (Sandbox Code Playgroud) 文件:
[
{
name: 'abc'
length: 25,
area: 10
},
{
name: 'abc',
length: 5
}
]
Run Code Online (Sandbox Code Playgroud)
汇总查询后的输出:
[
{
count: 2,
summarizedLength: 30,
summarizedArea: null,
_id: {
name: 'abc'
}
}
]
Run Code Online (Sandbox Code Playgroud)
在length
和area
应总结。但仅当所有文档都具有area
或length
属性时。
因此,如果length
分组的属性缺少任何属性,则该summarizedLength
值应为null/undefined/not exisitng
,并且与相同area
。
我尝试了这个:
let query = mongoose.model('mycollection').aggregate([
{
$group: {
_id: {
name: $name
},
count: {
$sum: 1
},
summarizedLength: { $sum: "$length" },
summarizedArea: { $sum: "$area" }, …
Run Code Online (Sandbox Code Playgroud) 这是我的文件:
{
password: '87654321',
title: 'Organization A',
members:
[ { tier: 1,
joinedDate: Sun May 12 2013 00:00:00 GMT+0200 (CEST),
user: 543fc462ed385e5e77a98d56
},
{ tier: 2,
joinedDate: Sat May 11 2013 00:00:00 GMT+0200 (CEST),
user: 543fc462ed385e5e77a98d57
},
{ tier: 3,
joinedDate: Fri May 10 2013 00:00:00 GMT+0200 (CEST),
user: 543fc462ed385e5e77a98d58
}
]
}
Run Code Online (Sandbox Code Playgroud)
我想编写一个查询,以查询给定用户_.id的成员
拉命令可能是我应该使用的
http://mongoosejs.com/docs/api.html#types_array_MongooseArray-pull
mongoose.model('organization').findOne({_id:user.organization}, function(err, org){
org.members.pull({'user._id':user._id});
org.save();
})
Run Code Online (Sandbox Code Playgroud)
没用 我究竟做错了什么?
更新资料
我的架构:
var organizationSchema = new Schema({
title: String,
password: { type: String, required: true, index: …
Run Code Online (Sandbox Code Playgroud) 如何键入连接到减速器的道具?
以下代码给出了打字稿错误,但在运行时有效。
class Sidebar extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div id="test">
<p>{this.props.value}</p> // Typescript error
<button onClick={() => this.props.setValue(3)}> click</button> // Typescript error
</div>
);
}
}
const mapStateToProps = (state: any, ownProps: any) => ({
value: state.calcReducer.value as number,
});
export default connect(mapStateToProps, {
setValue,
})(Sidebar);
Run Code Online (Sandbox Code Playgroud) node.js ×6
mongodb ×5
javascript ×3
mongoose ×3
docker ×1
express ×1
highcharts ×1
knex.js ×1
postgresql ×1
reactjs ×1
redux ×1
typescript ×1