Antd table select not working, always selecting all the rows - antd

I am trying to implement row selection in my antd table but when I am selecting any rows all the rows gets selected
<PhcTable
pagination={false}
dataSource={configurationOptions?.ConfigDeposits[index].creditTiers}
columns={columnsPaymentPlans}
rowSelection={{onselect:(record)=>{console.log(record)}}}
scroll={{ x: 500 }}
/>
const columnsPaymentPlans = [
{
title: "Credit Tiers",
dataIndex: 'creditTier',
key: 'creditTier',
width: 80
},
{
title: "Credit Risk",
dataIndex: "CreditRisk",
key: "CreditRisk",
width: 60,
},
{
title: "Notes",
dataIndex: "notes",
key: "notes",
width: 100,
},
{
title: "Deposit",
dataIndex: "deposit",
key: "deposit",
width: 60,
fixed: "right",
render: (text, record, index) => (
<PhcForm.Item
initialValue={text}
name={`deposit${record.providerSpecialtyId.toString()+index.toString()}`}
rules={[
{ required: true, message: "Field is required" },
{
validator: (rule, value, callback) =>
validateDeposit(rule, value, callback, record,"%"),
},
]}
>
<PhcInputNumber
maxLength={4}
style={{
height: "40px",
width: isBrowser ? "75%" : "100%",
padding: "4px 11px",
}}
value={text}
//onChange={onInputChange("minDepositType", index)}
/>
</PhcForm.Item>
),
},
{
title: "Max Loan Amount",
dataIndex: "maxLoanAmount",
key: "maxLoanAmount",
width: 70,
fixed: "right",
render: (text, record, index) => (
<PhcForm.Item
initialValue={text}
name={`maxLoanAmount${record.providerSpecialtyId.toString()+index.toString()}`}
rules={[
{ required: true, message: "Field is required" },
{
validator: (rule, value, callback) =>
validateMaxLoanAmount(rule, value, callback, record),
},
]}
>
<PhcInputDecimal
keyboard={true}
controls={true}
onKeyPress={onNumberPress}
formatter={(value) =>
`${value}`.replace(/(\..*)\./g, '$($1)')
}
maxLength={5}
style={{
height: "40px",
//width: isBrowser && "75%",
width: isBrowser ? "75%" : "100%",
padding: "4px 11px",
//minWidth: "218px",
}}
value={text}
//onChange={onInputChange("maxLoanAmount", index)}
/>
</PhcForm.Item>
),
},
{
title: "Terms",
dataIndex: "Terms",
key: "configDepositsTermsIds",
width: 150,
render: (text, record, index) => (
<PhcForm.Item
initialValue={record.Terms.filter(x=>x.selected == true).map(x=>x.id)}
name={`ConfigDepositsTermsIds${record.providerSpecialtyId.toString()+index.toString()}`}
rules={[
{ required: true, message: "Field is required" },
{
validator: (rule, value, callback) =>
validateDeposit(rule, value, callback, record),
},
]}
>
<PhcSelect
mode="multiple"
optionFilterProp="label"
allowClear
showSearch
showArrow
style={{ width: isBrowser && "75%" }}
>
{record.Terms &&
record.Terms.map((item) => (
<PhcSelect.Option value={item.id} label={item.term}>
{item.term}
</PhcSelect.Option>
))}
</PhcSelect>
</PhcForm.Item>
),
}
];
"creditTiers": [
{
"providerSpecialtyId": 1735,
"creditTierId": 1,
"creditTier": "Tier 1 Credit - Prime",
"CreditRisk": "Low",
"notes": "This credit tier serves near-prime, prime, and super-prime.",
"deposit": 0,
"maxLoanAmount": 20000,
"selected": false,
"Terms": [
{
"id": 1,
"term": "6",
"selected": false
},
{
"id": 2,
"term": "12",
"selected": false
},
{
"id": 3,
"term": "18",
"selected": false
},
{
"id": 4,
"term": "24",
"selected": false
},
{
"id": 5,
"term": "36",
"selected": false
},
{
"id": 6,
"term": "48",
"selected": false
},
{
"id": 7,
"term": "60",
"selected": false
}
]
},
{
"providerSpecialtyId": 1735,
"creditTierId": 2,
"creditTier": "Tier 2 Credit - Sub-Prime",
"CreditRisk": "Low/Moderate",
"notes": "This credit tier also serves low-income applicants.",
"deposit": 10,
"maxLoanAmount": 20000,
"selected": false,
"Terms": [
{
"id": 1,
"term": "6",
"selected": false
},
{
"id": 2,
"term": "12",
"selected": false
},
{
"id": 3,
"term": "18",
"selected": false
},
{
"id": 4,
"term": "24",
"selected": false
},
{
"id": 5,
"term": "36",
"selected": false
},
{
"id": 6,
"term": "48",
"selected": false
},
{
"id": 7,
"term": "60",
"selected": false
}
]
},
{
"providerSpecialtyId": 1735,
"creditTierId": 3,
"creditTier": "Tier 3 Credit - Deep Sub-Prime",
"CreditRisk": "Moderate/High",
"notes": "This credit tier is best used with orthodontics.",
"deposit": 15,
"maxLoanAmount": 15000,
"selected": false,
"Terms": [
{
"id": 1,
"term": "6",
"selected": false
},
{
"id": 2,
"term": "12",
"selected": false
},
{
"id": 3,
"term": "18",
"selected": false
},
{
"id": 4,
"term": "24",
"selected": false
},
{
"id": 5,
"term": "36",
"selected": false
},
{
"id": 6,
"term": "48",
"selected": false
},
{
"id": 7,
"term": "60",
"selected": false
}
]
},
{
"providerSpecialtyId": 1735,
"creditTierId": 4,
"creditTier": "Tier 4 Credit - Underbanked",
"CreditRisk": "Moderate/High",
"notes": "Applicants may use a SS# or an ITIN# to apply.",
"deposit": 15,
"maxLoanAmount": 7500,
"selected": false,
"Terms": [
{
"id": 1,
"term": "6",
"selected": false
},
{
"id": 2,
"term": "12",
"selected": false
},
{
"id": 3,
"term": "18",
"selected": false
},
{
"id": 4,
"term": "24",
"selected": false
},
{
"id": 5,
"term": "36",
"selected": false
},
{
"id": 6,
"term": "48",
"selected": false
},
{
"id": 7,
"term": "60",
"selected": false
}
]
},
{
"providerSpecialtyId": 1735,
"creditTierId": 5,
"creditTier": "Tier 5 Credit - Last Resort",
"CreditRisk": "High",
"notes": "Limits dental repayment options to 2, 3, and 4 months.",
"deposit": 20,
"maxLoanAmount": 7500,
"selected": false,
"Terms": [
{
"id": 1,
"term": "6",
"selected": false
},
{
"id": 2,
"term": "12",
"selected": false
},
{
"id": 3,
"term": "18",
"selected": false
},
{
"id": 4,
"term": "24",
"selected": false
},
{
"id": 5,
"term": "36",
"selected": false
},
{
"id": 6,
"term": "48",
"selected": false
},
{
"id": 7,
"term": "60",
"selected": false
}
]
}
]

The problem is that you didn't specify key for each row. By default, antd find key in each row. Since you don't have it and according to the data you added above, the key is creditTierId. So you can specify row key in table by:
rowKey={(record) => record.creditTierId}
If you just enable rowSelection, you can select any row. But in order to know the rows you have selected, you can create a state and control the rowSelection. Please check the code. I use onChange function in rowSelection and it provides two arguments. The first one array of selected Row keys & second one selected rows.
function App() {
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
const columnsPaymentPlans = [
{
title: 'Credit Tiers',
dataIndex: 'creditTier',
key: 'creditTier',
width: 80
},
{
title: 'Credit Risk',
dataIndex: 'CreditRisk',
key: 'CreditRisk',
width: 60
},
{
title: 'Notes',
dataIndex: 'notes',
key: 'notes',
width: 100
},
// ...Other Columns
];
return (
<Table
pagination={false}
dataSource={configurationOptions?.creditTiers}
columns={columnsPaymentPlans}
rowKey={(record) => record.creditTierId}
rowSelection={{
selectedRowKeys,
onChange: (selectedRowKeys, selectedRows) => {
setSelectedRowKeys(selectedRowKeys);
}
}}
scroll={{ x: 500 }}
/>
);
}
export default App;

Related

chart.update moving bar incorrectly

I have a chart that gets updated with new data and if the config is "almost" the same (new subtitle, data slightly different, etc...but same number of data values) I'm finding the last bar gets moved on top of the first bar, over laying it. Color me baffled. I'm using 9.3.3 but have repro'd it in "current" in this jsfiddle:
https://jsfiddle.net/wxpe6v2r/28/
const chart = Highcharts.chart('container', {
"title": {
"text": "Top 10"
},
"subtitle": {
"text": "Everything",
"useHTML": true
},
"colors": [
"#F5827A",
"#FBB3AF"
],
"chart": {
"marginLeft": 60,
"marginRight": 60,
"spacingTop": 10,
"spacingRight": 0,
"spacingBottom": 8,
"spacingLeft": 10,
"zoomType": "",
"alignTicks": false,
"animation": true
},
"plotOptions": {
"series": {
"animation": true,
"shadow": false,
"borderWidth": 0,
"marker": {
"enabled": true,
"states": {
"hover": {
"enabled": false
}
}
}
}
},
"legend": {
"enabled": true
},
"series": [
{
"name": "Count",
"type": "column",
"data": [
4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9
]
},
{
"name": "Cumulative Percent",
"yAxis": 1,
"type": "line",
"data": [
18.18, 22.73, 27.27, 31.82, 36.36, 40.91, 45.45, 50, 54.55, 59.09, 100
]
}
],
"xAxis": {
"type": "category",
"title": {
"text": "File",
"enabled": false,
},
"categories": [
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "Other"
]
},
"yAxis": [
{
"min": 0,
"max": 9,
"lineWidth": 1,
"allowDecimals": false,
"title": {
"text": "Count",
"rotation": 270,
"style": {
"fontWeight": "bold"
}
},
"labels": {
"enabled": true
},
"startOnTick": false,
"endOnTick": false
},
{
"min": 0,
"max": 100,
"gridLineWidth": 0,
"lineWidth": 1,
"opposite": true,
"title": {
"text": "Cumulative Percent",
"rotation": 270,
"style": {
"fontWeight": "bold"
}
},
"labels": {
"enabled": true,
}
}
],
});
document.getElementById('update').addEventListener('click', () => {
chart.update({
"title": {
"text": "Top 10"
},
"subtitle": {
"text": "Everything",
"useHTML": true
},
"colors": [
"#F5827A",
"#FBB3AF"
],
"chart": {
"marginLeft": 60,
"marginRight": 60,
"spacingTop": 10,
"spacingRight": 0,
"spacingBottom": 8,
"spacingLeft": 10,
"zoomType": "",
"alignTicks": false,
"animation": true
},
"plotOptions": {
"series": {
"animation": true,
"shadow": false,
"borderWidth": 0,
"marker": {
"enabled": true,
"states": {
"hover": {
"enabled": false
}
}
}
}
},
"legend": {
"enabled": true
},
"series": [
{
"name": "Count",
"type": "column",
"data": [
4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11
]
},
{
"name": "Cumulative Percent",
"yAxis": 1,
"type": "line",
"data": [
18.18, 22.73, 27.27, 31.82, 36.36, 40.91, 45.45, 50, 54.55, 59.09, 100
]
}
],
"xAxis": {
"type": "category",
"categories": [
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "Other"
]
},
"yAxis": [
{
"min": 0,
"max": 11,
"lineWidth": 1,
"allowDecimals": false,
"title": {
"text": "Count",
"rotation": 270,
"style": {
"fontWeight": "bold"
}
},
"labels": {
"enabled": true
},
"startOnTick": false,
"endOnTick": false
},
{
"min": 0,
"max": 100,
"gridLineWidth": 0,
"lineWidth": 1,
"opposite": true,
"title": {
"text": "Cumulative Percent",
"rotation": 270,
"style": {
"fontWeight": "bold"
}
},
"labels": {
"enabled": true,
}
}
],
}
);
});
Just hit the update button and the "Other" bar is moved to the first position, overlaying the "A" bar.
Any suggestions on what I'm doing wrong are appreciated.
P.S. I have noticed after playing with the jsfiddle that it moves the bar to the first matching series[0] data value. That is, given series[0] of [4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9], that gets updated to [4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11], it puts the [10] bar (value 11) over the [0] bar (value 4). If I change the initial series[0] values to [5, 2, 1, 1, 1, 1, 1, 1, 1, 1, 9], upon update() it moves the value 11 bar to series[2], the first matching value. I don't get it.
Defining xAxis.categories without xAxis.type is enough and it resolves the issue.
However, the problem looks like a bug, so you can report it on Highcharts Github: https://github.com/highcharts/highcharts/issues
"xAxis": {
// "type": "category",
"title": {
"text": "File",
"enabled": false,
},
"categories": [
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "Other"
]
}
Live demo: https://jsfiddle.net/BlackLabel/8nu9x6g5/
API Reference: https://api.highcharts.com/highcharts/xAxis.categories

How do I make the x-axis category label in a polar chart of HighChart non-wordwrap?

Here is the source code:
https://jsfiddle.net/24zrbqpL/
Highcharts.chart('container', {
"chart": {
"type": "line",
"polar": true
},
"xAxis": {
"min": 0.5,
"max": 6.5,
"categories": ['Clarify Objectives', 'Propose Initiates', 'Prioritise & Select', 'Track Performance', 'Review Portfolio', 'Adjust Course', ''],
"labels": {
"distance": 25
},
"tickmarkPlacement": "on",
"lineWidth": 0,
"gridLineColor": "#575756",
"title": {
"style": {
"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif",
"color": "#666666",
"fontSize": "30px",
"fontWeight": "normal",
"fontStyle": "normal"
}
}
},
"yAxis": {
"plotBands": [{
"from": 1,
"to": 2,
"color": "#f8c4c0",
"outerRadius": "105%",
"thickness": "50%"
}, {
"from": 2,
"to": 3,
"color": "#f39d96",
"outerRadius": "105%",
"thickness": "50%"
}, {
"from": 3,
"to": 4,
"color": "#ee766d",
"outerRadius": "105%",
"thickness": "50%"
}, {
"from": 4,
"to": 5,
"color": "#eb584d",
"outerRadius": "105%",
"thickness": "50%"
}],
"reversed": true,
"min": 1,
"max": 5,
"allowDecimals": false,
"tickInterval": 1,
"tickAmount": 6,
"tickLength": 10,
"gridLineInterpolation": "polygon",
"gridLineColor": "",
"lineWidth": 0,
"tickmarkPlacement": "between",
"tickPixelInterval": 100,
"tickPosition": "outside",
"labels": {
"enabled": true,
"style": {
"fontWeight": "bold"
},
//"y": 25
}
},
"title": {
"text": "APM Spiderweb"
},
"series": [{
data: [1, 2, 3, 4, 5, 6]
}, {
}],
"plotOptions": {
"series": {
"animation": true,
"lineWidth": 4,
"marker": {
"radius": 8,
"symbol": "circle"
},
"_colorIndex": 0,
"_symbolIndex": 0
}
},
"credits": {
"enabled": false
},
"colors": [
"#7cb5ec",
"#90ed7d",
"#f7a35c",
"#8085e9",
"#f15c80",
"#e4d354",
"#2b908f",
"#f45b5b",
"#91e8e1"
]
});
Setting a whiteSpace to 'nowrap' in the labels.style object is a solution which you are looking for.
"labels": {
"distance": 25,
"style": {
"whiteSpace": 'nowrap'
}
},
Demo: https://jsfiddle.net/BlackLabel/edpcjL3k/
API: https://api.highcharts.com/highcharts/xAxis.labels.style

Highcharts xAxis has extra gap when multiple yAxis

We have a chart that plots multiple series at once.
There are the main y-series (line type) that will have the main data readings.
There is the option to set two different 'levels' (line types) on the y-axis as well.
There are also options to have multiple additional y-axis bars (bar types).
With the x-axis being the datetime
Here is what a typical example of a chart looks like with valid date for the given range
This is working as expected.
We have the main y-series as the average air temp (left y-axis)
Then we have two bars, one for rainfall and one for irrigation (right y-axis)
And then the two 'levels', one red and one blue.
This is all great.
However, when we go to a date range in the future, where there is no air temp data, we get the following
Note that the start date is 2 days before the date range, and the end date looks equal distance from the end of the 'levels'
Interestingly if we remove the bars we get the following
This now shows the 'levels' to span the full width of the chart
If we remove the lines and just have the bars then we get the following (which is how it should look, but with the 'levels')
There seems to be something in here that is causing the conflict when there are multiple y-series without the main y-series.
I am setting the xAxis.setExtremes to the start and end dates of the date range we are looking at, but that seems to be doing nothing.
Here is the config;
{
"chart": {
"type":"line",
"animation": {
"duration":150
},
"events":{}
},
"credits":{
"enabled":false
},
"title":{
"text":""
},
"subtitle":{
"text":""
},
"tooltip":{
"shared":true,
"crosshairs":true,
"borderWidth":0,
"followPointer":true,
"useHTML":true,
"headerFormat":"<span style=\"font-size: 10px;\">{point.key}</span><br><br>"
},
"xAxis":[
{
"id":"x-axis",
"type":"datetime",
"crosshair":{
"snap":false
},
"title":{
"text":"25th Sep 2019 - 1st Oct 2019",
"margin":15
}
}
],
"yAxis":[
{
"id":"y-axis-sensors",
"title":{
"text":"ºC"
},
"reversed":false,
"visible":true,
"endOnTick":false,
"startOnTick":false,
"alignTicks":false
},
{
"id":"y-axis-moisture",
"title":{
"text":"mm"
},
"opposite":true,
"min":0,
"endOnTick":false,
"startOnTick":false,
"alignTicks":false,
"tickWidth":0,
"gridLineWidth":0
}
],
"series":[
{
"type":"line",
"yAxis":"y-axis-sensors",
"marker":{
"enabled":false
},
"lineWidth":1,
"animation":false,
"name":"Full",
"seriesGroup":"levelSeries",
"id":"series-level-range-full",
"color":"#31B5E0",
"showInLegend":false,
"states":{
"hover":{
"enabled":false
}
},
"enableMouseTracking":false,
"zIndex":5,
"step":true,
"data":[
[1569369600000,5],
[1569974400000,5]
]
},
{
"type":"line",
"yAxis":"y-axis-sensors",
"marker":{
"enabled":false
},
"lineWidth":1,
"animation":false,
"name":"Refill",
"seriesGroup":"levelSeries",
"id":"series-level-range-refill",
"color":"#D23333",
"showInLegend":false,
"states":{
"hover":{
"enabled":false
}
},
"enableMouseTracking":false,
"zIndex":5,
"step":true,
"data":[
[1569369600000,17],
[1569974400000,17]
]
},
{
"type":"column",
"yAxis":"y-axis-moisture",
"marker":{
"enabled":false
},
"name":"Rainfall",
"seriesGroup":"rainfallSeries",
"states":{
"hover":{
"enabled":false
}
},
"id":"series-rainfall",
"pointWidth":6,
"borderWidth":0,
"color":"rgba(41, 182, 246, 0.3)",
"data":[
[1569488400000,5]
],
"zIndex":10,
"stacking":"normal",
"stack":"moisture"
},
{
"type":"column",
"yAxis":"y-axis-moisture",
"marker":{
"enabled":false
},
"states":{
"hover":{
"enabled":false
}
},
"name":"Irrigation",
"seriesGroup":"irrigationSeries",
"id":"series-irrigation",
"pointWidth":6,
"borderWidth":0,
"color":"rgba(205,220,57, 0.3)",
"data":[[1569574800000,3]],
"zIndex":10,
"stacking":"normal",
"stack":"moisture"
}
]
}
I am at a bit of a loss here as to why this is happening.
Can anyone shed some light on this?
One of the solutions can be to add additional x-axis and bind line series to it. Then it looks like your expected result. Check demo and code posted below.
Code:
Highcharts.chart('container', {
"chart": {
"type": "line",
"animation": {
"duration": 150
},
"events": {}
},
"credits": {
"enabled": false
},
"title": {
"text": ""
},
"subtitle": {
"text": ""
},
"tooltip": {
"shared": true,
"crosshairs": true,
"borderWidth": 0,
"followPointer": true,
"useHTML": true,
"headerFormat": "<span style=\"font-size: 10px;\">{point.key}</span><br><br>"
},
"xAxis": [{
"id": "x-axis1",
"type": "datetime",
"crosshair": {
"snap": false
},
"title": {
"text": "25th Sep 2019 - 1st Oct 2019",
"margin": 15
}
}, {
"id": "x-axis2",
visible: false,
"type": "datetime"
}],
"yAxis": [{
"id": "y-axis-sensors",
"title": {
"text": "ºC"
},
"reversed": false,
"visible": true,
"endOnTick": false,
"startOnTick": false,
"alignTicks": false
},
{
"id": "y-axis-moisture",
"title": {
"text": "mm"
},
"opposite": true,
"min": 0,
"endOnTick": false,
"startOnTick": false,
"alignTicks": false,
"tickWidth": 0,
"gridLineWidth": 0
}
],
"series": [
{
"type": "line",
xAxis: 'x-axis2',
"yAxis": "y-axis-sensors",
"marker": {
"enabled": false
},
"lineWidth": 1,
"animation": false,
"name": "Full",
"seriesGroup": "levelSeries",
"id": "series-level-range-full",
"color": "#31B5E0",
"showInLegend": false,
"states": {
"hover": {
"enabled": false
}
},
"enableMouseTracking": false,
"zIndex": 5,
"step": true,
"data": [
[1569369600000, 5],
[1569974400000, 5]
]
},
{
"type": "line",
xAxis: 'x-axis2',
"yAxis": "y-axis-sensors",
"marker": {
"enabled": false
},
"lineWidth": 1,
"animation": false,
"name": "Refill",
"seriesGroup": "levelSeries",
"id": "series-level-range-refill",
"color": "#D23333",
"showInLegend": false,
"states": {
"hover": {
"enabled": false
}
},
"enableMouseTracking": false,
"zIndex": 5,
"step": true,
"data": [
[1569369600000, 17],
[1569974400000, 17]
]
},
{
"type": "column",
xAxis: 'x-axis1',
"yAxis": "y-axis-moisture",
"marker": {
"enabled": false
},
"name": "Rainfall",
"seriesGroup": "rainfallSeries",
"states": {
"hover": {
"enabled": false
}
},
"id": "series-rainfall",
"pointWidth": 6,
"borderWidth": 0,
"color": "rgba(41, 182, 246, 0.3)",
"data": [
[1569488400000, 5]
],
"zIndex": 10,
"stacking": "normal",
"stack": "moisture"
},
{
"type": "column",
xAxis: 'x-axis1',
"yAxis": "y-axis-moisture",
"marker": {
"enabled": false
},
"states": {
"hover": {
"enabled": false
}
},
"name": "Irrigation",
"seriesGroup": "irrigationSeries",
"id": "series-irrigation",
"pointWidth": 6,
"borderWidth": 0,
"color": "rgba(205,220,57, 0.3)",
"data": [
[1569574800000, 3]
],
"zIndex": 10,
"stacking": "normal",
"stack": "moisture"
}
]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container"></div>
Demo:
https://jsfiddle.net/BlackLabel/juwc8f37/

Export option not visible in Highcharts

When I generate my Highchart chart it generates complete. The only thing that doesn't show up is the export option.
Can anybody figure out what I am doing wrong?
Do I need to specify extra CSS styling options of some sort or include another JS script to allow this to work? I can't really figure it out at the moment.
chart1 = new Highcharts.Chart({
"chart": {
"renderTo": "container",
"type": "column"
},
"title": {
"text": "Doorlooptijd exploten"
},
"subtitle": {
"text": "Databron: Digibieb"
},
"xAxis": {
"categories": {
"2": "> xx",
"1": "< xx",
"0": "< xx"
}
},
"yAxis": {
"min": 0,
"title": {
"text": "Aantallen"
}
},
"legend": {
"layout": "vertical",
"backgroundColor": "#FFFFFF",
"align": "left",
"verticalAlign": "top",
"x": 100,
"y": 100,
"floating": 0,
"shadow": 1
},
"exporting": {
"enabled": true
},
"credits": {
"enabled": false
},
"plotOptions": {
"column": {
"pointPadding": 0.2,
"borderWidth": 0
}
},
"series": [{
"name": "asd",
"data": [1, 1, 1]
}, {
"name": "asd2",
"data": [1, 1, 1]
}, {
"name": "asd3",
"data": [1, 1, 1]
}, {
"name": "asd4",
"data": [0, 0, 25]
}, {
"name": "asd5",
"data": [54, 19, 53]
}, {
"name": "asd6",
"data": [0, 0, 4]
}, {
"name": "asd8",
"data": [22, 4, 28]
}, {
"name": "asd7",
"data": [23, 40, 19]
}, {
"name": "asd9",
"data": [23, 13, 8]
}, {
"name": "asd10",
"data": [3, 0, 0]
}]
});
You need to load the exporting.js script like this after the main Highcharts script
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
Fiddle

Using highcharts x-axis "zones" for datetime series chart

I've got a two-series Highcharts column chart that I'm trying to modify the color between past and future. I'd like the colors in past to be green, and colors in future to be blue essentially. I've read about highcharts "zones" which allow you to change attributes on the axis after a point, but the documentation uses a simple data chart, and not a datetime version like I'm using.
How can I use these zones with a datetime chart, or better-- how can I change the border/fill color of my bars for future instead of default colors used.
http://www.highcharts.com/docs/chart-concepts/series#zones
https://jsfiddle.net/x4n91jL8/
$(function () {
var colors = Highcharts.getOptions().colors;
colors[0] = 'rgba(255,255,255,0)';
colors[1] = '#7FC69E';
$('#container').highcharts({
"credits": {
"enabled": false
},
"chart": {
"renderTo": "container",
"type": "area",
"alignTicks": false,
"height": 300,
"marginLeft": 1,
"marginBottom": 1,
"backgroundColor": "transparent",
"events": {}
},
"title": {
"enabled": false,
"text": ""
},
"plotOptions": {
"series": {
"pointPadding": 0,
"groupPadding": 0.02,
"marker": {
"enabled": false
}
},
"column": {
"animation": false,
"grouping": false,
"pointPadding": 0,
"borderWidth": 0,
"allowPointSelect": false,
"events": {}
},
"line": {
"allowPointSelect": false,
"events": {}
},
"area": {
"allowPointSelect": false,
"events": {}
}
},
"legend": {
"enabled": false,
"layout": "horizontal",
"align": "center",
"verticalAlign": "top",
"floating": true,
"backgroundColor": "#FFFFFF"
},
"tooltip": {
"enabled": false,
"shared": true
},
"rangeSelector": {
"enabled": false,
"inputEnabled": true
},
"xAxis": {
"gridLineColor": "transparent",
"zIndex": 3,
"minorTickInterval": 604800000,
"minorTickPosition": "inside",
"minorTickLength": 5,
"minorTickWidth": 1,
"minorGridLineWidth": 0,
"startOnTick": false,
"gridLineWidth": 1,
"type": "datetime",
"min": 1451800000000,
"max": 1457000000000,
"labels": {
"enabled": false,
"step": 1
},
"dateTimeLabelFormats": {
"month": "%b",
"year": "%Y"
}
},
"series": [
{
"name": "Duration",
"zIndex": 3,
"type": "column",
"data": [
[
1452470400000,
6.5
],
[
1453075200000,
11.25
],
[
1453680000000,
8.25
],
[
1454284800000,
6.55
],
[
1454889600000,
1.05
],
[
1455494400000,
4.633333333333333
],
[
1456099200000,
1.1666666666666667
],
],
"tooltip": {
"yDecimals": 0
},
"borderWidth": 1,
"borderColor": "#008244",
"opacity": 0.6,
"lineWidth": 1,
"states": {
"hover": {
"lineWidth": 1
}
},
"zoneAxis": "x",
"zones": [
{
"value": 1454284800000
},
{
"borderColor": "#566888"
}
],
"_colorIndex": 0
},
{
"name": "Duration",
"zIndex": 3,
"type": "column",
"data": [
[
1454284800000,
5.216666666666667
],
[
1454889600000,
0
],
[
1455494400000,
2.6666666666666665
],
[
1456099200000,
1.1666666666666667
],
],
"tooltip": {
"yDecimals": 0
},
"borderWidth": 0,
"borderColor": "#008244",
"opacity": 0.6,
"lineWidth": 1,
"states": {
"hover": {
"lineWidth": 1
}
},
"zoneAxis": "x",
"zones": [
{
"value": 1454284800000
},
{
"fillColor": "#566888"
}
],
"_colorIndex": 1
}
],
"yAxis": [
{
"labels": {
"enabled": false
},
"opposite": false,
"gridLineWidth": 0,
"minorGridLineWidth": 0,
"showEmpty": false,
"title": {
"text": "",
"align": "middle",
"style": {
"color": "rgba(255,255,255,0)"
}
},
"lineWidth": 1,
"min": 0,
"startOnTick": false,
"endOnTick": false,
"max": 16.875,
"lineColor": "rgba(255,255,255,0)",
"index": 0
}
]
});
});
The correct format is actually like this:
And it also requires Highcharts 4.1.4 (I was using an older 4.0.4 actually).
"zones": [
{
"value": new Date().getTime(),
"color":'#7FC69E'
}
}

Resources