我想动态设置Candlestick的颜色。但我不知道该怎么做。
因此,我将anychart文档中所说的参数true传递给了anychart.stock构造函数,并在数据集上定义了一个带有映射字段的缩放颜色字段,如下所示。
有谁有解决方案吗?
参考Dok:https://docs.anychart.com/Stock_Charts/Data#individual_point_settings
anychart.onDocumentReady(function() {
// create a data table
var table = anychart.data.table('x');
// add data
table.addData([{
'x': '2015-12-24',
'open': 511.53,
'high': 514.98,
'low': 505.79,
'close': 506.40,
'fill': '#00FF00'
}]);
// create a stock chart
var chart = anychart.stock(true);
// create a mapping
var mapping = table.mapAs({
'open': 'open',
'high': 'high',
'low': 'low',
'close': 'close',
'fill': 'fill'
});
// add a series using the mapping
chart.plot(0).candlestick(mapping).name('ACME Corp.');
// set container id for the chart
chart.container('container');
// initiate chart drawing
chart.draw();
});发布于 2018-11-12 12:00:29
你的方法是完全正确的!唯一的问题是,烛台系列没有‘填充’设置,它有risingFill和fallingFill。因此,您需要做的就是使用这些设置来映射它。您可以在下面的注释中根据您的代码检查工作样例。此外,您还可以在this article中了解有关烛台设置的更多信息。
发布于 2021-01-14 20:08:19
根据任意图的答案,代码就像代码块中的代码一样。再加上一根蜡烛,我希望看到一根绿色的和一根红色的蜡烛。但是,只有红色的蜡烛才能正确地显示在“fallingFill”中。“risingFill”没有显示绿色的蜡烛。
anychart.onDocumentReady(function() {
// create a data table
var table = anychart.data.table('x');
// add data
table.addData([{
'x': '2015-12-24',
'open': 511.53,
'high': 514.98,
'low': 505.79,
'close': 506.40,
'fallingFill': '#FF0000',
},
{
'x': '2015-12-25',
'open': 521.53,
'high': 524.98,
'low': 515.79,
'close': 524, // 516.40,
'risingFill': '#00FF00'
}]);
// create a stock chart
var chart = anychart.stock(true);
// create a mapping
var mapping = table.mapAs({
'open': 'open',
'high': 'high',
'low': 'low',
'close': 'close',
'risingFill': 'risingFill',
'fallingFill': 'fallingFill'
});
// add a series using the mapping
chart.plot(0).candlestick(mapping).name('ACME Corp.');
// set container id for the chart
chart.container('container');
// initiate chart drawing
chart.draw();
});https://stackoverflow.com/questions/53189389
复制相似问题