$(function() {
var data = [
[10, 100],
[20, 150],
[30, 200],
[40, 250],
[50, 300]
];
var line_data = [];
var circle_data = [];
for (var i = 0; i < data.length; i++) {
var xValue = data[i][1]/2;
var yValue = 0;
var rValue = data[i][1]/2;
circle_data.push({
x: xValue - rValue,
y: yValue,
});
circle_data.push({
x: xValue,
y: yValue + rValue,
});
circle_data.push({
x: xValue + rValue,
y: yValue,
});
line_data.push({
x: xValue,
y: rValue
});
}
$('#container2').highcharts({
title: {
text: '',
},
credits: {
enabled: false
},
exporting: {
enabled: false
},
tooltip: {
enabled: true
},
xAxis: {
title: {
useHTML: true,
text: 'σ (MPa)'
},
gridLineWidth: 1,
min: 0,
max: 360,
tickInterval: 20
},
yAxis: {
title: {
useHTML: true,
text: 'τ (MPa)'
},
gridLineWidth: 1,
min: 0,
max: 360,
tickInterval: 20
},
plotOptions: {
line: {
marker: {
enabled: true
}
}
},
series: [{
// dataset za krivulju
type: 'line',
name: 'o3(MPa)',
enableMouseTracking: true,
data: line_data,
point: {
events: {
mouseOver: function() {
$('#row_' + this.index + ' > td').css("background-color", "yellow");
},
mouseOut: function() {
$('#row_' + this.index + ' > td').css("background-color", "white");
}
}
}
}, {
// dataset za Mohrove kružnice
visible: false,
data: circle_data,
}]
},
function(chart) {
// crtanje Mohrovih kružnica
for (var i = 0; 3 * i + 2 < chart.series[1].data.length; i++) {
var point0 = chart.series[1].data[3 * i];
var point1 = chart.series[1].data[3 * i + 1];
var point2 = chart.series[1].data[3 * i + 2];
var pathData = [
"M",
chart.plotLeft + point0.plotX,
chart.plotTop + point0.plotY,
"A",
point2.plotX - point1.plotX,
point2.plotY - point1.plotY,
0,
1,
1,
chart.plotLeft + point2.plotX,
chart.plotTop + point2.plotY,
];
chart.renderer.path(pathData)
.attr({
id: 'arc_' + i,
fill: null,
stroke: 'silver',
'stroke-width': 0,
data_id: i,
})
.on('mouseover', function() {
$(this).css('stroke', 'red');
$('#row_' + $(this).attr('data_id') + ' > td').css("background-color", "yellow");
})
.on('mouseout', function() {
$(this).css('stroke', 'silver');
$('#row_' + $(this).attr('data_id') + ' > td').css("background-color", "white");
})
.animate({
'stroke-width': 3
})
.add();
}
chart.series[1].remove();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container2" style="width: 600px; height: 600px;"></div>
Это здорово, именно то, что мне нужно :) –
КПП. есть ли способ «обрезать» ось y, чтобы она говорила 180, но оставляя все в пропорциях? Благодаря! –