Ce JSON est utilisé pour définir les informations de configuration du graphique de la fonction de dessin personnaliséChart()
. La bibliothèque de graphiques utilisée est Highcharts. Seuls quelques champs de configuration de base sont listés ici.
Champ d'extension de plateforme: définir sur vrai pour utiliser les graphiques Highstocks; définir sur faux pour utiliser les graphiques Highcharts.
__ est Stocks chaîne
{
layout: 'single', // Not participating in grouping, displayed separately, default is group 'group'
height: 300, // Specify height
}
prolongation JSON Titre du graphique titre chaîne Configuration de l'axe X. xAxe JSON Configuration de l'axe Y. yAxe JSON Série de données graphiques. séries JSON
Un exemple de dessin simple:
// This chart is an object in JavaScript language. Before using the Chart function, we need to declare an object variable chart to configure the chart.
var chart = {
// This field marks whether the chart is a general chart. If you are interested, you can change it to false and run it.
__isStock: true,
// Zoom tool
tooltip: {xDateFormat: '%Y-%m-%d %H:%M:%S, %A'},
// title
title : { text : 'Price difference analysis chart'},
// Select range
rangeSelector: {
buttons: [{type: 'hour',count: 1, text: '1h'}, {type: 'hour',count: 3, text: '3h'}, {type: 'hour', count: 8, text: '8h'}, {type: 'all',text: 'All'}],
selected: 0,
inputEnabled: false
},
// The horizontal axis of the coordinate axis is: x-axis, and the current setting type is: time
xAxis: { type: 'datetime'},
// The vertical axis of the coordinate axis is: the y-axis, the default value is adjusted according to the data size
yAxis : {
// title
title: {text: 'Price difference'},
// Whether to enable the right vertical axis
opposite: false
},
// Data series, this property saves each data series (line, K-line chart, label, etc.)
series : [
// The index is 0, and the data array stores the data of the index series.
{name : "line1", id : "line 1,buy1Price", data : []},
// The index is 1, dashStyle:'shortdash' is set, that is, a dashed line is set
{name : "line2", id : "line 2,lastPrice", dashStyle : 'shortdash', data : []}
]
}
function main(){
// Call the Chart function to initialize the chart
var ObjChart = Chart(chart)
// Clear
ObjChart.reset()
while(true){
// Get the timestamp of this poll, which is a millisecond timestamp. Used to determine the position of the X-axis written to the chart
var nowTime = new Date().getTime()
// Get market data
var ticker = _C(exchange.GetTicker)
// Get the buy price from the return value of the market data
var buy1Price = ticker.Buy
// Get the last transaction price. In order to prevent the two lines from overlapping, we add 1.
var lastPrice = ticker.Last + 1
// Use the timestamp as the X value and the buy price as the Y value to pass into the data sequence of index 0
ObjChart.add(0, [nowTime, buy1Price])
// Same as above
ObjChart.add(1, [nowTime, lastPrice])
Sleep(2000)
}
}
{@fun/Log/Graphique graphique}
LogStatus-btnTypeTwo est le numéro de connexion Options de la carte KLine