Bar High Chart with different positive and negative scale interval values - highcharts
Highcharts.chart('container', {
credits: {
enabled: false,
},
legend: {
enabled: false
},
chart: {
type: "bar",
height: 180,
reflow: false,
alignTicks: false,
},
title: {
text: null
},
accessibility: {
point: {
valueDescriptionFormat: "{index}. Agency {xDescription}, {y}%.",
},
},
xAxis: {
visible: false,
},
yAxis: [
{
tickPositioner: function() {
let step = 50,
step2 =250,
ret = [],
ret2 = [],
arr=[]
for (var i = this.min; i <= 0; i+= step) {
ret.push(i);
}
for (var i = 0; i <= this.max; i+= step2) {
ret2.push(i);
}
arr= ret.concat(ret2)
return arr;
},
title: {
text: null,
},
linkedTo: 0,
labels: {
enabled:true,
step: 1
},
accessibility: {
description: "Percentage population",
rangeDescription: "Range: 0 to 5%",
},
},
],
plotOptions: {
series: {
stacking: "normal",
dataLabels: {
enabled: true,
inside: true,
formatter: function() {
return (this.y > 1000) ? Highcharts.numberFormat(this.y / 1000, 3) + "K": this.y;
},
style: {
fontWeight: 'normal'
}
},
},
},
tooltip: {
formatter: function () {
return (
// "<b>" +
// this.point.series.data.map(x=>x.y) +
// "</b><br/>" +
"Segment: " +
Highcharts.numberFormat(Math.abs(this.point.y), 1) +
""
);
},
},
series: [
{
type: "bar",
// name: (segment[0] && segment[4])?"Top Agencies":"Bottom Agencies",
borderRadius: 12,
pointPadding: 0,
groupPadding: 0.05,
color: {//set le5end point color
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#46a4eb"],
[1, "#6cbdfb"],
],
},
data: [
{
y: 2000,
title:"HIII",
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#46a4eb"],
[1, "#6cbdfb"],
],
},
custom: {
// text: "BTS",
// score: "27,000",
text:"Abc",
score:2000,
},
},
{
y: 1000,
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#46a4eb"],
[1, "#6cbdfb"],
],
},
custom: {
text:"Abc",
score:1000
},
},
{
y: 1300,
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#46a4eb"],
[1, "#6cbdfb"],
],
},
custom: {
text:"CVB",
score:1300
},
},
{
y:1400,
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#46a4eb"],
[1, "#6cbdfb"],
],
},
custom: {
text:"Abc",
score:1400
},
},
{
y:760,
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#46a4eb"],
[1, "#6cbdfb"],
],
},
custom: {
text:"Abc",
score:760
},
},
{
y: 900,
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#f48686"],
[1, "#f05e5e"],
],
},
custom: {
text:"Jhd",
// score:"6000",
score:900
},
},
{
y:-50,
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#f48686"],
[1, "#f05e5e"],
],
},
custom: {
text:"Uit",
score:-50
},
},
{
y: -40,
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#f48686"],
[1, "#f05e5e"],
],
},
custom: {
text:"TPS",
score:-40
},
},
{
y: -15,
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#f48686"],
[1, "#f05e5e"],
],
},
custom: {
text:"Pop",
score:-15
},
},
{
y: -10,
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#f48686"],
[1, "#f05e5e"],
],
},
custom: {
text:"BVC",
score:-10
},
},
],
dataLabels: [
{
align: "left",
format: "({point.custom.score})",
enabled: true,
padding: 15,
color: "#FFFFFF",
style: {
fontSize: "10px",
textShadow: false,
textOutline: "0",
fontWeight: "light",
fontFamily: 'Muli',
},
},
{
align: "right",
format: "{point.custom.text}",
padding: 15,
style: {
fontSize: "10px",
textShadow: false,
textOutline: "0",
fontWeight: "light",
fontFamily: 'Muli',
},
},
],
},
],
});
.highcharts-figure, .highcharts-data-table table {
min-width: 310px;
max-width: 800px;
margin: 1em auto;
}
#container {
height: 400px;
}
.highcharts-data-table table {
font-family: Verdana, sans-serif;
border-collapse: collapse;
border: 1px solid #EBEBEB;
margin: 10px auto;
text-align: center;
width: 100%;
max-width: 500px;
}
.highcharts-data-table caption {
padding: 1em 0;
font-size: 1.2em;
color: #555;
}
.highcharts-data-table th {
font-weight: 600;
padding: 0.5em;
}
.highcharts-data-table td, .highcharts-data-table th, .highcharts-data-table caption {
padding: 0.5em;
}
.highcharts-data-table thead tr, .highcharts-data-table tr:nth-child(even) {
background: #f8f8f8;
}
.highcharts-data-table tr:hover {
background: #f1f7ff;
}
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
<p class="highcharts-description">
Bar chart showing horizontal columns. This chart type is often
beneficial for smaller screens, as the user can scroll through the data
vertically, and axis labels are easy to read.
</p>
</figure>
My requirement is I want to make a Bar chart with different interval ranges of positive and negative y-axis. Like for positive y-axis my interval range is around 250+ and for negative y-axis my range is around 15-20 or it sets ranges according to the given data dynamically.
Another issue is I have somehow manage to solve the above given issue but my origin is displacing from center so in short I want to keep my origin at the center with different ranges of positive and negative y-axis.
Is there any possibility to limit the width of +y-axis and -y-axis to center the origin ?
Here's code pen link barchart
This is my graph
This is what I want even if positive value is too high or negative value is too low.
Code is here
export const getAgencyChartOption = (data) =>{
let name=data.map(x=>x.agenciesName)
let segment=data.map(x=>x.segments)
let obj: Highcharts.Options = {
credits: {
enabled: false,
},
legend: {
enabled: false
},
chart: {
type: "bar",
height: 180,
reflow: false,
alignTicks: false,
},
title: {
text: null
},
accessibility: {
point: {
valueDescriptionFormat: "{index}. Agency {xDescription}, {y}%.",
},
},
xAxis: {
visible: false,
},
yAxis: [
{
tickPositioner: function() {
let step = 50,
step2 =250,
ret = [],
ret2 = [],
arr=[]
for (var i = this.min; i <= 0; i+= step) {
ret.push(i);
}
for (var i = 0; i <= this.max; i+= step2) {
ret2.push(i);
}
arr= ret.concat(ret2)
return arr;
},
title: {
text: null,
},
linkedTo: 0,
labels: {
enabled:true,
step: 1
},
accessibility: {
description: "Percentage population",
rangeDescription: "Range: 0 to 5%",
},
},
],
plotOptions: {
series: {
stacking: "normal",
dataLabels: {
enabled: true,
inside: true,
formatter: function() {
return (this.y > 1000) ? Highcharts.numberFormat(this.y / 1000, 3) + "K": this.y;
},
style: {
fontWeight: 'normal'
}
},
},
},
tooltip: {
formatter: function () {
return (
// "<b>" +
// this.point.series.data.map(x=>x.y) +
// "</b><br/>" +
"Segment: " +
Highcharts.numberFormat(Math.abs(this.point.y), 1) +
""
);
},
},
series: [
{
type: "bar",
// name: (segment[0] && segment[4])?"Top Agencies":"Bottom Agencies",
borderRadius: 12,
pointPadding: 0,
groupPadding: 0.05,
color: {//set le5end point color
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#46a4eb"],
[1, "#6cbdfb"],
],
},
data: [
{
y: Number(segment[0]),
title:"HIII",
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#46a4eb"],
[1, "#6cbdfb"],
],
},
custom: {
// text: "BTS",
// score: "27,000",
text:name[0],
score:segment[0]
},
},
{
y: Number(segment[1]),
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#46a4eb"],
[1, "#6cbdfb"],
],
},
custom: {
text:name[1],
score:segment[1]
},
},
{
y: Number(segment[2]),
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#46a4eb"],
[1, "#6cbdfb"],
],
},
custom: {
text:name[2],
score:segment[2]
},
},
{
y: Number(segment[ 3]),
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#46a4eb"],
[1, "#6cbdfb"],
],
},
custom: {
text:name[3],
score:segment[3]
},
},
{
y: Number(segment[4]),
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#46a4eb"],
[1, "#6cbdfb"],
],
},
custom: {
text:name[4],
score:segment[4]
},
},
{
y: Number(segment[5]),
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#f48686"],
[1, "#f05e5e"],
],
},
custom: {
text:name[5],
// score:"6000",
score:segment[5]
},
},
{
y: Number(segment[6]),
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#f48686"],
[1, "#f05e5e"],
],
},
custom: {
text:name[6],
score:segment[6]
},
},
{
y: Number(segment[7]),
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#f48686"],
[1, "#f05e5e"],
],
},
custom: {
text:name[7],
score:segment[7]
},
},
{
y: Number(segment[8]),
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#f48686"],
[1, "#f05e5e"],
],
},
custom: {
text:name[8],
score:segment[8]
},
},
{
y: Number(segment[9]),
color: {
linearGradient: { x1: 0, x2: 1, y1: 0, y2: 1 },
stops: [
[0, "#f48686"],
[1, "#f05e5e"],
],
},
custom: {
text:name[9],
score:segment[9]
},
},
],
dataLabels: [
{
align: "left",
format: "({point.custom.score})",
enabled: true,
padding: 15,
color: "#FFFFFF",
style: {
fontSize: "10px",
textShadow: false,
textOutline: "0",
fontWeight: "light",
fontFamily: 'Muli',
},
},
{
align: "right",
format: "{point.custom.text}",
padding: 15,
style: {
fontSize: "10px",
textShadow: false,
textOutline: "0",
fontWeight: "light",
fontFamily: 'Muli',
},
},
],
},
],
}
return obj
}
Related
Highcharts. Indentation and formatting issues
I want to make the graph start at 0 (as shown in the picture) and have the string formatted according to the regular expression replace(/\B(?=(\d{3})+(?!\d))/g, " ") but all my attempts are unsuccessful. chartOptions: { colors: ['#3DC3FB', '#FF5252', '#D2F449', '#179877'], title: { text: "", }, credits: { enabled: false }, tooltip: { formatter: function () { if (this.x > 0) { return this.x; } else return false; }, }, plotOptions: { series: { enableMouseTracking: false, states: { hover: { enabled: false }, normal: { animation: false }, select: { enabled: false } } }, }, xAxis: { gridLineWidth: 1, tickmarkPlacement: 'on', lineColor: "#A4A4A4", min: 0, categories: [null, "10 лет"], top: 10, right: -100, title: { style: { color: "#A4A4A4" } }, }, yAxis: { gridLineWidth: 0, tickColor: 'undefined', tickLength: 5, tickWidth: 1, tickPosition: 'outside', lineWidth: 1, lineColor: '#A4A4A4', min: 3, title: { text: "Доход от инвестиций", margin: 10, align: "low", style: { color: "#A4A4A4" }, y: -50, }, labels: { enabled: false, }, }, legend: {enabled: false}, marker: { enabled: false, symbol: 'circle', radius: 12, states: { hover: { fillColor: 'white', lineColor: 'green', lineWidth: 0 } } }, series: [ { type: 'line', name: "ВДело", data: [0, 1100], dataLabels: { x: -100, y: 5, enabled: true, // useHTML: true, format: `{point.y}/мес`, formatter: function () { return Highcharts.numberFormat(this.y,2); }, color: "#3DC3FB", style:{ fontSize: 20, lineHeight: 18, fontWeight: 500, fontFamily: 'Gilroy', fontStyle: 'normal', } }, animation: { defer: 1 }, marker: { symbol: 'circle', radius: 4, states: { hover: { fillColor: '#3DC3FB', lineColor: 'green', lineWidth: 0 } } }, }, { type: 'line', name: "Акции", data: [0, 550], animation: { defer: 1 }, marker: { symbol: 'circle', radius: 4, states: { hover: { fillColor: '#FF5252', lineColor: 'green', lineWidth: 0 } } }, }, { type: 'line', name: "Облигации", data: [0, 366], animation: { defer: 1 }, marker: { symbol: 'circle', radius: 4, states: { hover: { fillColor: '#D2F449', lineColor: 'green', lineWidth: 0 } } }, }, { type: 'line', name: "Депозит", data: [0, 275], animation: { defer: 1 }, marker: { symbol: 'circle', radius: 4, states: { hover: { fillColor: '#179877', lineColor: 'green', lineWidth: 0 } } }, }, ], }, I am new to highcharts and have a hard time with huge documentation. help me please
Understood the cost of his sleep. For those who will be interested. So that the graph starts like in the picture. plotOptions: { series: { findNearestPointBy: 'x', label: { connectorAllowed: false }, pointPlacement: 'on' } } and { type: 'line', name: "ВДело", data: [0, 1100], dataLabels: { x: -50, y: -10, enabled: true, format: `{point.y}/мес`, pointFormat: ' <b>{point.y:,.0f}/мес</b>', shared: true, color: "#3DC3FB", style:{ fontSize: 20, lineHeight: 18, fontWeight: 500, fontFamily: 'Gilroy', fontStyle: 'normal', } },
When it comes to the place to start the chart in the category axis, you need to only change xAxis.min to 0.5 Sample code: xAxis: { min: 0.5, tickmarkPlacement: 'on', type: 'category' }, Simplified demo: https://jsfiddle.net/BlackLabel/jt1gqrnb/
Highcharts - How to show intermediate values on Area chart
I have the following chart: https://jsfiddle.net/w7jm2n6u/ Highcharts.chart('container', { chart: { type: 'area', zoomType: 'x' }, exporting: { enabled: false }, title: { text: '' }, legend: { enabled: false }, xAxis: { type: 'datetime', title: { enabled: false }, min: Date.UTC(2018, 10, 1) }, yAxis: { title: { enabled: false }, labels: { formatter: function() { return this.value / 1000; } }, max: 2000 }, tooltip: { split: false, }, plotOptions: { area: { lineWidth: 1, marker: { enabled: false, states: { hover: { enabled: false } } }, }, series: { trackByArea: true, stickyTracking: false, } }, series: [{ name: 'Exceeds', color: '#0000FF', fillOpacity: 1, marker: { enabled: false, }, data: [ { x: Date.UTC(2018, 8, 1), y: 2000 },{ x: Date.UTC(2019, 0, 1), y: 2000 }, { x: Date.UTC(2019, 1, 1), y: 2000 }, { x: Date.UTC(2019, 2, 1), y: 2000 }], }, { name: 'Meets', color: '#00FF00', fillOpacity: 1, marker: { enabled: false, }, data: [ { x: Date.UTC(2018, 8, 1), y: 700 },{ x: Date.UTC(2019, 0, 1), y: 800 }, { x: Date.UTC(2019, 1, 1), y: 700 }, { x: Date.UTC(2019, 2, 1), y: 800 }], }, { name: 'Minimum', color: '#FFFF00', fillOpacity: 1, marker: { enabled: false, }, data: [ { x: Date.UTC(2018, 8, 1), y: 400 },{ x: Date.UTC(2019, 0, 1), y: 400 }, { x: Date.UTC(2019, 1, 1), y: 400 }, { x: Date.UTC(2019, 2, 1), y: 400 }], }, { name: 'Below Minimum', color: '#FF0000', fillOpacity: 1, marker: { enabled: false, }, data: [ { x: Date.UTC(2018, 8, 1), y: 100 },{ x: Date.UTC(2019, 0, 1), y: 200 }, { x: Date.UTC(2019, 1, 1), y: 300 }, { x: Date.UTC(2019, 2, 1), y: 320 }], }, { name: 'Data', color: '#000000', type: 'line', data: [{ x: Date.UTC(2019, 0, 3), y: 50 }, { x: Date.UTC(2019, 0, 15), y: 500 }, { x: Date.UTC(2019, 1, 4), y: 1000 }, { x: Date.UTC(2019, 1, 15), y: 1400 }, { x: Date.UTC(2019, 1, 28), y: 1900 }, ] }, ] }); Ideally, I would like to be able to hover over each area and see a tooltip with the value at that point in time for each of the 4 areas. For instance, between January 1st and February 1st, the Below Minimum (red) value ranges from 200 to 300. If I were to put my mouse halfway between those dates, I would want to see 'Below Minimum: 250'. Is there a way to achieve this? If not, I would at least like the current tooltip to always show the previous point value instead of whichever it is closest to. If I hover around 12/2018, I want to see the point from Sept 1, 2018, not January 1, 2019. Essentially these are start dates for the values and are only valid on or after the date.
You need to increase the density of points. Below you can find an example how you can do it programmatically: chart: { type: 'area', events: { load: function() { var series = this.series, iterations = 2, i = 0, newData = []; for (; i < iterations; i++) { series.forEach(function(s) { newData = []; s.points.forEach(function(p, j) { if (j) { newData.push( [ s.points[j - 1].x + (p.x - s.points[j - 1].x) / 2, s.points[j - 1].y + (p.y - s.points[j - 1].y) / 2 ], [p.x, p.y] ); } else { newData.push([p.x, p.y]); } }); s.setData(newData, false); }); this.redraw(false); } } } }, Live demo: https://jsfiddle.net/BlackLabel/d8jq9bvh/ API Reference: https://api.highcharts.com/highcharts/chart.events.load
How do I not show GMT and Timezone labels for Highcharts
As shown below: Instead of that I want the x-axis labels to look something like this: Without the GMT and time-zone. Sorry I am new to Highcharts ! EDIT: added code Highcharts.theme = { colors: ["#2b908f", "#90ee7e", "#f45b5b", "#7798BF", "#aaeeee", "#ff0066", "#eeaaee", "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"], chart: { backgroundColor: { linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 }, stops: [ [0, '#2a2a2b'], [1, '#3e3e40'] ] }, style: { fontFamily: "'Unica One', sans-serif" }, plotBorderColor: '#606063' }, title: { style: { color: '#E0E0E3', textTransform: 'uppercase', fontSize: '20px' } }, subtitle: { style: { color: '#E0E0E3', textTransform: 'uppercase' } }, xAxis: { type: 'datetime', dateTimeLabelFormats: { month: '%e. %b' }, gridLineColor: '#707073', labels: { style: { color: '#E0E0E3' } }, lineColor: '#707073', minorGridLineColor: '#505053', tickColor: '#707073', title: { style: { color: '#A0A0A3' } } }, yAxis: { gridLineColor: '#707073', labels: { style: { color: '#E0E0E3' } }, lineColor: '#707073', minorGridLineColor: '#505053', tickColor: '#707073', tickWidth: 1, title: { style: { color: '#A0A0A3' } } }, tooltip: { backgroundColor: 'rgba(0, 0, 0, 0.85)', style: { color: '#F0F0F0' } }, plotOptions: { series: { dataLabels: { color: '#B0B0B3' }, marker: { lineColor: '#333' } }, boxplot: { fillColor: '#505053' }, candlestick: { lineColor: 'white' }, errorbar: { color: 'white' } }, credits: { style: { color: '#666' } }, labels: { style: { color: '#707073' } }, drilldown: { activeAxisLabelStyle: { color: '#F0F0F3' }, activeDataLabelStyle: { color: '#F0F0F3' } }, navigation: { buttonOptions: { symbolStroke: '#DDDDDD', theme: { fill: '#505053' } } }, navigator: { handles: { backgroundColor: '#666', borderColor: '#AAA' }, outlineColor: '#CCC', maskFill: 'rgba(255,255,255,0.1)', series: { color: '#7798BF', lineColor: '#A6C7ED' }, xAxis: { gridLineColor: '#505053' } }, scrollbar: { barBackgroundColor: '#808083', barBorderColor: '#808083', buttonArrowColor: '#CCC', buttonBackgroundColor: '#606063', buttonBorderColor: '#606063', rifleColor: '#FFF', trackBackgroundColor: '#404043', trackBorderColor: '#404043' }, global: { useUTC: false }, // special colors for some of the legendBackgroundColor: 'rgba(0, 0, 0, 0.5)', background2: '#505053', dataLabelsColor: '#B0B0B3', textColor: '#C0C0C0', contrastTextColor: '#F0F0F3', maskColor: 'rgba(255,255,255,0.3)' }; Highcharts.setOptions(Highcharts.theme); //////////////////// $('#high').highcharts({ chart: { borderColor: '#EBBA95', borderRadius: 20, borderWidth: 2, zoomType: 'x', spacingTop: 40 }, title: { text: 'Humidity/Temperature Graph', x: -20, //center y: 5 }, subtitle: { text: 'Elemental Electronics | Click and drag to zoom', x: -20, }, xAxis: { type: 'datetime', dateTimeLabelFormats: { month: '%e. %b' }, categories: yearSeries, }, yAxis: { title: { text: 'All points on one graph' }, plotBands: [ { color: 'orange', // Color value from: 0, // Start of the plot band to: -25 // End of the plot band ,label: { text: 'Lower Range: 1 ppm', color: '#ffffff', align: 'left' } }, { label: { text: 'Upper Range: 5ppm', color: '#ffffff', align: 'left' }, color: 'orange', // Color value from: 75, // Start of the plot band to: 100// End of the plot band } ], }, tooltip: { valueSuffix: '°C' }, series: [ { name: 'Temperature', textColor: '#ffffff', data: mySeriestemp } ], }); }); mySeriestemp and yearSeries are both from arrays that I got using: for (var i = 0; i < year.length; i++) { yearSeries.push(new Date(year[i])); mySeriestemp.push(temp[i]); }
update As I seen your code you need to add following labels: { formatter: function() { return Highcharts.dateFormat('%e. %b', this.value); } See the working fiddle with your code Use this xAxis: { type: 'datetime', dateTimeLabelFormats: { month: '%e. %b' } }
formatter function needs to added here to show the labels in desired format labels: { formatter: function() { return Highcharts.dateFormat('%e. %b', this.value); }
HIghCharts. DataLables not show. IE8
I am using Highcharts gauges. Work perfectly in Chrome. however the gauge datalable does not appear in IE8. how to display solidgauge's datalabels of highcharts in IE8? in chrome, datalabels display OK. thanks in advance.. <script type="text/javascript"> $(function () { /** * Dark theme for Highcharts JS * #author Torstein Honsi */ // Load the fonts Highcharts.createElement('link', { href: 'http://fonts.googleapis.com/css?family=Unica+One', rel: 'stylesheet', type: 'text/css' }, null, document.getElementsByTagName('head')[0]); Highcharts.theme = { colors: ["#2b908f", "#90ee7e", "#f45b5b", "#7798BF", "#aaeeee", "#ff0066", "#eeaaee", "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"], chart: { backgroundColor: { linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 }, stops: [ [0, '#2a2a2b'], [1, '#3e3e40'] ] }, style: { fontFamily: "'Unica One', sans-serif" }, plotBorderColor: '#606063' }, title: { style: { color: '#E0E0E3', textTransform: 'uppercase', fontSize: '20px' } }, subtitle: { style: { color: '#E0E0E3', textTransform: 'uppercase' } }, xAxis: { gridLineColor: '#707073', labels: { style: { color: '#E0E0E3' } }, lineColor: '#707073', minorGridLineColor: '#505053', tickColor: '#707073', title: { style: { color: '#A0A0A3' } } }, yAxis: { gridLineColor: '#707073', labels: { style: { color: '#E0E0E3' } }, lineColor: '#707073', minorGridLineColor: '#505053', tickColor: '#707073', tickWidth: 1, title: { style: { color: '#A0A0A3' } } }, tooltip: { backgroundColor: 'rgba(0, 0, 0, 0.85)', style: { color: '#F0F0F0' } }, plotOptions: { series: { dataLabels: { color: '#B0B0B3' }, marker: { lineColor: '#333' } }, boxplot: { fillColor: '#505053' }, candlestick: { lineColor: 'white' }, errorbar: { color: 'white' } }, legend: { itemStyle: { color: '#E0E0E3' }, itemHoverStyle: { color: '#FFF' }, itemHiddenStyle: { color: '#606063' } }, credits: { style: { color: '#666' } }, labels: { style: { color: '#707073' } }, drilldown: { activeAxisLabelStyle: { color: '#F0F0F3' }, activeDataLabelStyle: { color: '#F0F0F3' } }, navigation: { buttonOptions: { symbolStroke: '#DDDDDD', theme: { fill: '#505053' } } }, // scroll charts rangeSelector: { buttonTheme: { fill: '#505053', stroke: '#000000', style: { color: '#CCC' }, states: { hover: { fill: '#707073', stroke: '#000000', style: { color: 'white' } }, select: { fill: '#000003', stroke: '#000000', style: { color: 'white' } } } }, inputBoxBorderColor: '#505053', inputStyle: { backgroundColor: '#333', color: 'silver' }, labelStyle: { color: 'silver' } }, navigator: { handles: { backgroundColor: '#666', borderColor: '#AAA' }, outlineColor: '#CCC', maskFill: 'rgba(255,255,255,0.1)', series: { color: '#7798BF', lineColor: '#A6C7ED' }, xAxis: { gridLineColor: '#505053' } }, scrollbar: { barBackgroundColor: '#808083', barBorderColor: '#808083', buttonArrowColor: '#CCC', buttonBackgroundColor: '#606063', buttonBorderColor: '#606063', rifleColor: '#FFF', trackBackgroundColor: '#404043', trackBorderColor: '#404043' }, // special colors for some of the legendBackgroundColor: 'rgba(0, 0, 0, 0.5)', background2: '#505053', dataLabelsColor: '#B0B0B3', textColor: '#C0C0C0', contrastTextColor: '#F0F0F3', maskColor: 'rgba(255,255,255,0.3)' }; // Apply the theme Highcharts.setOptions(Highcharts.theme); var gaugeOptions = { chart: { type: 'solidgauge', }, title: null, pane: { center: ['50%', '85%'], size: '140%', startAngle: -90, endAngle: 90, background: { backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE', innerRadius: '60%', outerRadius: '100%', shape: 'arc' } }, tooltip: { enabled: false }, // the value axis yAxis: { stops: [ [0.1, '#55BF3B'], // green [0.5, '#DDDF0D'], // yellow [0.9, '#DF5353'] // red ], lineWidth: 0, minorTickInterval: null, tickPixelInterval: 400, tickWidth: 0, title: { y: -70, }, labels: { y: 16, } }, plotOptions: { solidgauge: { dataLabels: { enabled:true, useHTML: true, backgroundColor:'#000000', color:'#FF6699', crop:false, } } } }; // The speed gauge $('#container-speed').highcharts(Highcharts.merge(gaugeOptions, { yAxis: { min: 0, max: 200, title: { text: 'Speed' } }, credits: { enabled: false }, series: [{ name: 'Speed', data: [80], dataLabels: { enabled:true, backgroundColor:'#000000', color:'#FF6699', crop:false, style: { color: '#FF6699', fontWeight: 'bold', fontSize:'25px' } }, tooltip: { valueSuffix: ' km/h' } }] })); // The RPM gauge $('#container-rpm').highcharts(Highcharts.merge(gaugeOptions, { yAxis: { min: 0, max: 5, title: { text: 'RPM' } }, series: [{ name: 'RPM', data: [1], dataLabels: { format: '<div style="text-align:center"><span style="font-size:25px;color:' + ((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y:.1f}</span><br/>' + '<span style="font-size:12px;color:silver">* 1000 / min</span></div>' }, tooltip: { valueSuffix: ' revolutions/min' } }] })); // Bring life to the dials setInterval(function () { // Speed var chart = $('#container-speed').highcharts(); if (chart) { var point = chart.series[0].points[0], newVal, inc = Math.round((Math.random() - 0.5) * 100); newVal = point.y + inc; if (newVal < 0 || newVal > 200) { newVal = point.y - inc; } point.update(newVal); } // RPM chart = $('#container-rpm').highcharts(); if (chart) { var point = chart.series[0].points[0], newVal, inc = Math.random() - 0.5; newVal = point.y + inc; if (newVal < 0 || newVal > 5) { newVal = point.y - inc; } point.update(newVal); } }, 2000); }); </script> <script src="http://code.highcharts.com/highcharts.js"></script> <script src="http://code.highcharts.com/highcharts-more.js"></script> <script src="http://code.highcharts.com/modules/solid-gauge.src.js"></script> <div style="width: 600px; height: 400px; margin: 0 auto; " > <div id="container-speed" style="width: 300px; height: 200px; float: left; "></div> <div id="container-rpm" style="width: 300px; height: 200px; float: left; "></div> </div>
highcharts start from hinges base
Is it possible to start the line from the hinges base ? I have looked everywhere and couldnt find a solution for it here is my code jQuery('#chart').highcharts({ colors: ['#f5781e', '#7b3186'], navigation: { buttonOptions: { enabled: false } }, credits: { enabled: false }, chart: { type: 'line', marginRight: 0, marginBottom: 35, width: 700, height: 280, }, title: { text: '', x: -20 //center }, subtitle: { text: '', x: -20 }, xAxis: { categories: ['1','2','3','4','5','6','7','8'], alternateGridColor: '#f4f6f5', lineColor: '#000000', lineWidth: 1, min: 0, }, yAxis: { title: { text: '' }, labels: { useHTML : true, format: '<span class="axis"><span class="flright">{value}</span>אלף</span>' }, tickInterval: 3, max: 35.2, plotLines: [{ value: 1, width: 1, color: '#000' }], lineColor: '#000000', lineWidth: 1, min: 0 }, plotOptions: { series: { pointStart: 0 } }, tooltip: { crosshairs: { width: 2, color: 'gray', dashStyle: 'shortdot' }, animation: true, valueSuffix: ',000₪', backgroundColor: 'rgba(255, 255, 255, 0.8)', formatter: function() {return '<b>₪' + this.x + this.y +'</b>';} }, legend: { enabled: false /***************** layout: 'horizontal', align: 'center', verticalAlign: 'bottom', borderWidth: 0, floating: true, rtl: true, y: 15, margin: 10, useHTML: true, itemStyle: { fontFamily: 'Arial, Helvetica, sans-serif', fontWeight: 'bold' } *******************/ }, series: [ { name: 'b', data: [0.5,1,1.5,2,2.5,3,3.5,4] }, { name: '<span class="abc">a</span>', data: [4,8,12,16,20,24,28,32] } ] },function(chart) { //LOGO chart.renderer.image('/images/small_logo.png', 670, 18, 31, 23).add(); } ); here is an image of what i want to achieve
You just have to change you min value : xAxis: { ... min: 0.5, ... }, Look at this : http://jsfiddle.net/yKHsD/ EDIT : There is a better solution. It is caused by the categories option. You can avoid this problem by doing : var xCategories = ['1','2','3','4','5','6','7','8']; // ... xAxis: { .... tickmarkPlacement: 'on', labels: { formatter: function() { return xCategories[this.value]; } }, startOnTick: false, endOnTick: false, minPadding: 0, maxPadding: 0, gridLineWidth: 1 }, In this example, don't forget to remove the categories option. Here is an example : http://jsfiddle.net/yKHsD/1/