score:20
The solution seems rather simple.
Just don't give the graph's a fixed width, i.e., don't define the width or set width:100%
and, unlike the demo I mention, the bar chart width and accompanying bars will shrink as much as the browser width is reduced.
score:0
try add this on the <head></head>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
score:1
An Example with bootstrap
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Highcharts data from JSON Response</title>
<style>
body{
margin-top: 30px;
margin-left:40px;
}
.col-md-4{
padding-left:5px !important;
padding-right:5px !important;
}
</style>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script type="text/javascript">
// Data gathered from http://populationpyramid.net/germany/2015/
// Age categories
var categories = ['0-4', '5-9', '10-14', '15-19',
'20-24', '25-29', '30-34', '35-39', '40-44',
'45-49', '50-54', '55-59', '60-64', '65-69',
'70-74', '75-79', '80-84', '85-89', '90-94',
'95-99', '100 + '];
$(document).ready(function () {
Highcharts.chart('container', {
chart: {
type: 'bar'
},
xAxis: [{
categories: categories,
reversed: false,
labels: {
step: 1
}
}, { // mirror axis on right side
opposite: true,
reversed: false,
categories: categories,
linkedTo: 0,
labels: {
step: 1
}
}],
yAxis: {
title: {
text: null
},
labels: {
formatter: function () {
return Math.abs(this.value) + '%';
}
}
},
plotOptions: {
series: {
stacking: 'normal'
}
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + ', age ' + this.point.category + '</b><br/>' +
'Population: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0);
}
},
series: [{
name: 'Male',
data: [-2.2, -2.2, -2.3, -2.5, -2.7, -3.1, -3.2,
-3.0, -3.2, -4.3, -4.4, -3.6, -3.1, -2.4,
-2.5, -2.3, -1.2, -0.6, -0.2, -0.0, -0.0]
}, {
name: 'Female',
data: [2.1, 2.0, 2.2, 2.4, 2.6, 3.0, 3.1, 2.9,
3.1, 4.1, 4.3, 3.6, 3.4, 2.6, 2.9, 2.9,
1.8, 1.2, 0.6, 0.1, 0.0]
}]
});
Highcharts.chart('container2', {
chart: {
type: 'bar'
},
title: {
text: 'Population pyramid for Germany, 2015'
},
subtitle: {
text: 'Source: <a href="http://populationpyramid.net/germany/2015/">Population Pyramids of the World from 1950 to 2100</a>'
},
xAxis: [{
categories: categories,
reversed: false,
labels: {
step: 1
}
}, { // mirror axis on right side
opposite: true,
reversed: false,
categories: categories,
linkedTo: 0,
labels: {
step: 1
}
}],
yAxis: {
title: {
text: null
},
labels: {
formatter: function () {
return Math.abs(this.value) + '%';
}
}
},
plotOptions: {
series: {
stacking: 'normal'
}
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + ', age ' + this.point.category + '</b><br/>' +
'Population: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0);
}
},
series: [{
name: 'Male',
data: [-2.2, -2.2, -2.3, -2.5, -2.7, -3.1, -3.2,
-3.0, -3.2, -4.3, -4.4, -3.6, -3.1, -2.4,
-2.5, -2.3, -1.2, -0.6, -0.2, -0.0, -0.0]
}, {
name: 'Female',
data: [2.1, 2.0, 2.2, 2.4, 2.6, 3.0, 3.1, 2.9,
3.1, 4.1, 4.3, 3.6, 3.4, 2.6, 2.9, 2.9,
1.8, 1.2, 0.6, 0.1, 0.0]
}]
});
Highcharts.chart('container3', {
chart: {
type: 'bar'
},
title: {
text: 'Population pyramid for Germany, 2015'
},
subtitle: {
text: 'Source: <a href="http://populationpyramid.net/germany/2015/">Population Pyramids of the World from 1950 to 2100</a>'
},
xAxis: [{
categories: categories,
reversed: false,
labels: {
step: 1
}
}, { // mirror axis on right side
opposite: true,
reversed: false,
categories: categories,
linkedTo: 0,
labels: {
step: 1
}
}],
yAxis: {
title: {
text: null
},
labels: {
formatter: function () {
return Math.abs(this.value) + '%';
}
}
},
plotOptions: {
series: {
stacking: 'normal'
}
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + ', age ' + this.point.category + '</b><br/>' +
'Population: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0);
}
},
series: [{
name: 'Male',
data: [-2.2, -2.2, -2.3, -2.5, -2.7, -3.1, -3.2,
-3.0, -3.2, -4.3, -4.4, -3.6, -3.1, -2.4,
-2.5, -2.3, -1.2, -0.6, -0.2, -0.0, -0.0]
}, {
name: 'Female',
data: [2.1, 2.0, 2.2, 2.4, 2.6, 3.0, 3.1, 2.9,
3.1, 4.1, 4.3, 3.6, 3.4, 2.6, 2.9, 2.9,
1.8, 1.2, 0.6, 0.1, 0.0]
}]
});
})
</script>
</head>
<body>
<div class="col-md-12 row">
<div class="col-md-4">
hello
</div>
<div class="col-md-8 row">
<div class="col-md-4"><div id="container" style="height: 400px;border:1px solid;"></div></div> <div class="col-md-4"><div id="container2" style="height: 400px;border:1px solid;"></div></div>
<div class="col-md-4"><div id="container3" style="height: 400px;border:1px solid;"></div></div>
</div>
</div>
</body>
</html>
score:2
You can set the chart container div width:100%
.
Then just remove the highchart width property. I resolved it for a sparkline chart. Now it is mobile responsive.
Highcharts.chart('my-sparkline-chart, {
chart: {
type: 'areaspline',
height: '70',
//width: '189', //comment width property.
spacing: [0, 0, 0, 0],
backgroundColor: "transparent"
}
...
score:4
It probably depends on which types of charts that you are displaying. On mobile, if you're displaying a column chart, you might want to rotate the chart so that it becomes a bar chart.
If you're displaying a line chart, you could "scope" the data, so that you're only displaying the least amount of points needed to get the point across. As you zoom in, re-scope the data to fit the current view. This can be done using some events combined with some hand rolled js.
Source: stackoverflow.com
Related Query
- Making Highcharts.js charts look good on mobile and desktop
- How to Increase minimum point value and the color of series in advanced accessible charts in Highcharts by making it traverse
- Highcharts - Global configuration with common code and unique data & Headings
- drilldown maps and funnell charts on the same page using highcharts
- Highcharts shared tooltip between charts with multiple series and shared tooltip
- JQuery mobile and highcharts integration
- Use of DotNet HighCharts dll to make charts in code behind
- How do i make connectors (lines connecting datalabels) of piechart in Highcharts look straight lines and not curved?
- making title in highcharts clickable and work with bootstrap popover?
- how to show column and area charts with different y axis with same category and same x axis in highcharts
- Not able to render the charts in pdf using Wickedpdf and Highcharts in rails 2.3 app
- HighCharts issues in Dual axes, line and column charts
- Switch between pie charts and bar chart in highcharts
- Highcharts - Multiple Charts On Mobile Page
- HighCharts - making a Pie with MySQL and PHP
- HTML table as data source for highstock charts using highcharts
- Different ToolTip text For Links and Nodes in Highcharts Sankey Charts
- Highcharts to get Combined Bar and line charts
- Converted PHP code that built an array to JS and now highcharts doesn't work - what did I do wrong?
- Highcharts Highstock How to Plot OHLC and Line Charts from One Set of Embedded CSV Data Using Series Map Tools?
- How to scrape data from Highcharts charts using selenium and python?
- Why code of Horizonal line(y-axis) on a single in Highcharts get applied to all other charts integrated with Webdatarocks
- How to change tick and minorTick color in different interval in highcharts gauge charts
- Making Highcharts look like progress bar with more than one series
- Align second scatter series to the side similar to how column and bar charts do using HighCharts
- Controlling Highcharts bar chart look and layout
- Highcharts and jQuery Mobile Pages
- Highcharts prevent page on mobile Safari from moving up and down as I scroll horizontally through data points
- how can I use rangeselector and navigation in highcharts in the given code
- Why do my Highcharts stacked areaspline charts look funny?
More Query from same tag
- Highcharts: how to move item legend position dynamically
- JSON output for highcharts
- Call asynchronous functions inside loop
- Coloring a label depending on color of slice and using distance
- why is my ionic not responding with the waterfall diagram highchart
- Splines with Grouped Columns highcharts
- Is there way to make one column wider than others?
- Set series color based on X axis on a column Highchart
- Highcharts not plotting textbox values
- High Charts xAxis first label repeating on all ticks
- Html not rendering chart
- Highcharts series visibility with csv data source
- Why did the Highcharts export menu disappear when I moved the button?
- How to scale Highcharts height on window resize with React
- Highcharts packed bubble chart not working for negative values
- Scatter chart using HTML and Java Script (makeing y axis starting from zero (upside down) )
- Highcharts 'bindAxis' for one chart only
- how to sort and select top 5 elements in a json array using angular JS
- Datetime format for series - Highcharts
- rerender view when model property change in EmberJS
- Highchart/Highstock Data sampling
- How to plot Highcharter side by side in RStudio Viewer?
- Highcharts with json from django query not rendered
- Bar chart label alignment for all the zero values
- Highcharts multi-color line
- Set datetime measure unit in Highcharts
- Navigator in highcharts graph does not work
- Make chart.renderer.path as plotline Highcharts
- DOM Node count increase when loading Highcharts documents (Chrome)
- Datalabels fontSize and position : different results depending on browser