如何编辑Amcharts X轴?

时间:2018-11-27 14:51:53

标签: javascript reactjs charts amcharts

我正在使用以下库的React应用程序中使用Amcharts amcharts3-react

这是我的Amcharts配置:

export const arabicCharts = {
  "type": "serial",
  "theme": "light",
  "autoMarginOffset": 20,
  "graphs": [{
    "id": "g1",
    "balloonText": "[[value]]",
    "bullet": "diamond",
    "bulletBorderAlpha": 1,
    "bulletColor": "#FFFFFF",
    "hideBulletsCount": 50,
    "title": "red line",
    "valueField": "ay",
    "lineAlpha": 0.8,
    "lineThickness": 2,
    "lineColor": "#b0de09",
    "fillAlphas": 0,
    "useLineColorForBulletBorder": true
  }, {
    "id": "g2",
    "balloonText": "[[value]]",
    "bullet": "round",
    "bulletBorderAlpha": 1,
    "bulletColor": "#FFFFFF",
    "hideBulletsCount": 50,
    "title": "red line",
    "valueField": "by",
    "lineAlpha": 0.8,
    "lineThickness": 2,
    "lineColor": "#fcd202",
    "fillAlphas": 0,
    "useLineColorForBulletBorder": true
  }],
  "chartCursor": {
    "limitToGraph": "g1"
  },
  "categoryField": "date",
  "categoryAxis": {
    "parseDates": true,
    "axisColor": "#DADADA",
    "dashLength": 1,
    "minorGridEnabled": true
  },
  "valueAxes": [{
    "axisAlpha": 0,
    "position": "right",
  },{
    "axisAlpha": 1,
    "position": "bottom",
  }],
};

valueAxes仅通过添加其标题而应用于Y轴。

为什么不将其应用于X轴? valueAxes第二个对象不起作用。 谢谢。

1 个答案:

答案 0 :(得分:1)

我已经在Github上回答了,但是对于其他好奇的人(请注意,这与AmCharts 3有关):

AmCharts 3中的序列图只能有一个水平/ X轴(如果设置了position: "left",则为Y轴),并且该轴必须是类别轴,不能完全是数字。您可以将第二个值轴设置为第二个Y轴(position: "right"graphs: [{ // ... "valueAxis": "v1, //use right hand axis }, { // ... valueAxis: "v2" //use left hand axis }], // ... valueAxes: [{ "position": "right", "id": "v1", // ... }, { "position": "left", "id": "v2" }] ),但是您还需要指定ID并为其分配图形,例如

var sql = "SELECT 1 FROM Printers WHERE PrinterID = @IdToCheck";

using (var command = new SqlCommand(sql, con))
{
    command.Parameters.AddWithValue("@IdToCheck", tbPrinterID.Text);
    con.Open();
    using (var reader = command.ExecuteReader())
    {
        while (reader.Read())
        {
         ..........
        }
    }
}

如果同时需要数字X和Y轴,请考虑改为使用v3的XY图表。

相关问题