无法使用股票传奇显示OHLC值

时间:2018-06-20 19:50:10

标签: javascript amcharts stock

我无法在amchart中显示带有股票传奇的OHLC值。 当我设置为 stockLegend.valueTextRegular = undefined; 时,我可以看到一些值,而且我无法猜测它是什么。 (图1) enter image description here 我试图将其设置为 stockLegend.valueTextRegular =“ Open:[[open]]”; ,结果如图2所示。 enter image description here 我的工作怎么了?

源代码如下:

        chart = new AmCharts.AmStockChart();


        // DATASET //////////////////////////////////////////
        dataSet = new AmCharts.DataSet();
        dataSet.fieldMappings = [{
            fromField: "open",
            toField: "open"
        }, {
            fromField: "close",
            toField: "close"
        }, {
            fromField: "high",
            toField: "high"
        }, {
            fromField: "low",
            toField: "low"
        }, {
            fromField: "volume",
            toField: "volume"
        }, {
            fromField: "value",
            toField: "value"
        }];
        dataSet.color = "#7f8da9";
        dataSet.dataProvider = chartData;
        dataSet.title = "Stock";
        dataSet.categoryField = "date";
        
        var stockPanel = new AmCharts.StockPanel();
        
                stockPanel.title = "Value";
        stockPanel.showCategoryAxis = false;
        stockPanel.percentHeight = 70;

        var valueAxis = new AmCharts.ValueAxis();
        valueAxis.dashLength = 5;
        stockPanel.addValueAxis(valueAxis);

        stockPanel.categoryAxis.dashLength = 5;

        // graph of first stock panel
        var graph = new AmCharts.StockGraph();
        graph.type = "candlestick";
        graph.openField = "open";
        graph.closeField = "close";
        graph.highField = "high";
        graph.lowField = "low";
        graph.valueField = "close";
        graph.lineColor = "#7f8da9";
        graph.fillColors = "#7f8da9";
        graph.negativeLineColor = "#db4c3c";
        graph.negativeFillColors = "#db4c3c";
        graph.proCandlesticks = true;
        graph.fillAlphas = 1;
        graph.useDataSetColors = false;
        graph.comparable = true;
        graph.compareField = "value";
        graph.showBalloon = true;
        graph.balloonText = "Open:<b>[[close]]</b>";
        stockPanel.addStockGraph(graph);

        var stockLegend = new AmCharts.StockLegend();
        stockLegend.valueTextRegular = "Open: [[open]]";
        //stockLegend.valueTextRegular = undefined;
        stockLegend.periodValueTextComparing = "[[percents.value.close]]%";
        stockPanel.stockLegend = stockLegend;

        var chartCursor = new AmCharts.ChartCursor();
        chartCursor.valueLineEnabled = true;
        chartCursor.valueLineAxis = valueAxis;
        stockPanel.chartCursor = chartCursor;       

0 个答案:

没有答案