完全解決! Google Chart で ローソク足+移動平均線チャート を表示すると、途中でズレと切れる!事象

以前、暫定的に解決していた、Google Chart でのローソク足チャートの表示不具合の件が、ようやく完全解決した。

その事象とは、ローソク足が10本、つまりグラフデータが10行以上になると、
途中で ズレ と 切れ、さらには、データの 抜け が発生して、表示が崩れてしまう、
という奇妙な事象だった。
Google Chart でローソク足と移動平均線

その後、いろいろと調べてみたけれども、WEBを検索しても同じ事例が見つからない。
Googleの公式ドキュメントを読んでも、そんな注意点は書かれていないので、原因が全く分からなかった。
結局、いろいろと試行錯誤しながらやってみたところ、
チャートの元データとなる、スプレッドシートの行に、
ダミーデータ行を一定間隔(8行ずつ)で2行挿入することで、暫定的に解決していた。

これだと、ローソク足10本以上でも、正常に表示させることに成功したが、
63行を超えると再び 抜け が発生してしまうので、まだまだ完全解決ではない。

今回、100本以上の長期チャートを表示されてみたくなったので、なんとか解決してみたくなって、いろいろなサンプル事例を使って、試してみた。
結局、データの行追加の方法を「google.visualization.DataTable」から「google.visualization.arrayToDataTable」へ変更してみたら、ダミー行無しで、正常に表示されるようになった。

これならば、ローソク足 300本でも正しく表示できる。
画面上で、表示スケールを調整できるようになれば、かなり実用的になる。

日足・週足・月足の同時連動チャートについても、今まで 60本までに制限していたのを、もっと増やすことができる。
できれば、日足は 120本、週足は 60本、月足は 30本 くらい を初期値にしたい。

私の自作チャートは、スマホ画面だと小さくて見づらいけれども、ピンチアウト操作で画面をズームアップして、安値と高値の数値を確認することができるので、それは意外と便利だと思う。

[サンプルソース Google Chart で ローソク足+移動平均線 の複合チャート]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">

// ライブラリのロード
// name:visualization(可視化),version:バージョン(1.1),packages:パッケージ(corechart)
google.load('visualization', '1', {'packages':['corechart']});

// グラフを描画する為のコールバック関数を指定
google.setOnLoadCallback(drawChart);

// グラフの描画
function drawChart() {

// メソッドからデータの生成
var data = new google.visualization.arrayToDataTable([
['2020/04/01',18784,18065,18686,17871,18689,18824,18822,18192,18704,21777,22454,21706],
['2020/04/02',18132,17818,17934,17707,18267,18655,18783,18301,18540,21680,22403,21700],
['2020/04/03',18059,17820,17951,17646,17901,18341,18537,18428,18365,21590,22349,21693],
['2020/04/06',18672,18576,17857,17802,18071,18239,18524,18597,18256,21506,22302,21688],
['2020/04/07',19162,18950,18878,18553,18449,18246,18461,18683,18219,21436,22258,21683],
['2020/04/08',19454,19353,19047,18730,18960,18503,18500,18664,18193,21362,22217,21680],
['2020/04/09',19406,19345,19376,19158,19216,18809,18561,18732,18189,21287,22178,21677],
['2020/04/10',19500,19498,19500,19235,19399,19144,18766,18743,18236,21212,22137,21673],
['2020/04/13',19355,19043,19312,19014,19295,19238,18941,18739,18317,21131,22095,21668],
['2020/04/14',19705,19638,19150,19093,19393,19375,19200,18811,18449,21059,22060,21666],
['2020/04/15',19660,19550,19589,19465,19410,19415,19340,18959,18576,20984,22022,21662],
['2020/04/16',19362,19290,19311,19154,19493,19404,19388,19106,18704,20904,21981,21657],
['2020/04/17',19922,19897,19575,19554,19579,19484,19466,19314,18871,20838,21947,21655],
['2020/04/20',19784,19669,19689,19611,19619,19609,19512,19423,19010,20766,21912,21652],
['2020/04/21',19529,19280,19479,19193,19615,19537,19481,19456,19070,20690,21875,21648],
['2020/04/22',19137,19137,19109,18858,19362,19455,19494,19435,19049,20612,21835,21642],
['2020/04/23',19429,19429,19313,19221,19282,19482,19465,19443,19087,20547,21796,21638],
['2020/04/24',19352,19262,19331,19175,19276,19355,19423,19420,19081,20481,21755,21633],
['2020/04/27',19819,19783,19410,19410,19491,19378,19494,19493,19116,20421,21718,21631],
['2020/04/28',19841,19771,19776,19638,19605,19476,19476,19507,19159,20368,21682,21627],
['2020/04/30',20365,20193,20105,20084,19916,19688,19551,19571,19265,20317,21651,21625],
['2020/05/01',20000,19619,19991,19551,19861,19726,19599,19604,19355,20262,21612,21621],
['2020/05/07',19720,19674,19468,19448,19829,19808,19676,19582,19448,20205,21575,21617],
['2020/05/08',20179,20179,19972,19894,19824,19887,19783,19633,19528,20152,21545,21615],
['2020/05/11',20534,20390,20333,20285,20081,20011,19944,19744,19600,20094,21516,21614],
['2020/05/12',20457,20366,20413,20293,20312,20046,20027,19867,19651,20037,21486,21614],
['2020/05/13',20329,20267,20140,20056,20341,20175,20098,19950,19697,19980,21455,21612],
['2020/05/14',20185,19914,20140,19902,20182,20223,20058,20016,19718,19914,21420,21608],
['2020/05/15',20198,20037,20149,19832,20073,20195,20118,20041,19767,19851,21386,21604],
['2020/05/18',20197,20133,20097,19999,20028,20143,20184,20077,19792,19792,21353,21602],
['2020/05/19',20659,20433,20469,20433,20201,20157,20220,20101,19836,19740,21317,21599],
['2020/05/20',20684,20595,20454,20454,20387,20222,20249,20199,19901,19697,21284,21596],
['2020/05/21',20734,20552,20692,20503,20527,20350,20276,20287,19934,19649,21249,21594],
['2020/05/22',20615,20388,20583,20334,20512,20420,20293,20308,19970,19598,21213,21590],
['2020/05/25',20741,20741,20653,20584,20560,20542,20411,20343,20043,19554,21182,21588],
['2020/05/26',21328,21271,20927,20918,20800,20709,20588,20433,20150,19531,21157,21587],
['2020/05/27',21475,21419,21249,21142,21144,20874,20771,20548,20249,19515,21133,21587],
['2020/05/28',21926,21916,21612,21580,21535,21147,20983,20748,20382,19514,21113,21588],
['2020/05/29',21955,21877,21807,21710,21737,21445,21166,20932,20487,19526,21094,21590],
['2020/06/01',22161,22062,21910,21898,21952,21709,21382,21125,20601,19538,21076,21591],
['2020/06/02',22401,22325,22175,22118,22088,21920,21659,21315,20708,19559,21061,21593],
['2020/06/03',22818,22613,22649,22462,22333,22159,21926,21516,20858,19584,21050,21596],
['2020/06/04',22907,22695,22885,22501,22544,22314,22130,21731,21009,19607,21045,21599],
['2020/06/05',22865,22863,22613,22563,22724,22512,22336,21978,21143,19642,21038,21604],
['2020/06/08',23178,23178,23121,23028,22912,22735,22516,22222,21282,19700,21038,21611],
['2020/06/09',23185,23091,23135,22933,23044,22888,22690,22404,21418,19754,21031,21618],
['2020/06/10',23175,23124,22939,22900,23131,22990,22841,22574,21561,19816,21024,21623],
['2020/06/11',22939,22472,22848,22466,22896,22946,22862,22630,21689,19881,21009,21627],
['2020/06/12',22350,22305,22082,21786,22634,22834,22818,22673,21803,19962,20992,21631],
['2020/06/15',22251,21530,22135,21529,22102,22504,22652,22620,21872,20038,20968,21631],
['2020/06/16',22624,22582,21912,21899,22139,22403,22612,22645,21980,20131,20954,21634],
['2020/06/17',22536,22455,22517,22318,22189,22269,22508,22630,22073,20226,20938,21637],
['2020/06/18',22432,22355,22363,22125,22464,22245,22403,22596,22163,20323,20922,21640],
['2020/06/19',22523,22478,22515,22352,22429,22280,22311,22557,22268,20416,20907,21642],
['2020/06/22',22575,22437,22353,22311,22423,22461,22306,22483,22352,20488,20893,21647],
['2020/06/23',22693,22549,22636,22257,22488,22455,22341,22429,22416,20538,20881,21651],
['2020/06/24',22663,22534,22541,22479,22507,22471,22484,22370,22472,20603,20872,21655],
['2020/06/25',22423,22259,22287,22165,22447,22451,22438,22348,22489,20651,20863,21659],
['2020/06/26',22589,22512,22424,22408,22435,22458,22446,22369,22521,20708,20854,21663],
['2020/06/29',22281,21995,22255,21969,22255,22370,22395,22416,22518,20759,20844,21665],
['2020/06/30',22448,22288,22335,22273,22265,22318,22368,22386,22516,20830,20835,21668],
['2020/07/01',22360,22121,22338,22039,22135,22235,22323,22353,22491,20901,20827,21669],
['2020/07/02',22267,22145,22182,22072,22185,22212,22265,22332,22464,20973,20817,21670],
['2020/07/03',22312,22306,22266,22154,22191,22171,22232,22315,22436,21036,20807,21672],
['2020/07/06',22734,22714,22341,22325,22388,22315,22297,22342,22413,21098,20796,21675],
['2020/07/07',22742,22614,22649,22540,22545,22380,22312,22349,22389,21153,20783,21678],
['2020/07/08',22667,22438,22481,22438,22589,22443,22375,22339,22354,21204,20771,21680],
['2020/07/09',22679,22529,22442,22434,22527,22520,22410,22366,22357,21255,20758,21683],
['2020/07/10',22563,22290,22534,22285,22419,22517,22434,22344,22357,21309,20742,21684],
['2020/07/13',22784,22784,22591,22561,22534,22531,22525,22423,22419,21361,20733,21687],
['2020/07/14',22677,22587,22631,22538,22554,22526,22565,22453,22420,21412,20724,21688],
['2020/07/15',22965,22945,22817,22800,22772,22627,22598,22535,22444,21473,20721,21690],
['2020/07/16',22925,22770,22907,22739,22767,22675,22620,22598,22465,21521,20715,21692],
['2020/07/17',22857,22696,22807,22643,22804,22756,22657,22637,22476,21571,20707,21694],
['2020/07/20',22788,22717,22772,22580,22728,22743,22684,22637,22490,21628,20701,21696],
['2020/07/21',22925,22884,22789,22780,22766,22802,22769,22664,22506,21691,20703,21698],
['2020/07/22',22855,22751,22791,22732,22784,22764,22764,22695,22517,21746,20707,21699],
['2020/07/27',22741,22715,22495,22429,22783,22753,22783,22714,22540,21804,20714,21701],
['2020/07/28',22842,22657,22735,22646,22708,22745,22741,22751,22547,21852,20729,21702],
['2020/07/29',22584,22397,22543,22366,22590,22681,22688,22712,22567,21895,20740,21704],
['2020/07/30',22506,22339,22489,22334,22464,22572,22637,22687,22570,21931,20753,21706],
['2020/07/31',22295,21710,22267,21710,22149,22364,22493,22564,22549,21966,20759,21707],
['2020/08/03',22214,22195,21947,21919,22081,22260,22395,22506,22552,22008,20767,21710],
['2020/08/04',22603,22573,22379,22379,22159,22243,22369,22494,22565,22048,20786,21715],
['2020/08/05',22554,22514,22479,22356,22427,22266,22341,22474,22555,22083,20814,21719],
['2020/08/06',22587,22418,22471,22362,22502,22282,22307,22427,22545,22118,20839,21724],
['2020/08/07',22436,22329,22433,22204,22420,22406,22297,22385,22540,22152,20868,21728],
['2020/08/11',22760,22750,22505,22497,22499,22517,22356,22388,22551,22199,20910,21733],
['2020/08/12',22874,22843,22747,22670,22641,22571,22517,22407,22579,22246,20964,21738],
['2020/08/13',23316,23249,23123,23111,22947,22718,22668,22492,22602,22298,21027,21745],
['2020/08/14',23338,23289,23323,23222,23127,22892,22770,22587,22637,22346,21090,21751],
['2020/08/17',23248,23096,23189,23068,23211,23045,22853,22726,22645,22387,21153,21758],
['2020/08/18',23128,23051,23097,22948,23145,23106,22944,22811,22659,22429,21218,21764],
['2020/08/19',23149,23110,22997,22953,23086,23159,23055,22865,22679,22474,21281,21771],
['2020/08/20',23078,22880,23003,22851,23014,23085,23074,22902,22687,22510,21328,21776],
['2020/08/21',23135,22920,23022,22920,22970,23011,23085,22952,22689,22537,21362,21782],
['2020/08/24',23012,22985,22913,22862,22928,22989,23047,23017,22701,22563,21405,21789],
['2020/08/25',23431,23296,23242,23225,23067,23038,23048,23072,22730,22586,21444,21798],
['2020/08/26',23348,23290,23257,23203,23190,23074,23076,23117,22762,22610,21487,21808],
['2020/08/27',23323,23208,23311,23177,23265,23140,23098,23112,22802,22629,21529,21817],
['2020/08/28',23376,22882,23232,22594,23127,23132,23066,23072,22829,22638,21578,21824],
['2020/08/31',23342,23139,23147,23102,23076,23163,23103,23076,22901,22647,21631,21832],
['2020/09/01',23206,23138,23089,23047,23053,23131,23134,23085,22948,22655,21684,21840],
['2020/09/02',23287,23247,23261,23170,23175,23123,23171,23098,22982,22661,21731,21847],
['2020/09/03',23580,23465,23524,23426,23283,23174,23196,23157,23029,22666,21776,21854],
['2020/09/04',23257,23205,23130,23098,23306,23239,23183,23185,23069,22668,21814,21861],
['2020/09/07',23218,23089,23145,23086,23253,23229,23166,23196,23107,22667,21852,21868],
['2020/09/08',23277,23274,23188,23129,23189,23256,23222,23194,23133,22680,21890,21875],
['2020/09/09',23059,23032,22966,22878,23132,23213,23207,23168,23142,22692,21929,21881],
['2020/09/10',23250,23235,23193,23134,23180,23167,23221,23171,23142,22721,21965,21889],
['2020/09/11',23412,23406,23114,23114,23224,23207,23244,23223,23147,22735,22004,21896],
['2020/09/14',23582,23559,23431,23429,23400,23301,23257,23265,23171,22753,22047,21903],
['2020/09/15',23477,23454,23438,23351,23473,23337,23293,23297,23191,22771,22082,21910],
['2020/09/16',23506,23475,23425,23397,23496,23426,23348,23319,23209,22788,22120,21917],
['2020/09/17',23446,23319,23416,23272,23416,23443,23354,23305,23231,22803,22161,21925],
['2020/09/18',23398,23360,23321,23290,23385,23433,23401,23320,23253,22816,22203,21932],
['2020/09/23',23370,23346,23245,23154,23342,23391,23417,23346,23271,22830,22242,21939],
['2020/09/24',23234,23087,23215,23039,23264,23317,23371,23327,23261,22844,22280,21945],
['2020/09/25',23272,23204,23217,23154,23212,23263,23321,23344,23256,22855,22315,21950],
['2020/09/28',23516,23511,23391,23303,23267,23302,23329,23372,23271,22880,22352,21956],
['2020/09/29',23622,23539,23410,23347,23418,23337,23338,23385,23304,22901,22385,21962],
['2020/09/30',23522,23185,23478,23170,23412,23305,23319,23348,23306,22919,22421,21967],
['2020/10/02',23365,23029,23294,22951,23251,23294,23272,23306,23301,22934,22455,21971],
['2020/10/05',23377,23312,23254,23252,23175,23315,23267,23289,23304,22950,22486,21977],
['2020/10/06',23441,23433,23420,23331,23258,23300,23316,23301,23303,22962,22516,21983],
['2020/10/07',23432,23422,23272,23272,23389,23276,23347,23307,23314,22976,22547,21990],
['2020/10/08',23701,23647,23506,23477,23501,23369,23367,23337,23341,22996,22581,21996],
['2020/10/09',23725,23619,23713,23552,23563,23487,23378,23390,23359,23014,22618,22003],
['2020/10/12',23597,23558,23588,23501,23608,23536,23431,23426,23385,23035,22653,22010],
['2020/10/13',23667,23601,23667,23490,23593,23569,23513,23435,23403,23049,22688,22017],
['2020/10/14',23656,23626,23545,23518,23595,23610,23558,23443,23414,23066,22720,22025],
['2020/10/15',23581,23507,23548,23458,23578,23582,23569,23475,23412,23076,22749,22032],
['2020/10/16',23538,23410,23478,23382,23514,23540,23567,23514,23410,23086,22777,22039],
['2020/10/19',23707,23671,23543,23543,23529,23563,23570,23549,23419,23103,22810,22046],
['2020/10/20',23674,23567,23587,23518,23549,23556,23563,23563,23432,23117,22838,22052],
['2020/10/21',23702,23639,23615,23611,23626,23559,23574,23585,23446,23129,22862,22058],
// データの順 安値,終値,始値,高値
// ※Excelだと始値,高値,安値,終値の順番です。ややこしいです:-)
], true);

// オプションの設定
var options = {
chartArea:{left:80,top:30,right:0,bottom:0},
legend: { position: 'none'},
backgroundColor: 'white',
colors: ['black'],
title: '日足 (2020/10/21 水) 1001 日経平均',
hAxis: {
format: 'yyyy/MM/dd',
direction: +1,
viewWindowMode: 'maximized',
},
vAxis: {
viewWindow: { min:20714 }
},
bar: {
groupWidth: '90%'
},
candlestick: {
fallingColor: { strokeWidth: 1, fill: '#ffffff' }, // black
risingColor: { strokeWidth: 1, fill: '#000000' } // white
},
width: 1200,
height: 600,
lineWidth: 1,
//チャートのタイプとして、ローソク足を指定
seriesType: "candlesticks",
//ローソク足だでなく、線グラフも表示することを記述
series: {

1:{
type: "line",
color: 'pink',
lineWidth: 2,
},
2:{
type: "line",
color: 'red',
lineWidth: 3,
},
3:{
type: "line",
color: 'black',
lineWidth: 2,
},
4:{
type: "line",
color: 'yellowgreen',
lineWidth: 2,
},
5:{
type: "line",
color: 'green',
lineWidth: 3,
},
6:{
type: "line",
color: 'blue',
lineWidth: 3,
},
7:{
type: "line",
color: 'purple',
lineWidth: 3,
},
8:{
type: "line",
color: 'orange',
lineWidth: 3,
},

}
}
// 指定されたIDの要素にローソク足を作成
var chart = new google.visualization.ComboChart(document.getElementById('chart'));

// グラフの描画
chart.draw(data, options);
}

</script>
</head>
<body>

<!-- グラフの描画エリア -->
<div id="chart"></div>

</body>
</html>

	

My Company Links

合資会社ユースマネージメント
ドメインサービス
インターネット活用の入り口

My Website Links

細野俊一のトレーディング日記
日経225+JPX400銘柄の PPP(パンパカパン) 一覧
株価指数+外国為替(FX)の PPP(パンパカパン) 状態
「生命の科学」学習メモ
大安心と大冒険を求めて

Facebook Pages

ポイント&フィギュア活用研究会
合資会社ユースマネージメント
アダムスキー「生命の科学」活用研究会
細野俊一 (宇宙哲学研究家)