K线图。点击右上角的“眼睛”图标,增加一个新Series之后,图形就异常了。
配置项如下
var upColor = '#ec0000'
var upBorderColor = '#8A0000'
var downColor = '#00da3c'
var downBorderColor = '#008F28'
var data0 = splitData([
['20140102', 12.049313, 11.996508, 11.890899, 12.102117],
['20140103', 11.943704, 11.838094, 11.732485, 11.996508],
['20140106', 11.838094, 11.362853, 11.362853, 11.838094],
['20140107', 11.362853, 11.415657, 11.257243, 11.468462],
['20140108', 11.468462, 11.098829, 11.046025, 11.521267],
['20140109', 11.098829, 11.098829, 10.99322, 11.257243],
['20140110', 11.046025, 10.676392, 10.676392, 11.046025],
['20140113', 10.676392, 10.729197, 10.623588, 10.887611],
['20140114', 10.729197, 10.99322, 10.465174, 10.99322],
['20140115', 10.940416, 10.99322, 10.782001, 10.99322],
['20140116', 10.99322, 11.046025, 10.887611, 11.151634],
['20140117', 11.046025, 10.834805, 10.834805, 11.151634],
['20140120', 10.834805, 10.887611, 10.782001, 10.99322],
['20140121', 10.834805, 11.151634, 10.834805, 11.151634],
['20140122', 11.151634, 11.943704, 10.99322, 12.102117],
['20140123', 11.78529, 11.67968, 11.521267, 11.890899],
['20140124', 11.574071, 12.313336, 11.574071, 12.577359],
['20140127', 12.102117, 12.313336, 11.78529, 12.47175],
['20140128', 12.366141, 12.102117, 12.049313, 12.47175],
['20140129', 12.102117, 12.102117, 11.996508, 12.260532],
['20140130', 12.102117, 11.996508, 11.890899, 12.207727],
['20140207', 11.996508, 11.996508, 11.78529, 11.996508],
['20140210', 11.890899, 12.313336, 11.890899, 12.313336],
['20140211', 12.260532, 12.313336, 12.154922, 12.524555],
['20140212', 12.366141, 12.366141, 12.207727, 12.418945],
['20140213', 12.366141, 12.102117, 12.102117, 12.366141],
['20140214', 12.049313, 12.630164, 11.943704, 12.999796],
['20140217', 12.524555, 12.735773, 12.366141, 12.894187],
['20140218', 12.682969, 12.682969, 12.524555, 13.052601],
['20140219', 12.630164, 12.946992, 12.524555, 12.946992],
['20140220', 12.946992, 12.577359, 12.524555, 12.999796],
['20140221', 12.577359, 12.418945, 12.260532, 12.630164],
['20140224', 12.313336, 11.67968, 11.521267, 12.366141],
['20140225', 11.67968, 11.521267, 11.468462, 11.78529],
['20140226', 11.521267, 11.732485, 11.415657, 11.732485],
['20140227', 11.67968, 11.732485, 11.626876, 11.943704],
['20140228', 11.78529, 11.943704, 11.626876, 11.996508],
['20140303', 11.996508, 12.102117, 11.838094, 12.102117],
['20140304', 12.102117, 12.049313, 11.838094, 12.102117],
['20140305', 12.049313, 12.102117, 11.890899, 12.207727],
['20140306', 12.049313, 12.47175, 11.78529, 12.577359],
['20140307', 12.313336, 12.260532, 12.154922, 12.47175],
['20140310', 12.049313, 11.78529, 11.67968, 12.102117],
['20140311', 11.78529, 11.890899, 11.67968, 12.102117],
['20140312', 11.78529, 13.369429, 11.78529, 13.369429],
['20140313', 13.369429, 13.105406, 12.841383, 13.580648],
['20140314', 12.894187, 12.366141, 11.996508, 12.894187],
['20140317', 12.260532, 12.577359, 12.207727, 12.682969],
['20140318', 12.47175, 12.630164, 12.260532, 12.735773],
['20140319', 12.47175, 12.946992, 12.260532, 12.999796],
['20140320', 12.946992, 12.630164, 12.630164, 13.316624],
['20140321', 12.47175, 14.214303, 12.313336, 14.214303],
['20140324', 15.956856, 15.956856, 15.956856, 15.956856],
['20140325', 17.857824, 17.857824, 17.857824, 17.857824],
['20140326', 19.600378, 17.382582, 16.960144, 19.600378],
['20140327', 16.960144, 17.540997, 16.432098, 18.913918],
['20140328', 17.012949, 16.484903, 16.220881, 18.069042],
['20140331', 16.273685, 15.798442, 15.42881, 16.696121],
['20140401', 15.745638, 16.326488, 15.217591, 16.854536],
['20140402', 16.220881, 18.280262, 16.062466, 18.280262],
['20140403', 18.174652, 17.171362, 16.748926, 18.227455],
['20140404', 16.907339, 17.224167, 16.537708, 18.016237],
['20140408', 16.696121, 16.748926, 16.115271, 16.854536],
['20140409', 16.590511, 16.643316, 16.326488, 17.065754],
['20140410', 16.696121, 16.115271, 15.851247, 16.748926],
['20140411', 16.115271, 15.956856, 15.692833, 16.220881],
['20140414', 15.904052, 16.220881, 15.534419, 16.326488],
['20140415', 16.273685, 15.587224, 15.534419, 16.326488],
['20140416', 15.640028, 15.640028, 15.534419, 16.009661],
['20140417', 15.692833, 15.164787, 15.164787, 15.745638],
['20140418', 15.164787, 15.164787, 15.006373, 15.376005],
['20140421', 15.059177, 14.531131, 14.478326, 15.323201],
['20140422', 14.583936, 14.84796, 14.372717, 14.900764],
['20140423', 14.742349, 14.425522, 14.319912, 14.795154],
['20140424', 14.372717, 14.531131, 14.319912, 15.059177],
['20140425', 14.267108, 14.003085, 13.95028, 14.742349],
['20140428', 13.897475, 12.841383, 12.788578, 13.897475],
['20140429', 12.788578, 13.15821, 12.630164, 13.15821],
['20140430', 13.052601, 13.369429, 12.946992, 13.686257],
['20140505', 13.26382, 13.15821, 12.788578, 13.26382],
['20140506', 13.052601, 13.26382, 12.999796, 13.369429],
['20140507', 13.26382, 12.946992, 12.841383, 13.316624],
['20140508', 12.841383, 13.475038, 12.788578, 14.055889],
['20140509', 13.26382, 13.052601, 12.841383, 13.316624],
['20140512', 13.15821, 13.422233, 12.946992, 13.475038],
['20140513', 13.369429, 13.580648, 13.26382, 13.739061],
['20140514', 13.897475, 13.527843, 13.527843, 14.372717],
['20140515', 13.26382, 12.946992, 12.894187, 13.369429],
['20140516', 12.946992, 13.052601, 12.894187, 13.105406],
['20140519', 13.052601, 12.946992, 12.841383, 13.052601],
['20140520', 12.946992, 12.946992, 12.841383, 13.105406],
['20140521', 12.946992, 12.946992, 12.524555, 12.999796],
['20140522', 12.894187, 12.999796, 12.788578, 13.15821],
['20140523', 13.052601, 13.369429, 12.946992, 13.844671],
['20140526', 13.15821, 13.211015, 13.052601, 13.26382],
['20140527', 13.15821, 13.105406, 13.105406, 13.316624],
['20140528', 13.105406, 13.15821, 12.946992, 13.26382],
['20140529', 13.26382, 12.999796, 12.946992, 13.316624],
['20140530', 12.999796, 12.946992, 12.788578, 13.052601],
['20140603', 12.999796, 13.052601, 12.841383, 13.211015],
['20140604', 12.946992, 12.735773, 12.735773, 12.999796],
]);
var sigIndex = 100;
var sigDate = '20140324';
var i = sigIndex
var last = data0.values.length
var lowValue = data0.values[i][2]
var highValue = data0.values[i][3]
var end = sigIndex + 14
if (end > last - 1) {
end = last - 1
}
for (i = i + 1; i < end; i++) {
if (highValue < data0.values[i][3]) {
highValue = data0.values[i][3]
}
}
//新series
var datc = []
for (j = 0; j < last; j++) {
datc.push(highValue)
}
function splitData(rawData) {
var categoryData = [];
var values = []
for (var i = 0; i < rawData.length; i++) {
categoryData.push(rawData[i].splice(0, 1)[0]);
values.push(rawData[i])
}
return {
categoryData: categoryData,
values: values
};
}
option = {
title: {
text: 'SH600159',
left: '3%'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
},
},
toolbox: {
show: true,
feature: {
myTool1: {
show: true,
title: '增加series',
icon: 'path://M432.45,595.444c0,2.177-4.661,6.82-11.305,6.82c-6.475,0-11.306-4.567-11.306-6.82s4.852-6.812,11.306-6.812C427.841,588.632,432.452,593.191,432.45,595.444L432.45,595.444z M421.155,589.876c-3.009,0-5.448,2.495-5.448,5.572s2.439,5.572,5.448,5.572c3.01,0,5.449-2.495,5.449-5.572C426.604,592.371,424.165,589.876,421.155,589.876L421.155,589.876z M421.146,591.891c-1.916,0-3.47,1.589-3.47,3.549c0,1.959,1.554,3.548,3.47,3.548s3.469-1.589,3.469-3.548C424.614,593.479,423.062,591.891,421.146,591.891L421.146,591.891zM421.146,591.891',
onclick: function() {
var op = myChart.getOption()
var item = {
name: 'maxs',
type: 'line',
data: datc,
smooth: false,
lineStyle: {
normal: {
opacity: 0.5,
color: '#000000',
type: 'dashed'
}
},
itemStyle: {
normal: {
opacity: 0,
borderWidth: 0,
color: '#000000',
borderColor: '#000000'
}
}
}
op.series.push(item)
myChart.setOption(op)
}
},
}
},
grid: [{
left: '10%',
right: '10%',
top: 80,
height: 250
},
],
xAxis: [{
type: 'category',
gridIndex: 0,
data: data0.categoryData,
scale: true,
boundaryGap: false,
axisLine: {
onZero: false
},
splitLine: {
show: false
},
splitNumber: 20,
min: 'dataMin',
max: 'dataMax'
},
],
yAxis: [{
scale: true,
gridIndex: 0,
splitNumber: 3,
splitArea: {
show: true
}
},
],
series: [{
name: 'K线',
type: 'candlestick',
dimensions: ['date', 'open', 'close', 'low', 'high'],
data: data0.values,
itemStyle: {
normal: {
color: upColor,
color0: downColor,
borderColor: upBorderColor,
borderColor0: downBorderColor
}
},
markPoint: {
label: {
normal: {
formatter: function(param) {
return 'Sig';
}
}
},
symbolSize: 38,
data: [{
coord: ['20140324', 16.27599312],
itemStyle: {
normal: {
color: '#FF8000'
}
}
}, ]
}
},
],
};