Y2轴在C3组合图中以十进制显示

时间:2017-02-07 08:12:24

标签: d3.js charts c3.js

我已尝试使用以下数据的C3组合图表。它以小数点显示Y2轴。所以我在图表中看不到data2点。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Renci.SshNet;
using MinimalisticTelnet;

namespace Ssh_Net
{
    class Program
    {

        static void Main(string[] args)
        {
            String host = "54.88.81.210";
            String username = "root";
            String password = "abcd1234";
            int port = 22;

            ForwardedPortDynamic tunnelPort;

            // Setup SSH with Credentials
            ConnectionInfo ConnNfo = new ConnectionInfo(host, port, username,

                new AuthenticationMethod[] {

                        /* Password based authentication */
                        new PasswordAuthenticationMethod(username, password)
                }
            );


            // Instantly execute a shell command

            using (var sshclient = new SshClient(ConnNfo))
            {
                sshclient.Connect();
                Console.WriteLine("Connecting");

                if (sshclient.IsConnected)
                {
                    try
                    {
                        Console.WriteLine(sshclient.RunCommand("telnet localhost 21000").Execute());

                    }
                    catch (Exception e)
                    {
                        Console.Write(e.ToString());
                    }
                }

                Console.ReadLine();
                sshclient.Disconnect();

            }


        }


    }
}

让我知道解决方案

1 个答案:

答案 0 :(得分:1)

您正在设置第二个y轴错误。这样,您只能看到一个y轴,显示范围高于第二列,这就是为什么它显示为点。

只需添加axes: {data1:'y',data2:'y2'}

即可

图表的完整配置应如下所示:

var chart = c3.generate({
    data: {
        columns: [
            ['data1', 30543, 2045346, 50765767, 4067657, 605676, 50665],
            ['data2', 200, 130, 90, 240, 130, 220]
        ],
       types: {
            data1: 'bar',
            data2: 'line'      
        },
        axes: {
            data1: 'y',
            data2: 'y2'
        }

    },
    axis: {
        y2: {
            show: true
        }
    }
});