我的气泡图非常简单,我希望它在xaxis上显示自定义字符串而不是x值。对于在x轴上的系列中的拳头对象,显示proyect 1,依此类推。
$(function () {
var names = ["DAVE","JOHN"];
var projects = ["Project 1","Project 2"];
$('#container').highcharts({
chart: {
type: 'bubble',
plotBorderWidth: 1,
zoomType: 'xy'
},
title: {
text: 'Highcharts for staff project time'
},
xAxis: {
categories:['Project 1', 'Project 2', 'Project 3']
},
series: [{
data: [
{ x: 3.5, y: 4, z: 5, color: 'blue' },
{ x: 7, y: 7, z: 3, color: 'blue' },
{ x: 4, y: 8, z: 6, color: 'blue' }
],
}]
}); …Run Code Online (Sandbox Code Playgroud) 我的状态看起来像这样:
state: {
1: {show: false, description: 'one'},
2: {show: false, description: 'two'},
3: {show: true, description: 'three'}
}
Run Code Online (Sandbox Code Playgroud)
根据来自动作的变量"id",我必须更新状态.
像这样的东西:
var returnedState = {...state, [id].show : ![id].show}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我想更改类似于此的对象的属性,这是一个简化的对象,具有原始的一些属性:
state = {
pivotComuns: [
{
id: 1,
enabled : true
},
{
id: 2,
enabled : true
}
],
otherProperties : "otherProperties"
}
Run Code Online (Sandbox Code Playgroud)
我正在改变启用状态,如下所示:
state = {
...state,
pivotColumns: {
...state.pivotColumns,
[2]: {
...state.pivotColumns[2], enabled: !state.pivotColumns[2].enabled
}
}
}
Run Code Online (Sandbox Code Playgroud)
它可以工作,但是返回一个像我这样的数组是pivotComuns属性,它返回一个对象,"注意我为{}更改了[]":
state = {
pivotComuns: {
{
id: 1
enabled : true
},
{
id: 2,
enabled : true
}
},
otherProperties : "otherProperties"
}
Run Code Online (Sandbox Code Playgroud)
我做错了什么,我需要保持该属性为数组.
我正在使用map遍历元素列表,我想要的是每行有4个元素。这是我的课程的一部分:
render() {
return (
<div>
<h1>Card List</h1>
{this.props.items ? this.props.items.map((item) =>
<div class="cardSection">
<Row className="show-grid">
<Card name={item.name} imgGold={item.imgGold} />
</Row>
</div>
) : <div>Loading!</div>}
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud)
我想使用xs = {4} md = {4}每行4个Card组件