score:1
Accepted answer
For example, in the JSFiddle linked above i'd like to se January as a wider column instead of the thin one with an empty space on the right. Is that possible?
It is possible, however it will require a bit of custom code. The better solution is to centre the single column.
Code:
var maxGroupedColumns = 0;
Highcharts.chart('container', {
chart: {
type: 'column',
events: {
load: function() {
var newSeriesArr = [],
chart = this,
groupedSeries = {},
pointOffset;
// create a new series for each point
for (var i = chart.series.length - 1; i >= 0; i--) {
var series = chart.series[i];
var pointsInSeries = series.points.length;
for (var j = pointsInSeries - 1; j >= 0; j--) {
var point = series.points[j];
// omit the point if its y value equals to 0
if (!point.y) {
continue;
}
// make sure that x property of each point is initialized
point.options.x = point.x;
var newSeriesOptions = {
data: [point.options],
// move relevant options from the original series
color: series.color,
name: series.name,
// linking series items in legend
linkedTo: series.options.id
};
if (!groupedSeries[point.x]) {
// create group
groupedSeries[point.x] = [];
}
// create series and assign it to group
groupedSeries[point.x].push(chart.addSeries(newSeriesOptions, false));
if (groupedSeries[point.x].length > maxGroupedColumns) {
// update max grouped columns number
maxGroupedColumns = groupedSeries[point.x].length;
}
point.remove(false);
}
//series.remove(false);
series.setData([]);
}
// handle pointPlacement for each series
pointOffset = 1 / maxGroupedColumns;
for (var x in groupedSeries) {
var group = groupedSeries[x];
group.forEach(function(series, index) {
series.update({
pointPlacement: pointOffset * index - ((group.length - 1) * pointOffset) / 2,
}, false);
});
}
chart.redraw();
}
}
},
title: {
text: 'Monthly Average Temperature'
},
subtitle: {
text: 'Source: WorldClimate.com'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
title: {
text: 'Temperature (°C)'
}
},
plotOptions: {
column: {
dataLabels: {
enabled: true
},
grouping: false,
pointRange: 1,
pointPadding: 0.25,
}
},
series: [{
name: 'Tokyo',
id: 'Tokyo',
data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}, {
name: 'London',
id: 'London',
data: [null, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
}]
});
Source: stackoverflow.com
Related Query
- Highcharts, chart with two series starting in diferent points, how yo show single column?
- How to dynamically populate Highcharts column chart with two series
- Highcharts 3.0, area chart with stacked and unstacked series - how to fix?
- Highcharts can't render a bubble chart with a single series
- How to create a single series bar graph with Highcharts
- Highcharts gantt chart : Task progress indicator need to show a single task for various status like completed,inprogress etc with different colors
- How to connect to end points in two linked series in HighCharts
- Highcharts single horizontal stacked bar chart with data names (labels) and %-ages always shown and data numbers and series name shown on mousehover
- How to have multiple highcharts with different series data in vuejs without repeating code
- How to show labels selectively in certain points in Line chart of HighCharts
- Highcharts show two line series with same values
- show two different series with different start intervals with the same xAxis highcharts
- Highcharts - How show only two series on click
- how can I fill absent points in a series with average of its two neighbor points
- How to render a bar chart with different series with only one entry per category in HighCharts
- How to Create a Stacked Column Chart with Dynamic Series in Highcharts
- Highcharts - How to show two tooltips for single point at different positions of chart?
- HIGHCHARTS - Given a series with UNIX stamps and values pairs for the data, how do I show only the date for the first and last point on xAxis?
- Highcharts - how to have a chart with dynamic height?
- Highcharts doesn't display series with lots of data points
- How to show a column with the value Zero in Column chart in Highcharts?
- How To Use Epoch Time With Highcharts Series Data?
- Highcharts : Chart with drilldown how to obtain click event of drill up button
- Highcharts - best way to handle and display zero (or negative) values in a line chart series with logarithmic Y axis
- Highcharts - How can I remove starting and ending padding from area chart
- How can I delete all of the points from a highcharts series
- Highcharts - Scatter chart with a line connecting the dots in the series
- Highcharts connecting scatter chart and pie chart with single legend
- Can I sychronize two highcharts series with different years (leap year)
- Show more data on Gauge chart with Highcharts
More Query from same tag
- Highcharts CDN issue with IE8
- Updating column zIndex on legendItem mouseover/mouseout in Highcharts
- Saving images from HTML5 canvas directly
- How to display all dates with a given Start Date and End Date even if there is no data?
- HighCharts Data Structure - Multiple Independent Series, Stacked Column Chart
- Highchart is not showing in heroku, but works in local environment
- How to put data in Highchart from session storage?
- Add extra tooltip in Highcharts
- How can I change granularity in highcharts?
- JSON, Highcharts and Coldfusion json data
- In Highcharts, how to move annotations along with the chart when it changes?
- Highcharts Date Time With Irregular Intervals Down to Minutes
- How to change the point color to red that is lowest point plotted in the graph and 2nd issue is animation effect is not supporting in the ie10,ie8
- highstock mouse releaase trendline
- Highcharts add a legend for marker colors
- Puppeteer Without an HTML page?
- How to parse a string in HighMaps (Map Bubble) alongside country code?
- How to subset a table by clicking in a highcharts shiny R barplot?
- Highchart step line chart tooltip show old data when there is no data
- How to make Highchart 2 or more inner Pie but only 1 outer pie with donut type?
- Highcharts : How to apply padding between each bar on Y-axis
- controlling the resolution (dpi) of an exported JPG from highcharts exporting-server
- Fonts are not showing up in the Export server rendered files
- "Uncaught SyntaxError: Unexpected token = " ... JavaScript/HighCharts?
- Highcharts: Combined line and column chart - start / end line on left / right side, not on column chart data points
- ng serve causes error: "cannot use namespace as a type"
- Category names and the chart are not aligned in polar chart, Highcharts
- How to bind dynamic data to highcharts basic area graph
- Highcharts points and lines are missing
- Highcharts Density Dot Map Support?