pageTest3.html 11.1 KB
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="pageTemplates/other/jquery.min.js"></script>
    <script src="pageTemplates/other/d3.min.js"></script>
    <script src="pageTemplates/js/vue_v2.6.12.js"></script>
    <script src="pageTemplates/components/lineChart.vue.js"></script>

    <style>

        svg.line-chart {
            width: 100%;
            height: 100%;
            position: absolute;
            left: 0;

            /* 文本css */
            font-style: normal;
            font-variant-ligatures: normal;
            font-variant-caps: normal;
            font-variant-numeric: normal;
            font-variant-east-asian: normal;
            font-weight: 400;
            font-stretch: normal;
            font-size: 14px;
            line-height: 20px;
            font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
        }

        svg.line-chart circle.station_circle {
            fill: #5e96d2;
            r: 5.5;
            stroke: rgb(253, 253, 253);
            stroke-width: 3;
            Pointer-events: none;
        }

        svg.line-chart circle.station_circle.down {
            fill: #c92121;
        }

        svg.line-chart path.station_link {
            stroke-width: 3.5px;
            stroke: #5E96D2;
            Pointer-events: none;
        }

        svg.line-chart path.station_link.down {
            stroke: #c92121;
        }

        svg.line-chart path.station_link.down.loop_line {
            stroke-dasharray: 4, 3;
            stroke-width: 1px;
        }

        svg.line-chart text.station_text {
            writing-mode: tb;
            fill: #3e3e3e;
            letter-spacing: -.2px;
            text-shadow: 0 0 2px #dadada;
            Pointer-events: none;
        }

        svg.line-chart text.station_text.up {
            fill: #4556b6;
        }

        svg.line-chart text.station_text.down {
            fill: #c94f21;
        }

        svg.line-chart g.item:first-child > text {
            stroke: #6f6e6e;
            fill: none;
        }

        svg.line-chart g.item:nth-last-child(3) > text {
            stroke: #6f6e6e;
            fill: none;
        }

        svg.line-chart g.item:first-child > text.up,
        svg.line-chart g.item:nth-last-child(3) > text.up {
            stroke: #4556b6;
        }

        svg.line-chart g.item:first-child > text.down,
        svg.line-chart g.item:nth-last-child(3) > text.down {
            stroke: #c94f21;
        }

        svg.line-chart g.gps-wrap > rect {
            width: 30px;
            height: 15px;
            /* fill: #fff; */
            rx: 2px;
            cursor: pointer;
        }

        svg.line-chart g.gps-wrap > rect[updown="0"] {
            stroke: rgb(62, 80, 179);
            fill: rgb(62, 80, 179);
        }

        svg.line-chart g.gps-wrap > rect[updown="1"] {
            stroke: #c94f21;
            fill: #c94f21;
        }

        svg.line-chart g.gps-wrap > rect.hover {
            stroke-width: 2;
        }

        svg.line-chart g.gps-wrap > text {
            font-size: 12px;
            transform: translate(0, 12px);
            pointer-events: none;
        }

        svg.line-chart g.gps-wrap > text[updown="0"] {
            fill: #fff;
        }

        svg.line-chart g.gps-wrap > text[updown="1"] {
            fill: #fff;
        }

        svg.line-chart g.gps-wrap > rect.abnormal[updown="0"],
        svg.line-chart g.gps-wrap > rect.abnormal[updown="1"] {
            width: 40px;
            fill: yellow;
            stroke: yellow;
        }

        svg.line-chart g.gps-wrap > text.abnormal[updown="0"],
        svg.line-chart g.gps-wrap > text.abnormal[updown="1"] {
            fill: black;
        }

        svg.line-chart .merge_hide {
            display: none !important;
        }

        svg.line-chart g.merge-item rect {
            width: 22px;
            height: 22px;
            rx: 15px;
            fill: #19a53a;
            cursor: pointer;
            stroke: #19a53a;
            stroke-dasharray: 1, 2;
            stroke-width: 3px;
        }

        svg.line-chart g.merge-item text {
            fill: #fff;
            pointer-events: none;
        }

    </style>

    <style>
        .top-center-big-text {
            height: 44px;
            position: absolute;
            left: 50%;
            transform: translate(-50%, 0);
            -webkit-transform: translate(-50%, 0);
            color: #babdbd;
            font-size: 30px;
            padding: 20px 0px;
            font-weight: bold;
            font-family: "Open Sans", sans-serif;
        }
    </style>

</head>
<body>

<div id="app" style="width: 800px; height: 300px; border: 1px solid black;">
    <line_chart_vue :name="lineName1" :route="line1route" :code="lineCode" :gps="line1gps" :width="width" :height="height"></line_chart_vue>
</div>

<input type="button" value="线路路由数据源1" onclick="switchLineData1()">
<input type="button" value="线路路由数据源2" onclick="switchLineData2()">
<input type="button" value="width=600" onclick="switchWidth()">
<input type="button" value="width=700" onclick="switchWidth2()">

<script>
    /*
        线路路由测试数据
     */
    /**
     * 测试的线路路由数据
     * 上行路由起点战到终点战:A B C D E F
     * 下行路由终点战到起点站:A C1 D E1 F
     * 按照绘制需求合并路由数据图示如下:
     *  A B  C D E  F
     *  A C1   D E1 F
     */
    var test_route_data = [
        {
            names: ["A起点站"], // 站点名字数组
            ids: ["ACODE_0", "ACODE_1"], // 站点编码_上下行
            type: 2, // 0:上行 1:下行 2:同名合并 3:异名合并
            stationMark: "B"
        },
        {
            names: ["B中途站", "C1中途站"],
            ids: ["BCODE_0", "C1CODE_1"],
            type: 3,
            stationMark: "Z"
        },
        {
            names: ["C中途站"],
            ids: ["CCODE_0"],
            type: 0,
            stationMark: "Z"
        },
        {
            names: ["D中途站"],
            ids: ["DCODE_0", "DCODE_1"],
            type: 2,
            stationMark: "Z"
        },
        {
            names: ["E中途站", "E1中途站"],
            ids: ["ECODE_0", "E1CODE_1"],
            type: 3,
            stationMark: "Z"
        },
        {
            names: ["F终点站"],
            ids: ["FCODE_0", "FCODE_1"],
            type: 2,
            stationMark: "E"
        }
    ];

    var test_route_data_copy = [
        {
            names: ["A起点站"], // 站点名字数组
            ids: ["ACODE_0", "ACODE_1"], // 站点编码_上下行
            type: 2, // 0:上行 1:下行 2:同名合并 3:异名合并
            stationMark: "B"
        },
        {
            names: ["B中途站", "C1中途站"],
            ids: ["BCODE_0", "C1CODE_1"],
            type: 3,
            stationMark: "Z"
        },
        {
            names: ["C中途站"],
            ids: ["CCODE_0"],
            type: 0,
            stationMark: "Z"
        },
        {
            names: ["D中途站"],
            ids: ["DCODE_0", "DCODE_1"],
            type: 2,
            stationMark: "Z"
        },
        {
            names: ["E中途站", "E1中途站"],
            ids: ["ECODE_0", "E1CODE_1"],
            type: 3,
            stationMark: "Z"
        },
        {
            names: ["F终点站"],
            ids: ["FCODE_0", "FCODE_1"],
            type: 2,
            stationMark: "E"
        }
    ];

    var test_route_data2 = [
        {
            names: ["A起点站中中中"], // 站点名字数组
            ids: ["ACODE_0", "ACODE_1"], // 站点编码_上下行
            type: 2, // 0:上行 1:下行 2:同名合并 3:异名合并
            stationMark: "B"
        },
        {
            names: ["B中途站", "C1中途站"],
            ids: ["BCODE_0", "C1CODE_1"],
            type: 3,
            stationMark: "Z"
        }
    ];

    /**
     * 测试用gps数据(对应后台GpsEntity)。
     * @type {*[]}
     */
    var test_gps_data = [
        {
            stopNo: 'BCODE', // 站点编码
            upDown: 0, // 上下行(0 上行 , 1 下行 , -1 无效)
            deviceId: '559L1014', // 设备编码
            instation: 1, // 0: 站外 1:站内 2:场内
            nbbm: 'W2B-064' // 车辆内部编码(自编号)
        },
        {
            stopNo: 'BCODE', // 站点编码
            upDown: 0, // 上下行(0 上行 , 1 下行 , -1 无效)
            deviceId: '559L1013', // 设备编码
            instation: 1, // 0: 站外 1:站内 2:场内
            nbbm: 'W2B-065' // 车辆内部编码(自编号)
        },
        {
            stopNo: 'CCODE', // 站点编码
            upDown: 0, // 上下行(0 上行 , 1 下行 , -1 无效)
            deviceId: '559L1015', // 设备编码
            instation: 0, // 0: 站外 1:站内 2:场内
            nbbm: 'W2B-066' // 车辆内部编码(自编号)
        },
        {
            stopNo: 'E1CODE', // 站点编码
            upDown: 1, // 上下行(0 上行 , 1 下行 , -1 无效)
            deviceId: '559L1025', // 设备编码
            instation: 1, // 0: 站外 1:站内 2:场内
            nbbm: 'W2B-026' // 车辆内部编码(自编号)
        },

        {
            stopNo: 'ACODE', // 站点编码
            upDown: 1, // 上下行(0 上行 , 1 下行 , -1 无效)
            deviceId: '559L1035', // 设备编码
            instation: 1, // 0: 站外 1:站内 2:场内
            nbbm: 'W2B-036' // 车辆内部编码(自编号)
        },
        {
            stopNo: 'ACODE', // 站点编码
            upDown: 1, // 上下行(0 上行 , 1 下行 , -1 无效)
            deviceId: '559L1045', // 设备编码
            instation: 1, // 0: 站外 1:站内 2:场内
            nbbm: 'W2B-046' // 车辆内部编码(自编号)
        },
        {
            stopNo: 'ACODE', // 站点编码
            upDown: 1, // 上下行(0 上行 , 1 下行 , -1 无效)
            deviceId: '559L1055', // 设备编码
            instation: 1, // 0: 站外 1:站内 2:场内
            nbbm: 'W2B-056' // 车辆内部编码(自编号)
        }

    ];


    var vm = new Vue({
        data: {
            lineName1: '测试线路1',
            line1route: test_route_data,
            line1gps: test_gps_data,
            lineCode: '线路编码1',
            width: 600,
            height: 240
        },
        el: '#app',
        components: {
            'line_chart_vue': line_chart_vue
        }
    });

    function switchLineData1() {
        vm.line1route = test_route_data;
    }

    function switchLineData2() {
        vm.line1route = test_route_data2;
    }
    function switchWidth() {
        vm.width = 600;
    }
    function switchWidth2() {
        vm.width = 700;
    }

</script>

</body>
</html>