Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Amcharts v3多类别步骤图_Javascript_Amcharts - Fatal编程技术网

Javascript Amcharts v3多类别步骤图

Javascript Amcharts v3多类别步骤图,javascript,amcharts,Javascript,Amcharts,我正在尝试在同一张图表上生成两个具有独立X轴(类别)值的图形(步进线)。我所能接近的是: AmCharts.makeChart("price-level-compare", { type: "serial", dataProvider: [ {qty1: 1, price1: 2.3, qty2: 1, price2: 3.6},

我正在尝试在同一张图表上生成两个具有独立X轴(类别)值的图形(步进线)。我所能接近的是:

AmCharts.makeChart("price-level-compare",
        {
            type: "serial",
            dataProvider:
                [
                    {qty1: 1,   price1: 2.3, qty2: 1, price2: 3.6},
                    {qty1: 2,   price1: 2.2, qty2: 5, price2: 3.3},
                    {qty1: 10,  price1: 1.97,qty2: 10, price2: 3.1},
                    {qty1: 100, price1: 1.54,qty2: 200,price2: 1.1},
                    {qty1: 500, price1: 1.2, qty2: 300,price2: 1.0}
                ],
            graphs: [{
                "id":"g1",
                "type": "step",
                "lineThickness": 2,
                "bullet":"square",
                "bulletAlpha":0,
                "bulletSize":4,
                "bulletBorderAlpha":0,
                "valueField": "price1"
            },{
                "id":"g2",
                "type": "step",
                "lineThickness": 2,
                "bullet":"square",
                "bulletAlpha":0,
                "bulletSize":4,
                "bulletBorderAlpha":0,
                "valueField": "price2"
            }],
            "categoryField": "qty1"

        }
    );
这将生成不正确的图形:


我不知道如何指定另一个名为“qty2”的“categoryField”作为“price2”值的X轴值。

序列图表不支持多个categoryFields

鉴于您的数据是数字,XY图表更适合。只需设置每个图形的和,以指向数据中的适当值

  graphs: [
    {
      id: "g1",
      type: "step",
      lineThickness: 2,
      bullet: "square",
      bulletAlpha: 0,
      bulletSize: 4,
      bulletBorderAlpha: 0,
      xField: "qty1",
      yField: "price1"
    },
    {
      id: "g2",
      type: "step",
      lineThickness: 2,
      bullet: "square",
      bulletAlpha: 0,
      bulletSize: 4,
      bulletBorderAlpha: 0,
      xField: "qty2",
      yField: "price2"
    }
下面是演示

AmCharts.makeChart(“chartdiv”{
类型:“xy”,
数据提供者:[
{qty1:1,price1:2.3,qty2:1,price2:3.6},
{qty1:2,price1:2.2,qty2:5,price2:3.3},
{qty1:10,price1:1.97,qty2:10,price2:3.1},
{qty1:100,price1:1.54,qty2:200,price2:1.1},
{qty1:500,price1:1.2,qty2:300,price2:1.0}
],
图表:[
{
id:“g1”,
键入:“步骤”,
线宽:2,
子弹:“正方形”,
阿尔法:0,
尺寸:4,
第一个字母:0,
xField:“qty1”,
伊菲尔德:“价格1”
},
{
id:“g2”,
键入:“步骤”,
线宽:2,
子弹:“正方形”,
阿尔法:0,
尺寸:4,
第一个字母:0,
xField:“qty2”,
伊菲尔德:“价格2”
}
]
});
html,正文{
宽度:100%;
身高:100%;
边际:0px;
}
#沙特迪夫{
宽度:100%;
身高:100%;
}

谢谢,我想我要么必须在V3中的数据中添加额外的点,例如,在XY图表中添加额外的点,要么移动到V4。