メインコンテンツへスキップ
見出し画像

Splunk ダッシュボードで東京路線図を作ってみた 🚃 レベルアップ編


    はじめに

    こんにちは!今回は Splunk Enterprise のダッシュボード機能を使って、HTML/CSSのみで東京の鉄道路線図を作成②をしてみました。

    データ分析ツールであるSplunkですが、実はHTMLパネルを使えば自由にビジュアライゼーションを作成できます。今回はその機能を活用して、28駅・8路線・28本の接続線を持つ本格的な路線図を実装しました!

    完成イメージ

    画像

    実装した路線

    • 🟢 JR山手線 (上野・秋葉原・東京・有楽町・新橋・浜松町・田町・品川)

    • 🟠 JR中央線 (御茶ノ水・東京・四ツ谷・新宿・中野)

    • 🔵 JR京浜東北線 (大宮・川口・東京・川崎・横浜)

    • 🟡 JR総武線 (秋葉原・船橋・千葉)

    • 🔴 東京メトロ丸ノ内線 (池袋・新宿三丁目・銀座)

    • 🟠 東京メトロ銀座線 (浅草・上野・渋谷・銀座)

    • 🔵 東京メトロ東西線 (大手町・高田馬場・中野・西船橋)

    • 🔵 新幹線 (東京・名古屋・京都)

    技術的なポイント

    1. 絶対配置による自由なレイアウト

    .station {
      position: absolute; /* 自由な位置に配置可能 */
      background: white;
      border: 5px solid;
      border-radius: 15px;
      /* ... */
    }
    

    各駅を position: absolute で配置することで、複雑な路線図のレイアウトを実現しています。

    2. CSSクラスによる座標管理

    /* 東京駅の位置 */
    .pos-tokyo { 
      top: 320px; 
      left: 150px; 
    }
    
    /* 新宿駅の位置 */
    .pos-shinjuku { 
      top: 320px; 
      left: 550px; 
    }
    

    各駅の座標を個別のCSSクラスとして定義することで、保守性を向上させています。

    3. グラデーションによる視覚効果

    .yamanote {
      border-color: #9ACD32;
      background: linear-gradient(135deg, #9ACD32 0%, #ffffff 100%);
    }
    
    .line-yamanote {
      background: linear-gradient(180deg, #9ACD32 0%, #7FB800 100%);
    }
    

    各路線に対して、枠線と背景にグラデーションを適用し、立体感を演出しています。

    4. ホバーエフェクト

    .station:hover {
      transform: scale(1.15) rotate(2deg); /* 拡大&回転 */
      box-shadow: 0 15px 40px rgba(0,0,0,0.6);
      z-index: 100;
    }
    

    マウスホバー時に駅が拡大・回転することで、インタラクティブな体験を提供しています。

    5. 斜め線の実装

    .line27 {
      width: 380px;
      height: 8px;
      transform: rotate(25deg); /* 25度回転 */
      transform-origin: left center;
    }
    

    新幹線などの斜め路線は、transform: rotate() を使用して実装しています。

    コード構造

    ディレクトリ構成(概念的な)

    splunk-dashboard/
    ├── style.css          # CSSスタイル定義
    │   ├── .route-map    # 全体コンテナ
    │   ├── .station      # 駅スタイル
    │   ├── .line         # 路線スタイル
    │   └── .legend       # 凡例スタイル
    └── index.html         # HTML構造
        ├── stations/     # 駅要素
        ├── lines/        # 路線要素
        └── legend/       # 凡例要素
    

    主要なCSSクラス

    クラス名 役割 例
    .route-map 路線図全体のコンテナ 背景・パディング設定
    .station 駅の基本スタイル 枠線・影・ホバー効果
    .line 路線の基本スタイル 幅・高さ・色
    .yamanote 山手線カラー 緑色 (#9ACD32)
    .chuo 中央線カラー オレンジ色 (#FF6F00)
    .pos-tokyo 東京駅の座標 top/left指定

    実装のコツ

    1. 駅の座標計算

    路線図を美しく見せるには、駅の間隔を均等にすることが重要です。

    /* 山手線の駅を100px間隔で配置 */
    .pos-ueno       { top: 80px;  left: 150px; }
    .pos-akihabara  { top: 200px; left: 150px; } /* +120px */
    .pos-tokyo      { top: 320px; left: 150px; } /* +120px */
    .pos-yurakucho  { top: 440px; left: 150px; } /* +120px */
    

    2. 路線の接続

    駅の中心を通るように線を配置します。駅の幅を考慮して計算します。

    駅の左端 + (駅の幅 / 2) - (線の幅 / 2) = 線の左端
    150px + (110px / 2) - (8px / 2) = 197px
    

    3. 色の選択

    実際の路線カラーに近い色を使用することで、リアリティを向上させています。

    /* 実際の路線カラーを参考に */
    #9ACD32  /* 山手線 - 黄緑 */
    #FF6F00  /* 中央線 - オレンジ */
    #00BFFF  /* 京浜東北線 - 水色 */
    #DC143C  /* 丸ノ内線 - 赤 */
    

    Splunkへの実装方法

    Step 1: ダッシュボードを作成

    Settings > Dashboards > Create New Dashboard
    

    Step 2: XMLエディタを開く

    Edit > Edit Source (XML)
    

    Step 3: コードを貼り付け

    提供された完全なXMLコードを貼り付けます。

    <dashboard version="1.1">
      <label>🚃 東京鉄道路線図 - 完全版</label>
      <row>
        <panel>
          <html>
            <style>
              /* ここにCSSを記述 */
            </style>
            <div class="route-map">
              <!-- ここにHTMLを記述 -->
            </div>
          </html>
        </panel>
      </row>
    </dashboard>
    

    Step 4: 保存して確認

    保存後、ダッシュボードを開くと路線図が表示されます!

    カスタマイズアイデア

    1. リアルタイムデータの表示

    <div class="station yamanote pos-tokyo">
      <div class="station-icon">🏢</div>
      <div class="station-name">東京</div>
      <div class="station-data">
        <!-- Splunkのサーチ結果を表示 -->
        混雑度: <span id="tokyo-crowd">60%</span>
      </div>
    </div>
    

    2. 駅のクリックイベント

    document.querySelectorAll('.station').forEach(station => {
      station.addEventListener('click', function() {
        const stationName = this.querySelector('.station-name').textContent;
        alert(`${stationName}駅の詳細情報を表示`);
      });
    });
    

    3. アニメーション効果

    @keyframes train-move {
      0% { left: 150px; }
      100% { left: 550px; }
    }
    
    .train {
      position: absolute;
      animation: train-move 5s linear infinite;
    }
    

    パフォーマンス最適化

    1. CSSの最適化

    不要なスタイルを削除し、共通部分をまとめることで、ファイルサイズを削減できます。

    2. z-indexの管理

    /* 重なり順を明確に */
    .line        { z-index: 1; }   /* 最下層 */
    .station     { z-index: 10; }  /* 中間層 */
    .station:hover { z-index: 100; } /* ホバー時は最前面 */
    .legend      { z-index: 50; }  /* 凡例は常に上 */
    

    3. レスポンシブ対応

    @media (max-width: 1024px) {
      .route-map {
        min-height: 800px;
        padding: 20px;
      }
      
      .station {
        min-width: 80px;
        font-size: 12px;
      }
    }
    

    トラブルシューティング

    問題1: 駅が表示されない

    原因: position: absolute の基準となる親要素に position: relative が設定されていない

    解決策:

    .route-map {
      position: relative; /* これが必須! */
    }
    

    問題2: 線がずれている

    原因: 駅のサイズ変更に伴い、線の位置が合わなくなった

    解決策: 駅の中心座標を再計算して、線の位置を調整する

    問題3: ホバーエフェクトが効かない

    原因: z-indexの設定が不適切

    解決策:

    .station:hover {
      z-index: 100; /* 他の要素より大きい値 */
    }
    

    まとめ

    SplunkのHTMLパネルを使えば、データ分析ツールでありながら、自由なビジュアライゼーションを実現できます。

    今回のポイント:

    • ✅ position: absolute による柔軟な配置

    • ✅ CSSクラスによる座標管理で保守性向上

    • ✅ グラデーションとホバーエフェクトで視覚的魅力を向上

    • ✅ 完全なコメント付きで学習しやすい

    次のステップ

    • 🔄 リアルタイムの列車位置情報を統合

    • 📊 混雑度データの可視化

    • 🎯 駅クリックで詳細情報を表示

    • 🗺️ 他の都市の路線図作成

    参考リンク

    コード全文

    画像
    <dashboard version="1.1">
      <!-- ============================================
           ダッシュボードのタイトル設定
      ============================================ -->
      <label>【編集用】118 東京駅路線図 - 複雑版</label>
      <!-- ============================================
           ダッシュボードの説明文
      ============================================ -->
      <description>HTML/CSSのみで実装した東京駅周辺の路線図</description>
      <!-- ============================================
           1つ目の行(Row)開始
      ============================================ -->
      <!-- 行終了 -->
      <row>
        <panel>
          <!-- ============================================
               HTMLコンテンツ開始
          ============================================ -->
          <!-- HTMLコンテンツ終了 -->
          <html>
            <!-- ============================================
                 CSSスタイル定義開始
            ============================================ -->
            <style>
              /* ==========================================
                 全体のリセット(余白をゼロに)
              ========================================== */
              * {
                margin: 0; /* すべての要素の外側余白をゼロに */
                padding: 0; /* すべての要素の内側余白をゼロに */
                box-sizing: border-box; /* パディングとボーダーを幅に含める */
              }
              
              /* ==========================================
                 路線図全体のコンテナ
              ========================================== */
              .route-map {
                position: relative; /* 子要素の絶対配置の基準点にする */
                width: 100%; /* 幅を画面いっぱいに */
                min-height: 1200px; /* 最小高さを1200pxに設定(縦に長い路線図用) */
                background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%); /* 濃紺〜紫のグラデーション背景 */
                border-radius: 0; /* 角を丸くしない(画面いっぱい表示) */
                padding: 40px; /* 内側に40pxの余白 */
                overflow: hidden; /* はみ出した部分を隠す */
              }
              
              /* ==========================================
                 タイトルエリアのスタイル
              ========================================== */
              .map-title {
                text-align: center; /* テキストを中央揃え */
                color: #ffffff; /* 白文字 */
                font-size: 42px; /* 文字サイズを42pxに */
                font-weight: bold; /* 太字 */
                margin-bottom: 50px; /* 下に50pxの余白 */
                text-shadow: 0 0 20px rgba(255,255,255,0.3), 0 4px 10px rgba(0,0,0,0.8); /* 光る影効果 */
                letter-spacing: 4px; /* 文字間隔を4px空ける */
              }
              
              /* ==========================================
                 駅(四角形)の基本スタイル
              ========================================== */
              .station {
                position: absolute; /* 絶対配置(自由な位置に配置可能) */
                background: white; /* 背景色を白に */
                border: 5px solid; /* 枠線5px(色は個別に指定) */
                border-radius: 15px; /* 角を15px丸くする */
                padding: 15px 25px; /* 上下15px、左右25pxの内側余白 */
                box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 20px rgba(255,255,255,0.1); /* 影と光の効果 */
                text-align: center; /* テキストを中央揃え */
                font-weight: bold; /* 太字 */
                font-size: 15px; /* 文字サイズ15px */
                color: #222; /* 濃いグレーの文字色 */
                min-width: 110px; /* 最小幅110px */
                transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); /* アニメーション(バウンス効果) */
                z-index: 10; /* 重なり順(線より上に表示) */
                cursor: pointer; /* マウスカーソルをポインターに */
              }
              
              /* ==========================================
                 駅にマウスを乗せたときのエフェクト
              ========================================== */
              .station:hover {
                transform: scale(1.15) rotate(2deg); /* 1.15倍に拡大&2度回転 */
                box-shadow: 0 15px 40px rgba(0,0,0,0.6), 0 0 30px rgba(255,255,255,0.3); /* 影を強化 */
                z-index: 100; /* 最前面に表示 */
              }
              
              /* ==========================================
                 駅のアイコン部分
              ========================================== */
              .station-icon {
                font-size: 28px; /* アイコンサイズ28px */
                margin-bottom: 8px; /* 下に8pxの余白 */
                filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); /* アイコンに影を付ける */
              }
              
              /* ==========================================
                 駅名テキスト部分
              ========================================== */
              .station-name {
                font-size: 14px; /* 文字サイズ14px */
                margin-top: 5px; /* 上に5pxの余白 */
                letter-spacing: 1px; /* 文字間隔を1px空ける */
              }
              
              /* ==========================================
                 路線(線)の基本スタイル
              ========================================== */
              .line {
                position: absolute; /* 絶対配置 */
                z-index: 1; /* 駅より下に表示 */
                transition: all 0.3s ease; /* アニメーション */
                box-shadow: 0 0 10px rgba(0,0,0,0.3); /* 線に影を付ける */
              }
              
              /* ==========================================
                 縦方向の路線スタイル
              ========================================== */
              .line-vertical {
                width: 8px; /* 幅8px */
                border-radius: 4px; /* 角を4px丸くする */
              }
              
              /* ==========================================
                 横方向の路線スタイル
              ========================================== */
              .line-horizontal {
                height: 8px; /* 高さ8px */
                border-radius: 4px; /* 角を4px丸くする */
              }
              
              /* ==========================================
                 JR山手線(緑色)のスタイル定義
              ========================================== */
              .yamanote {
                border-color: #9ACD32; /* 枠線の色:黄緑 */
                background: linear-gradient(135deg, #9ACD32 0%, #ffffff 100%); /* 黄緑から白へのグラデーション */
              }
              .line-yamanote {
                background: linear-gradient(180deg, #9ACD32 0%, #7FB800 100%); /* 黄緑のグラデーション */
              }
              
              /* ==========================================
                 JR中央線(オレンジ色)のスタイル定義
              ========================================== */
              .chuo {
                border-color: #FF6F00; /* 枠線の色:オレンジ */
                background: linear-gradient(135deg, #FF6F00 0%, #ffffff 100%); /* オレンジから白へのグラデーション */
              }
              .line-chuo {
                background: linear-gradient(90deg, #FF6F00 0%, #E65100 100%); /* オレンジのグラデーション */
              }
              
              /* ==========================================
                 JR京浜東北線(水色)のスタイル定義
              ========================================== */
              .keihin {
                border-color: #00BFFF; /* 枠線の色:水色 */
                background: linear-gradient(135deg, #00BFFF 0%, #ffffff 100%); /* 水色から白へのグラデーション */
              }
              .line-keihin {
                background: linear-gradient(180deg, #00BFFF 0%, #0099CC 100%); /* 水色のグラデーション */
              }
              
              /* ==========================================
                 JR総武線(黄色)のスタイル定義
              ========================================== */
              .sobu {
                border-color: #FFD700; /* 枠線の色:金色 */
                background: linear-gradient(135deg, #FFD700 0%, #ffffff 100%); /* 金色から白へのグラデーション */
              }
              .line-sobu {
                background: linear-gradient(90deg, #FFD700 0%, #FFC700 100%); /* 金色のグラデーション */
              }
              
              /* ==========================================
                 東京メトロ丸ノ内線(赤色)のスタイル定義
              ========================================== */
              .marunouchi {
                border-color: #DC143C; /* 枠線の色:赤 */
                background: linear-gradient(135deg, #DC143C 0%, #ffffff 100%); /* 赤から白へのグラデーション */
              }
              .line-marunouchi {
                background: linear-gradient(90deg, #DC143C 0%, #B71C1C 100%); /* 赤のグラデーション */
              }
              
              /* ==========================================
                 東京メトロ銀座線(オレンジ色)のスタイル定義
              ========================================== */
              .ginza {
                border-color: #FF9500; /* 枠線の色:明るいオレンジ */
                background: linear-gradient(135deg, #FF9500 0%, #ffffff 100%); /* オレンジから白へのグラデーション */
              }
              .line-ginza {
                background: linear-gradient(90deg, #FF9500 0%, #FF8C00 100%); /* オレンジのグラデーション */
              }
              
              /* ==========================================
                 東京メトロ東西線(水色)のスタイル定義
              ========================================== */
              .tozai {
                border-color: #009BBF; /* 枠線の色:青緑 */
                background: linear-gradient(135deg, #009BBF 0%, #ffffff 100%); /* 青緑から白へのグラデーション */
              }
              .line-tozai {
                background: linear-gradient(90deg, #009BBF 0%, #00838F 100%); /* 青緑のグラデーション */
              }
              
              /* ==========================================
                 新幹線(青色)のスタイル定義
              ========================================== */
              .shinkansen {
                border-color: #1E90FF; /* 枠線の色:青 */
                background: linear-gradient(135deg, #1E90FF 0%, #ffffff 100%); /* 青から白へのグラデーション */
              }
              .line-shinkansen {
                background: linear-gradient(135deg, #1E90FF 0%, #1976D2 100%); /* 青のグラデーション */
              }
              
              /* ==========================================
                 駅の配置(座標指定)
                 ※画面いっぱいに駅を配置
              ========================================== */
              
              /* 山手線エリア(左側縦ライン) */
              .pos-ueno { top: 80px; left: 150px; } /* 上野駅 */
              .pos-akihabara { top: 200px; left: 150px; } /* 秋葉原駅 */
              .pos-tokyo { top: 320px; left: 150px; } /* 東京駅(中心) */
              .pos-yurakucho { top: 440px; left: 150px; } /* 有楽町駅 */
              .pos-shinbashi { top: 560px; left: 150px; } /* 新橋駅 */
              .pos-hamamatsucho { top: 680px; left: 150px; } /* 浜松町駅 */
              .pos-tamachi { top: 800px; left: 150px; } /* 田町駅 */
              .pos-shinagawa { top: 920px; left: 150px; } /* 品川駅 */
              
              /* 中央線エリア(横ライン) */
              .pos-ochanomizu { top: 320px; left: 20px; } /* 御茶ノ水駅 */
              .pos-yotsuya { top: 320px; left: 350px; } /* 四ツ谷駅 */
              .pos-shinjuku { top: 320px; left: 550px; } /* 新宿駅 */
              .pos-nakano { top: 320px; left: 750px; } /* 中野駅 */
              
              /* 京浜東北線エリア(右側縦ライン) */
              .pos-omiya { top: 80px; left: 450px; } /* 大宮駅 */
              .pos-kawaguchi { top: 200px; left: 450px; } /* 川口駅 */
              .pos-yokohama { top: 920px; left: 450px; } /* 横浜駅 */
              .pos-kawasaki { top: 800px; left: 450px; } /* 川崎駅 */
              
              /* 総武線エリア(横ライン) */
              .pos-chiba { top: 200px; left: 750px; } /* 千葉駅 */
              .pos-funabashi { top: 200px; left: 600px; } /* 船橋駅 */
              
              /* 丸ノ内線エリア(右上縦ライン) */
              .pos-ikebukuro { top: 80px; left: 850px; } /* 池袋駅 */
              .pos-shinjuku3 { top: 200px; left: 850px; } /* 新宿三丁目駅 */
              .pos-ginza { top: 440px; left: 350px; } /* 銀座駅 */
              
              /* 銀座線エリア(横ライン) */
              .pos-asakusa { top: 80px; left: 350px; } /* 浅草駅 */
              .pos-ueno-ginza { top: 80px; left: 250px; } /* 上野駅(銀座線) */
              .pos-shibuya { top: 440px; left: 750px; } /* 渋谷駅 */
              
              /* 東西線エリア(横ライン) */
              .pos-nakano-tozai { top: 440px; left: 850px; } /* 中野駅(東西線) */
              .pos-takadanobaba { top: 440px; left: 650px; } /* 高田馬場駅 */
              .pos-otemachi { top: 440px; left: 250px; } /* 大手町駅 */
              .pos-nishifunabashi { top: 440px; left: 1050px; } /* 西船橋駅 */
              
              /* 新幹線エリア */
              .pos-nagoya { top: 800px; left: 600px; } /* 名古屋駅 */
              .pos-kyoto { top: 920px; left: 750px; } /* 京都駅 */
              
              /* ==========================================
                 路線(線)の配置
                 ※各駅を結ぶ線を配置
              ========================================== */
              
              /* 山手線 縦線(左側) */
              .line1 { top: 120px; left: 197px; height: 80px; } /* 上野→秋葉原 */
              .line2 { top: 240px; left: 197px; height: 80px; } /* 秋葉原→東京 */
              .line3 { top: 360px; left: 197px; height: 80px; } /* 東京→有楽町 */
              .line4 { top: 480px; left: 197px; height: 80px; } /* 有楽町→新橋 */
              .line5 { top: 600px; left: 197px; height: 80px; } /* 新橋→浜松町 */
              .line6 { top: 720px; left: 197px; height: 80px; } /* 浜松町→田町 */
              .line7 { top: 840px; left: 197px; height: 80px; } /* 田町→品川 */
              
              /* 中央線 横線 */
              .line8 { top: 337px; left: 90px; width: 60px; } /* 御茶ノ水→東京 */
              .line9 { top: 337px; left: 220px; width: 130px; } /* 東京→四ツ谷 */
              .line10 { top: 337px; left: 420px; width: 130px; } /* 四ツ谷→新宿 */
              .line11 { top: 337px; left: 620px; width: 130px; } /* 新宿→中野 */
              
              /* 京浜東北線 縦線(右側) */
              .line12 { top: 120px; left: 497px; height: 80px; } /* 大宮→川口 */
              .line13 { top: 240px; left: 497px; height: 80px; } /* 川口→東京 */
              .line14 { top: 360px; left: 497px; height: 440px; } /* 東京→川崎 */
              .line15 { top: 840px; left: 497px; height: 80px; } /* 川崎→横浜 */
              
              /* 総武線 横線 */
              .line16 { top: 217px; left: 220px; width: 380px; } /* 秋葉原→船橋 */
              .line17 { top: 217px; left: 650px; width: 100px; } /* 船橋→千葉 */
              
              /* 丸ノ内線 縦線 */
              .line18 { top: 120px; left: 897px; height: 80px; } /* 池袋→新宿三丁目 */
              .line19 { top: 240px; left: 897px; height: 200px; } /* 新宿三丁目→銀座方面 */
              
              /* 丸ノ内線 横線(銀座まで) */
              .line20 { top: 457px; left: 397px; width: 500px; } /* 銀座→新宿三丁目 */
              
              /* 銀座線 横線 */
              .line21 { top: 97px; left: 290px; width: 60px; } /* 上野→浅草 */
              .line22 { top: 97px; left: 390px; width: 360px; } /* 浅草→渋谷 */
              .line23 { top: 457px; left: 420px; width: 330px; } /* 銀座→渋谷 */
              
              /* 東西線 横線 */
              .line24 { top: 457px; left: 290px; width: 360px; } /* 大手町→高田馬場 */
              .line25 { top: 457px; left: 720px; width: 130px; } /* 高田馬場→中野 */
              .line26 { top: 457px; left: 920px; width: 130px; } /* 中野→西船橋 */
              
              /* 新幹線 斜め線 */
              .line27 {
                top: 360px; /* 上から360px */
                left: 220px; /* 左から220px */
                width: 380px; /* 幅380px */
                height: 8px; /* 高さ8px */
                transform: rotate(25deg); /* 25度回転(斜め) */
                transform-origin: left center; /* 回転の基準点:左中央 */
              }
              .line28 {
                top: 840px; /* 上から840px */
                left: 650px; /* 左から650px */
                width: 100px; /* 幅100px */
                height: 8px; /* 高さ8px */
                transform: rotate(35deg); /* 35度回転(斜め) */
                transform-origin: left center; /* 回転の基準点:左中央 */
              }
              
              /* ==========================================
                 凡例(路線の説明)エリア
              ========================================== */
              .legend {
                position: absolute; /* 絶対配置 */
                bottom: 40px; /* 下から40px */
                right: 40px; /* 右から40px */
                background: rgba(255,255,255,0.95); /* 半透明の白背景 */
                border-radius: 20px; /* 角を20px丸くする */
                padding: 25px; /* 内側に25pxの余白 */
                box-shadow: 0 15px 40px rgba(0,0,0,0.4), 0 0 20px rgba(255,255,255,0.2); /* 影と光の効果 */
                z-index: 50; /* 最前面に表示 */
                max-width: 300px; /* 最大幅300px */
              }
              
              /* 凡例のタイトル */
              .legend-title {
                font-size: 22px; /* 文字サイズ22px */
                font-weight: bold; /* 太字 */
                margin-bottom: 20px; /* 下に20pxの余白 */
                color: #222; /* 濃いグレー */
                text-align: center; /* 中央揃え */
                border-bottom: 3px solid #ddd; /* 下に3pxの線 */
                padding-bottom: 10px; /* 下に10pxのパディング */
              }
              
              /* 凡例の各項目 */
              .legend-item {
                display: flex; /* フレックスボックス */
                align-items: center; /* 垂直方向中央揃え */
                margin: 10px 0; /* 上下10pxの余白 */
                gap: 12px; /* 要素間の間隔12px */
              }
              
              /* 凡例の色サンプル(線) */
              .legend-color {
                width: 40px; /* 幅40px */
                height: 8px; /* 高さ8px */
                border-radius: 4px; /* 角を4px丸くする */
                box-shadow: 0 2px 5px rgba(0,0,0,0.2); /* 影を付ける */
              }
              
              /* 凡例のテキスト */
              .legend-text {
                font-size: 15px; /* 文字サイズ15px */
                color: #444; /* 濃いグレー */
                font-weight: 600; /* やや太字 */
              }
              
            </style>
            <!-- CSSスタイル定義終了 -->
            
            <!-- ============================================
                 HTMLコンテンツ(路線図本体)開始
            ============================================ -->
            <div class="route-map">
              <!-- ============================================
                   タイトル表示
              ============================================ -->
              <div class="map-title">🚃 東京鉄道路線図 - 完全版</div>
              
              <!-- ============================================
                   駅(Station)の配置
                   ※すべての駅を絶対配置で配置
              ============================================ -->
              
              <!-- 山手線の駅群 -->
              <div class="station yamanote pos-ueno">
                <div class="station-icon">🏛️</div> <!-- 上野駅のアイコン -->
                <div class="station-name">上野</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-akihabara">
                <div class="station-icon">🎮</div> <!-- 秋葉原駅のアイコン -->
                <div class="station-name">秋葉原</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-tokyo">
                <div class="station-icon">🏢</div> <!-- 東京駅のアイコン -->
                <div class="station-name">東京</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-yurakucho">
                <div class="station-icon">🎭</div> <!-- 有楽町駅のアイコン -->
                <div class="station-name">有楽町</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-shinbashi">
                <div class="station-icon">🏙️</div> <!-- 新橋駅のアイコン -->
                <div class="station-name">新橋</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-hamamatsucho">
                <div class="station-icon">🗼</div> <!-- 浜松町駅のアイコン -->
                <div class="station-name">浜松町</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-tamachi">
                <div class="station-icon">🏪</div> <!-- 田町駅のアイコン -->
                <div class="station-name">田町</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-shinagawa">
                <div class="station-icon">🚄</div> <!-- 品川駅のアイコン -->
                <div class="station-name">品川</div> <!-- 駅名 -->
              </div>
              
              <!-- 中央線の駅群 -->
              <div class="station chuo pos-ochanomizu">
                <div class="station-icon">📚</div> <!-- 御茶ノ水駅のアイコン -->
                <div class="station-name">御茶ノ水</div> <!-- 駅名 -->
              </div>
              
              <div class="station chuo pos-yotsuya">
                <div class="station-icon">🏯</div> <!-- 四ツ谷駅のアイコン -->
                <div class="station-name">四ツ谷</div> <!-- 駅名 -->
              </div>
              
              <div class="station chuo pos-shinjuku">
                <div class="station-icon">🌃</div> <!-- 新宿駅のアイコン -->
                <div class="station-name">新宿</div> <!-- 駅名 -->
              </div>
              
              <div class="station chuo pos-nakano">
                <div class="station-icon">🎪</div> <!-- 中野駅のアイコン -->
                <div class="station-name">中野</div> <!-- 駅名 -->
              </div>
              
              <!-- 京浜東北線の駅群 -->
              <div class="station keihin pos-omiya">
                <div class="station-icon">⚽</div> <!-- 大宮駅のアイコン -->
                <div class="station-name">大宮</div> <!-- 駅名 -->
              </div>
              
              <div class="station keihin pos-kawaguchi">
                <div class="station-icon">🏭</div> <!-- 川口駅のアイコン -->
                <div class="station-name">川口</div> <!-- 駅名 -->
              </div>
              
              <div class="station keihin pos-kawasaki">
                <div class="station-icon">🏭</div> <!-- 川崎駅のアイコン -->
                <div class="station-name">川崎</div> <!-- 駅名 -->
              </div>
              
              <div class="station keihin pos-yokohama">
                <div class="station-icon">⛵</div> <!-- 横浜駅のアイコン -->
                <div class="station-name">横浜</div> <!-- 駅名 -->
              </div>
              
              <!-- 総武線の駅群 -->
              <div class="station sobu pos-funabashi">
                <div class="station-icon">⚓</div> <!-- 船橋駅のアイコン -->
                <div class="station-name">船橋</div> <!-- 駅名 -->
              </div>
              
              <div class="station sobu pos-chiba">
                <div class="station-icon">🥜</div> <!-- 千葉駅のアイコン -->
                <div class="station-name">千葉</div> <!-- 駅名 -->
              </div>
              
              <!-- 丸ノ内線の駅群 -->
              <div class="station marunouchi pos-ikebukuro">
                <div class="station-icon">🦉</div> <!-- 池袋駅のアイコン -->
                <div class="station-name">池袋</div> <!-- 駅名 -->
              </div>
              
              <div class="station marunouchi pos-shinjuku3">
                <div class="station-icon">🛍️</div> <!-- 新宿三丁目駅のアイコン -->
                <div class="station-name">新宿三丁目</div> <!-- 駅名 -->
              </div>
              
              <div class="station marunouchi pos-ginza">
                <div class="station-icon">💎</div> <!-- 銀座駅のアイコン -->
                <div class="station-name">銀座</div> <!-- 駅名 -->
              </div>
              
              <!-- 銀座線の駅群 -->
              <div class="station ginza pos-asakusa">
                <div class="station-icon">🏮</div> <!-- 浅草駅のアイコン -->
                <div class="station-name">浅草</div> <!-- 駅名 -->
              </div>
              
              <div class="station ginza pos-ueno-ginza">
                <div class="station-icon">🎨</div> <!-- 上野駅(銀座線)のアイコン -->
                <div class="station-name">上野</div> <!-- 駅名 -->
              </div>
              
              <div class="station ginza pos-shibuya">
                <div class="station-icon">🎵</div> <!-- 渋谷駅のアイコン -->
                <div class="station-name">渋谷</div> <!-- 駅名 -->
              </div>
              
              <!-- 東西線の駅群 -->
              <div class="station tozai pos-otemachi">
                <div class="station-icon">🏦</div> <!-- 大手町駅のアイコン -->
                <div class="station-name">大手町</div> <!-- 駅名 -->
              </div>
              
              <div class="station tozai pos-takadanobaba">
                <div class="station-icon">🎓</div> <!-- 高田馬場駅のアイコン -->
                <div class="station-name">高田馬場</div> <!-- 駅名 -->
              </div>
              
              <div class="station tozai pos-nakano-tozai">
                <div class="station-icon">🎬</div> <!-- 中野駅(東西線)のアイコン -->
                <div class="station-name">中野</div> <!-- 駅名 -->
              </div>
              
              <div class="station tozai pos-nishifunabashi">
                <div class="station-icon">🚢</div> <!-- 西船橋駅のアイコン -->
                <div class="station-name">西船橋</div> <!-- 駅名 -->
              </div>
              
              <!-- 新幹線の駅群 -->
              <div class="station shinkansen pos-nagoya">
                <div class="station-icon">🏯</div> <!-- 名古屋駅のアイコン -->
                <div class="station-name">名古屋</div> <!-- 駅名 -->
              </div>
              
              <div class="station shinkansen pos-kyoto">
                <div class="station-icon">⛩️</div> <!-- 京都駅のアイコン -->
                <div class="station-name">京都</div> <!-- 駅名 -->
              </div>
              
              <!-- ============================================
                   路線(Line)の配置
                   ※各駅を結ぶ線を配置
              ============================================ -->
              
              <!-- 山手線の縦線群(左側ライン) -->
              <div class="line line-vertical line-yamanote line1"/> <!-- 上野→秋葉原 -->
              <div class="line line-vertical line-yamanote line2"/> <!-- 秋葉原→東京 -->
              <div class="line line-vertical line-yamanote line3"/> <!-- 東京→有楽町 -->
              <div class="line line-vertical line-yamanote line4"/> <!-- 有楽町→新橋 -->
              <div class="line line-vertical line-yamanote line5"/> <!-- 新橋→浜松町 -->
              <div class="line line-vertical line-yamanote line6"/> <!-- 浜松町→田町 -->
              <div class="line line-vertical line-yamanote line7"/> <!-- 田町→品川 -->
              
              <!-- 中央線の横線群 -->
              <div class="line line-horizontal line-chuo line8"/> <!-- 御茶ノ水→東京 -->
              <div class="line line-horizontal line-chuo line9"/> <!-- 東京→四ツ谷 -->
              <div class="line line-horizontal line-chuo line10"/> <!-- 四ツ谷→新宿 -->
              <div class="line line-horizontal line-chuo line11"/> <!-- 新宿→中野 -->
              
              <!-- 京浜東北線の縦線群(右側ライン) -->
              <div class="line line-vertical line-keihin line12"/> <!-- 大宮→川口 -->
              <div class="line line-vertical line-keihin line13"/> <!-- 川口→東京 -->
              <div class="line line-vertical line-keihin line14"/> <!-- 東京→川崎 -->
              <div class="line line-vertical line-keihin line15"/> <!-- 川崎→横浜 -->
              
              <!-- 総武線の横線群 -->
              <div class="line line-horizontal line-sobu line16"/> <!-- 秋葉原→船橋 -->
              <div class="line line-horizontal line-sobu line17"/> <!-- 船橋→千葉 -->
              
              <!-- 丸ノ内線の縦線群 -->
              <div class="line line-vertical line-marunouchi line18"/> <!-- 池袋→新宿三丁目 -->
              <div class="line line-vertical line-marunouchi line19"/> <!-- 新宿三丁目→銀座方面 -->
              
              <!-- 丸ノ内線の横線(銀座まで) -->
              <div class="line line-horizontal line-marunouchi line20"/> <!-- 銀座→新宿三丁目 -->
              
              <!-- 銀座線の横線群 -->
              <div class="line line-horizontal line-ginza line21"/> <!-- 上野→浅草 -->
              <div class="line line-horizontal line-ginza line22"/> <!-- 浅草→渋谷 -->
              <div class="line line-horizontal line-ginza line23"/> <!-- 銀座→渋谷 -->
              
              <!-- 東西線の横線群 -->
              <div class="line line-horizontal line-tozai line24"/> <!-- 大手町→高田馬場 -->
              <div class="line line-horizontal line-tozai line25"/> <!-- 高田馬場→中野 -->
              <div class="line line-horizontal line-tozai line26"/> <!-- 中野→西船橋 -->
              
              <!-- 新幹線の斜め線群 -->
              <div class="line line-horizontal line-shinkansen line27"/> <!-- 東京→名古屋 -->
              <div class="line line-horizontal line-shinkansen line28"/> <!-- 名古屋→京都 -->
              
              <!-- ============================================
                   凡例(Legend)エリア
                   ※画面右下に路線の説明を表示
              ============================================ -->
              <div class="legend">
                <!-- 凡例のタイトル -->
                <div class="legend-title">🚃 路線凡例</div>
                
                <!-- JR山手線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #9ACD32 0%, #7FB800 100%);"/> <!-- 緑色の線サンプル -->
                  <div class="legend-text">JR山手線</div> <!-- 路線名 -->
                </div>
                
                <!-- JR中央線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #FF6F00 0%, #E65100 100%);"/> <!-- オレンジ色の線サンプル -->
                  <div class="legend-text">JR中央線</div> <!-- 路線名 -->
                </div>
                
                <!-- JR京浜東北線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #00BFFF 0%, #0099CC 100%);"/> <!-- 水色の線サンプル -->
                  <div class="legend-text">JR京浜東北線</div> <!-- 路線名 -->
                </div>
                
                <!-- JR総武線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #FFD700 0%, #FFC700 100%);"/> <!-- 金色の線サンプル -->
                  <div class="legend-text">JR総武線</div> <!-- 路線名 -->
                </div>
                
                <!-- 東京メトロ丸ノ内線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #DC143C 0%, #B71C1C 100%);"/> <!-- 赤色の線サンプル -->
                  <div class="legend-text">メトロ丸ノ内線</div> <!-- 路線名 -->
                </div>
                
                <!-- 東京メトロ銀座線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #FF9500 0%, #FF8C00 100%);"/> <!-- オレンジ色の線サンプル -->
                  <div class="legend-text">メトロ銀座線</div> <!-- 路線名 -->
                </div>
                
                <!-- 東京メトロ東西線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #009BBF 0%, #00838F 100%);"/> <!-- 青緑色の線サンプル -->
                  <div class="legend-text">メトロ東西線</div> <!-- 路線名 -->
                </div>
                
                <!-- 新幹線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #1E90FF 0%, #1976D2 100%);"/> <!-- 青色の線サンプル -->
                  <div class="legend-text">新幹線</div> <!-- 路線名 -->
                </div>
              </div>
              <!-- 凡例エリア終了 -->
              
            </div>
            <!-- 路線図本体終了 -->
            
          </html>
        </panel>
      </row>
    </dashboard><!-- ダッシュボード終了 -->
    

    Splunk路線図カスタマイズ完全ガイド - SPLでデータ連動させる方法 🚃📊

    前回の記事では、SplunkでHTML/CSSのみの静的な路線図を作成しました。さらに実用的な路線図を目指して、以下の3つを詳しく解説します:

    1. 🆕 駅と路線を追加する方法

    2. 🎨 SPL(Splunk Search Processing Language)でデータを取得

    3. 🔄 リアルタイムデータで色を動的に変更

    目次

    1. 駅と路線の追加方法

    2. SPLでデータを取得して表示

    3. 混雑度に応じて色を変更

    4. 実践:リアルタイム監視ダッシュボード

    5. 完全なコード例


    駅と路線の追加方法

    Step 1: 新しい駅を追加する

    1-1. CSSで座標を定義

    画像

    まず、追加する駅の位置を決めます。既存の駅との位置関係を考慮して座標を決定します。

    /* 例:渋谷駅を追加する場合 */
    .pos-shibuya {
      top: 320px;   /* 縦位置 */
      left: 850px;  /* 横位置 */
    }
    
    /* 例:目黒駅を追加する場合 */
    .pos-meguro {
      top: 560px;   /* 品川の下あたり */
      left: 300px;  /* 山手線の延長線上 */
    }
    

    1-2. 路線のスタイルを定義

    新しい路線を追加する場合は、その路線専用のスタイルを作成します。

    /* 例:東急東横線を追加 */
    .toyoko {
      border-color: #E6004C;  /* ピンク色 */
      background: linear-gradient(135deg, #E6004C 0%, #ffffff 100%);
    }
    
    .line-toyoko {
      background: linear-gradient(90deg, #E6004C 0%, #D10045 100%);
    }
    

    1-3. HTMLで駅要素を追加

    <!-- 渋谷駅を追加 -->
    <div class="station yamanote pos-shibuya" id="station-shibuya">
      <div class="station-icon">🎵</div>
      <div class="station-name">渋谷</div>
      <div class="station-status">通常</div>
    </div>
    
    <!-- 目黒駅を追加 -->
    <div class="station yamanote pos-meguro" id="station-meguro">
      <div class="station-icon">🌳</div>
      <div class="station-name">目黒</div>
      <div class="station-status">通常</div>
    </div>
    

    1-4. 路線(線)を追加

    新しい駅を既存の駅と接続する線を追加します。

    <!-- 品川→目黒の線 */
    <div class="line line-vertical line-yamanote" 
         style="top: 960px; left: 197px; height: 80px;"></div>
    
    <!-- 目黒→渋谷の線(斜め) */
    <div class="line line-horizontal line-yamanote" 
         style="top: 577px; left: 270px; width: 580px; transform: rotate(-10deg);"></div>
    

    Step 2: 路線を追加する(例:副都心線)

    2-1. 完全な新路線を追加

    /* 副都心線のスタイル定義 */
    .fukutoshin {
      border-color: #9C5E31;  /* 茶色 */
      background: linear-gradient(135deg, #9C5E31 0%, #ffffff 100%);
    }
    
    .line-fukutoshin {
      background: linear-gradient(90deg, #9C5E31 0%, #8B4513 100%);
    }
    
    /* 副都心線の駅座標 */
    .pos-wakoshi { top: 50px; left: 950px; }
    .pos-kotake { top: 150px; left: 950px; }
    .pos-ikebukuro-fuku { top: 250px; left: 950px; }
    .pos-shinjuku-fuku { top: 350px; left: 950px; }
    .pos-shibuya-fuku { top: 450px; left: 950px; }
    

    2-2. HTMLで駅を配置

    <!-- 副都心線の駅群 -->
    <div class="station fukutoshin pos-wakoshi" id="station-wakoshi">
      <div class="station-icon">🏘️</div>
      <div class="station-name">和光市</div>
    </div>
    
    <div class="station fukutoshin pos-kotake" id="station-kotake">
      <div class="station-icon">🌸</div>
      <div class="station-name">小竹向原</div>
    </div>
    
    <div class="station fukutoshin pos-ikebukuro-fuku" id="station-ikebukuro-fuku">
      <div class="station-icon">🦉</div>
      <div class="station-name">池袋</div>
    </div>
    
    <!-- 線を追加 -->
    <div class="line line-vertical line-fukutoshin" 
         style="top: 90px; left: 997px; height: 60px;"></div>
    <div class="line line-vertical line-fukutoshin" 
         style="top: 190px; left: 997px; height: 60px;"></div>
    <div class="line line-vertical line-fukutoshin" 
         style="top: 290px; left: 997px; height: 60px;"></div>
    

    座標計算のコツ

    // 駅の中心座標を計算する関数
    function calculateLinePosition(station1, station2) {
      const stationWidth = 110;  // 駅の幅
      const lineWidth = 8;       // 線の幅
      
      // 線の左端 = 駅の左端 + (駅の幅 / 2) - (線の幅 / 2)
      const lineLeft = station1.left + (stationWidth / 2) - (lineWidth / 2);
      
      // 線の高さ = 駅2の上端 - 駅1の下端
      const lineHeight = station2.top - (station1.top + 40); // 40pxは駅の高さ
      
      return {
        top: station1.top + 40,
        left: lineLeft,
        height: lineHeight
      };
    }
    
    // 使用例
    const tokyo = { top: 320, left: 150 };
    const shinbashi = { top: 560, left: 150 };
    const linePos = calculateLinePosition(tokyo, shinbashi);
    console.log(linePos); // { top: 360, left: 197, height: 200 }
    

    SPLでデータを取得して表示

    データソースの準備

    まず、Splunkにインデックスされるログデータの形式を定義します。

    サンプルデータ形式

    {
      "timestamp": "2026-01-18T10:30:00",
      "station_name": "tokyo",
      "line_name": "yamanote",
      "crowd_level": 85,
      "delay_minutes": 0,
      "status": "normal"
    }
    

    インデックスにデータを投入

    # イベント例
    2026-01-18 10:30:00 station_name=tokyo line_name=yamanote crowd_level=85 delay_minutes=0 status=normal
    2026-01-18 10:30:00 station_name=shinjuku line_name=chuo crowd_level=92 delay_minutes=5 status=crowded
    2026-01-18 10:30:00 station_name=shibuya line_name=yamanote crowd_level=78 delay_minutes=0 status=normal
    

    SPLで駅データを取得

    <dashboard version="1.1">
      <label>🚃 リアルタイム路線図</label>
      
      <!-- サーチ定義: 最新の駅情報を取得 -->
      <search id="station_status_search">
        <query>
          index=railway_data 
          | stats latest(crowd_level) as crowd_level, 
                  latest(delay_minutes) as delay_minutes,
                  latest(status) as status 
            by station_name, line_name
          | eval color = case(
              crowd_level >= 90, "red",
              crowd_level >= 70, "orange", 
              crowd_level >= 50, "yellow",
              1=1, "green"
            )
        </query>
        <earliest>-5m</earliest>
        <latest>now</latest>
        <refresh>30s</refresh>
      </search>
      
      <!-- 結果を表示 -->
      <row>
        <panel>
          <html>
            <style>
              /* CSSスタイル */
            </style>
            
            <div class="route-map">
              <!-- 駅の配置 -->
              <div class="station yamanote pos-tokyo" 
                   id="station-tokyo" 
                   data-station="tokyo">
                <div class="station-icon">🏢</div>
                <div class="station-name">東京</div>
                <div class="station-crowd">--</div>
                <div class="station-delay">--</div>
              </div>
              
              <!-- 他の駅も同様に配置 -->
            </div>
            
            <script>
              // Splunkのサーチ結果を取得
              require([
                'splunkjs/mvc',
                'splunkjs/mvc/searchmanager',
                'underscore',
                'jquery'
              ], function(mvc, SearchManager, _, $) {
                
                // サーチマネージャーを取得
                var searchManager = mvc.Components.get('station_status_search');
                
                // 結果を取得して処理
                var results = searchManager.data('results', {
                  output_mode: 'json',
                  count: 0
                });
                
                results.on('data', function() {
                  var data = results.data();
                  
                  if (data && data.rows) {
                    updateStations(data.rows);
                  }
                });
                
                // 駅情報を更新する関数
                function updateStations(rows) {
                  rows.forEach(function(row) {
                    var stationName = row[0];  // station_name
                    var lineName = row[1];      // line_name
                    var crowdLevel = row[2];    // crowd_level
                    var delayMinutes = row[3];  // delay_minutes
                    var status = row[4];        // status
                    var color = row[5];         // color
                    
                    // 駅要素を取得
                    var stationEl = $('#station-' + stationName);
                    
                    if (stationEl.length > 0) {
                      // 混雑度を表示
                      stationEl.find('.station-crowd').text(
                        '混雑度: ' + crowdLevel + '%'
                      );
                      
                      // 遅延時間を表示
                      stationEl.find('.station-delay').text(
                        delayMinutes > 0 ? '遅延: ' + delayMinutes + '分' : '定刻'
                      );
                      
                      // 色を変更
                      stationEl.css('background-color', getColorCode(color));
                      stationEl.css('border-color', getColorCode(color, true));
                    }
                  });
                }
                
                // 色コードを取得
                function getColorCode(color, isDark) {
                  var colors = {
                    'red': isDark ? '#cc0000' : '#ffcccc',
                    'orange': isDark ? '#ff6600' : '#ffddaa',
                    'yellow': isDark ? '#ffcc00' : '#ffffcc',
                    'green': isDark ? '#00cc00' : '#ccffcc'
                  };
                  return colors[color] || '#ffffff';
                }
              });
            </script>
          </html>
        </panel>
      </row>
    </dashboard>
    

    混雑度に応じて色を変更

    パターン1: 駅の背景色を変更

    // 混雑度に応じて駅の色を変更
    function updateStationColor(stationId, crowdLevel) {
      var stationEl = $('#station-' + stationId);
      var bgColor, borderColor;
      
      if (crowdLevel >= 90) {
        // 超混雑(赤)
        bgColor = 'linear-gradient(135deg, #ff0000 0%, #ffcccc 100%)';
        borderColor = '#cc0000';
      } else if (crowdLevel >= 70) {
        // 混雑(オレンジ)
        bgColor = 'linear-gradient(135deg, #ff6600 0%, #ffddaa 100%)';
        borderColor = '#ff6600';
      } else if (crowdLevel >= 50) {
        // やや混雑(黄色)
        bgColor = 'linear-gradient(135deg, #ffcc00 0%, #ffffcc 100%)';
        borderColor = '#ffcc00';
      } else {
        // 空いている(緑)
        bgColor = 'linear-gradient(135deg, #00cc00 0%, #ccffcc 100%)';
        borderColor = '#00cc00';
      }
      
      stationEl.css({
        'background': bgColor,
        'border-color': borderColor
      });
    }
    

    パターン2: 路線の色を変更

    // 路線の遅延状況に応じて色を変更
    function updateLineColor(lineClass, delayMinutes) {
      var lineColor;
      
      if (delayMinutes >= 10) {
        // 大幅遅延(赤)
        lineColor = 'linear-gradient(90deg, #ff0000 0%, #cc0000 100%)';
      } else if (delayMinutes >= 5) {
        // 遅延(オレンジ)
        lineColor = 'linear-gradient(90deg, #ff6600 0%, #ff3300 100%)';
      } else if (delayMinutes > 0) {
        // 小遅延(黄色)
        lineColor = 'linear-gradient(90deg, #ffcc00 0%, #ffaa00 100%)';
      } else {
        // 定刻(元の色に戻す)
        return; // 元の路線色を維持
      }
      
      $('.' + lineClass).css('background', lineColor);
    }
    
    // 使用例
    updateLineColor('line-yamanote', 8);  // 山手線が8分遅延
    updateLineColor('line-chuo', 0);      // 中央線は定刻
    

    パターン3: アニメーションで注意を促す

    /* 遅延時に点滅させる */
    @keyframes blink {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.5; }
    }
    
    .station-delayed {
      animation: blink 1s ease-in-out infinite;
      border-width: 6px;
    }
    
    /* 超混雑時に拡大縮小 */
    @keyframes pulse {
      0%, 100% { transform: scale(1); }
      50% { transform: scale(1.05); }
    }
    
    .station-crowded {
      animation: pulse 2s ease-in-out infinite;
    }
    
    // 状態に応じてアニメーションクラスを追加
    function updateStationAnimation(stationId, delayMinutes, crowdLevel) {
      var stationEl = $('#station-' + stationId);
      
      // 既存のアニメーションクラスを削除
      stationEl.removeClass('station-delayed station-crowded');
      
      // 遅延がある場合
      if (delayMinutes >= 5) {
        stationEl.addClass('station-delayed');
      }
      
      // 超混雑の場合
      if (crowdLevel >= 90) {
        stationEl.addClass('station-crowded');
      }
    }
    

    実践:リアルタイムhogehoge監視ダッシュボード

    完全な実装例

    <dashboard version="1.1">
      <label>🚃 リアルタイム路線図監視ダッシュボード</label>
      
      <!-- ============================================
           サーチ1: 駅ごとの最新状況
      ============================================ -->
      <search id="station_status">
        <query>
          index=railway_data sourcetype=station_status
          | stats latest(crowd_level) as crowd_level,
                  latest(delay_minutes) as delay_minutes,
                  latest(temperature) as temperature,
                  latest(status) as status
            by station_name
          | eval crowd_color = case(
              crowd_level >= 90, "red",
              crowd_level >= 70, "orange",
              crowd_level >= 50, "yellow",
              1=1, "green"
            )
          | eval delay_color = case(
              delay_minutes >= 10, "red",
              delay_minutes >= 5, "orange",
              delay_minutes > 0, "yellow",
              1=1, "green"
            )
        </query>
        <earliest>-5m</earliest>
        <latest>now</latest>
        <refresh>30s</refresh>
      </search>
      
      <!-- ============================================
           サーチ2: 路線ごとの平均遅延
      ============================================ -->
      <search id="line_status">
        <query>
          index=railway_data sourcetype=line_status
          | stats avg(delay_minutes) as avg_delay,
                  max(delay_minutes) as max_delay,
                  latest(status) as status
            by line_name
          | eval line_color = case(
              avg_delay >= 10, "red",
              avg_delay >= 5, "orange",
              avg_delay > 0, "yellow",
              1=1, "green"
            )
        </query>
        <earliest>-5m</earliest>
        <latest>now</latest>
        <refresh>30s</refresh>
      </search>
      
      <!-- ============================================
           メインパネル: 路線図
      ============================================ -->
      <row>
        <panel>
          <html>
            <style>
              /* 基本スタイル */
              .route-map {
                position: relative;
                width: 100%;
                min-height: 1000px;
                background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
                padding: 40px;
                overflow: hidden;
              }
              
              .map-title {
                text-align: center;
                color: white;
                font-size: 36px;
                font-weight: bold;
                margin-bottom: 30px;
              }
              
              /* 駅のスタイル */
              .station {
                position: absolute;
                background: white;
                border: 5px solid;
                border-radius: 15px;
                padding: 15px;
                text-align: center;
                min-width: 120px;
                transition: all 0.3s ease;
                z-index: 10;
                cursor: pointer;
              }
              
              .station-icon {
                font-size: 24px;
                margin-bottom: 5px;
              }
              
              .station-name {
                font-weight: bold;
                font-size: 14px;
                margin: 5px 0;
              }
              
              .station-crowd,
              .station-delay,
              .station-temp {
                font-size: 11px;
                color: #666;
                margin: 2px 0;
              }
              
              /* 路線のスタイル */
              .line {
                position: absolute;
                z-index: 1;
                transition: all 0.3s ease;
              }
              
              .line-vertical {
                width: 8px;
                border-radius: 4px;
              }
              
              .line-horizontal {
                height: 8px;
                border-radius: 4px;
              }
              
              /* アニメーション */
              @keyframes blink {
                0%, 100% { opacity: 1; }
                50% { opacity: 0.6; }
              }
              
              @keyframes pulse {
                0%, 100% { transform: scale(1); }
                50% { transform: scale(1.08); }
              }
              
              .station-delayed {
                animation: blink 1.5s ease-in-out infinite;
              }
              
              .station-crowded {
                animation: pulse 2s ease-in-out infinite;
              }
              
              /* 座標定義 */
              .pos-tokyo { top: 300px; left: 150px; }
              .pos-shinjuku { top: 300px; left: 550px; }
              .pos-shibuya { top: 300px; left: 850px; }
              .pos-shinagawa { top: 600px; left: 150px; }
              
              /* 路線色 */
              .line-yamanote { background: linear-gradient(90deg, #9ACD32 0%, #7FB800 100%); }
              .line-chuo { background: linear-gradient(90deg, #FF6F00 0%, #E65100 100%); }
              
              /* ステータスインジケーター */
              .status-indicator {
                position: absolute;
                top: 20px;
                right: 20px;
                background: white;
                padding: 20px;
                border-radius: 10px;
                box-shadow: 0 5px 15px rgba(0,0,0,0.3);
                z-index: 100;
              }
              
              .status-item {
                display: flex;
                align-items: center;
                margin: 10px 0;
                gap: 10px;
              }
              
              .status-dot {
                width: 15px;
                height: 15px;
                border-radius: 50%;
              }
              
              .status-dot.green { background: #00cc00; }
              .status-dot.yellow { background: #ffcc00; }
              .status-dot.orange { background: #ff6600; }
              .status-dot.red { background: #ff0000; }
            </style>
            
            <div class="route-map">
              <div class="map-title">🚃 リアルタイム路線図</div>
              
              <!-- ステータスインジケーター -->
              <div class="status-indicator">
                <h3 style="margin: 0 0 15px 0;">運行状況</h3>
                <div class="status-item">
                  <div class="status-dot green"></div>
                  <span>通常運行</span>
                </div>
                <div class="status-item">
                  <div class="status-dot yellow"></div>
                  <span>やや混雑/小遅延</span>
                </div>
                <div class="status-item">
                  <div class="status-dot orange"></div>
                  <span>混雑/遅延</span>
                </div>
                <div class="status-item">
                  <div class="status-dot red"></div>
                  <span>超混雑/大幅遅延</span>
                </div>
              </div>
              
              <!-- 駅の配置 -->
              <div class="station pos-tokyo" id="station-tokyo" data-station="tokyo">
                <div class="station-icon">🏢</div>
                <div class="station-name">東京</div>
                <div class="station-crowd">混雑度: --</div>
                <div class="station-delay">遅延: --</div>
                <div class="station-temp">温度: --</div>
              </div>
              
              <div class="station pos-shinjuku" id="station-shinjuku" data-station="shinjuku">
                <div class="station-icon">🌃</div>
                <div class="station-name">新宿</div>
                <div class="station-crowd">混雑度: --</div>
                <div class="station-delay">遅延: --</div>
                <div class="station-temp">温度: --</div>
              </div>
              
              <div class="station pos-shibuya" id="station-shibuya" data-station="shibuya">
                <div class="station-icon">🎵</div>
                <div class="station-name">渋谷</div>
                <div class="station-crowd">混雑度: --</div>
                <div class="station-delay">遅延: --</div>
                <div class="station-temp">温度: --</div>
              </div>
              
              <div class="station pos-shinagawa" id="station-shinagawa" data-station="shinagawa">
                <div class="station-icon">🚄</div>
                <div class="station-name">品川</div>
                <div class="station-crowd">混雑度: --</div>
                <div class="station-delay">遅延: --</div>
                <div class="station-temp">温度: --</div>
              </div>
              
              <!-- 路線 -->
              <div class="line line-horizontal line-chuo" 
                   style="top: 317px; left: 220px; width: 330px;" 
                   id="line-chuo"></div>
              <div class="line line-horizontal line-chuo" 
                   style="top: 317px; left: 620px; width: 230px;" 
                   id="line-chuo-2"></div>
              <div class="line line-vertical line-yamanote" 
                   style="top: 340px; left: 197px; height: 260px;" 
                   id="line-yamanote"></div>
            </div>
            
            <script>
              require([
                'splunkjs/mvc',
                'splunkjs/mvc/searchmanager',
                'underscore',
                'jquery'
              ], function(mvc, SearchManager, _, $) {
                
                // サーチマネージャーを取得
                var stationSearch = mvc.Components.get('station_status');
                var lineSearch = mvc.Components.get('line_status');
                
                // 駅データの処理
                var stationResults = stationSearch.data('results', {
                  output_mode: 'json',
                  count: 0
                });
                
                stationResults.on('data', function() {
                  var data = stationResults.data();
                  if (data && data.rows) {
                    updateStations(data.rows);
                  }
                });
                
                // 路線データの処理
                var lineResults = lineSearch.data('results', {
                  output_mode: 'json',
                  count: 0
                });
                
                lineResults.on('data', function() {
                  var data = lineResults.data();
                  if (data && data.rows) {
                    updateLines(data.rows);
                  }
                });
                
                // 駅情報を更新
                function updateStations(rows) {
                  rows.forEach(function(row) {
                    var stationName = row[0];      // station_name
                    var crowdLevel = parseInt(row[1]);    // crowd_level
                    var delayMinutes = parseInt(row[2]);  // delay_minutes
                    var temperature = row[3];      // temperature
                    var status = row[4];           // status
                    var crowdColor = row[5];       // crowd_color
                    var delayColor = row[6];       // delay_color
                    
                    var stationEl = $('#station-' + stationName);
                    
                    if (stationEl.length > 0) {
                      // テキスト更新
                      stationEl.find('.station-crowd').text('混雑度: ' + crowdLevel + '%');
                      stationEl.find('.station-delay').text(
                        delayMinutes > 0 ? '遅延: ' + delayMinutes + '分' : '定刻運行'
                      );
                      stationEl.find('.station-temp').text('温度: ' + temperature + '℃');
                      
                      // 色を更新
                      var bgColor = getGradientColor(crowdColor);
                      var borderColor = getSolidColor(crowdColor);
                      
                      stationEl.css({
                        'background': bgColor,
                        'border-color': borderColor
                      });
                      
                      // アニメーションクラスを管理
                      stationEl.removeClass('station-delayed station-crowded');
                      
                      if (delayMinutes >= 5) {
                        stationEl.addClass('station-delayed');
                      }
                      
                      if (crowdLevel >= 90) {
                        stationEl.addClass('station-crowded');
                      }
                    }
                  });
                }
                
                // 路線情報を更新
                function updateLines(rows) {
                  rows.forEach(function(row) {
                    var lineName = row[0];           // line_name
                    var avgDelay = parseFloat(row[1]);      // avg_delay
                    var maxDelay = parseInt(row[2]); // max_delay
                    var status = row[3];             // status
                    var lineColor = row[4];          // line_color
                    
                 
                    var lineEl = $('.line-' + lineName);
                    
                    if (lineEl.length > 0) {
                      var color = getLineGradient(lineColor);
                      lineEl.css('background', color);
                      
                      // 遅延が大きい場合は太くする
                      if (avgDelay >= 10) {
                        lineEl.css('height', '12px');
                      } else {
                        lineEl.css('height', '8px');
                      }
                    }
                  });
                }
                
                // グラデーション色を取得
                function getGradientColor(colorName) {
                  var gradients = {
                    'red': 'linear-gradient(135deg, #ff0000 0%, #ffcccc 100%)',
                    'orange': 'linear-gradient(135deg, #ff6600 0%, #ffddaa 100%)',
                    'yellow': 'linear-gradient(135deg, #ffcc00 0%, #ffffcc 100%)',
                    'green': 'linear-gradient(135deg, #00cc00 0%, #ccffcc 100%)'
                  };
                  return gradients[colorName] || 'linear-gradient(135deg, #ffffff 0%, #eeeeee 100%)';
                }
                
                // ソリッドカラーを取得
                function getSolidColor(colorName) {
                  var colors = {
                    'red': '#cc0000',
                    'orange': '#ff6600',
                    'yellow': '#ffcc00',
                    'green': '#00cc00'
                  };
                  return colors[colorName] || '#999999';
                }
                
                // 路線グラデーションを取得
                function getLineGradient(colorName) {
                  var gradients = {
                    'red': 'linear-gradient(90deg, #ff0000 0%, #cc0000 100%)',
                    'orange': 'linear-gradient(90deg, #ff6600 0%, #ff3300 100%)',
                    'yellow': 'linear-gradient(90deg, #ffcc00 0%, #ffaa00 100%)',
                    'green': 'linear-gradient(90deg, #9ACD32 0%, #7FB800 100%)'
                  };
                  return gradients[colorName] || 'linear-gradient(90deg, #999999 0%, #666666 100%)';
                }
                
                // 駅クリック時の詳細表示
                $('.station').on('click', function() {
                  var stationName = $(this).data('station');
                  var crowdText = $(this).find('.station-crowd').text();
                  var delayText = $(this).find('.station-delay').text();
                  var tempText = $(this).find('.station-temp').text();
                  
                  alert(
                    '駅名: ' + stationName + '\n' +
                    crowdText + '\n' +
                    delayText + '\n' +
                    tempText
                  );
                });
              });
            </script>
          </html>
        </panel>
      </row>
      
      <!-- ============================================
           統計情報パネル
      ============================================ -->
      <row>
        <panel>
          <title>駅別混雑度ランキング</title>
          <table>
            <search base="station_status">
              <query>
                | sort -crowd_level
                | head 10
                | table station_name crowd_level delay_minutes status
                | rename station_name as "駅名", crowd_level as "混雑度(%)", delay_minutes as "遅延(分)", status as "状態"
              </query>
            </search>
          </table>
        </panel>
        
        <panel>
          <title>路線別平均遅延</title>
          <table>
            <search base="line_status">
              <query>
                | sort -avg_delay
                | table line_name avg_delay max_delay status
                | rename line_name as "路線名", avg_delay as "平均遅延(分)", max_delay as "最大遅延(分)", status as "状態"
              </query>
            </search>
          </table>
        </panel>
      </row>
      
      <!-- ============================================
           時系列グラフ
      ============================================ -->
      <row>
        <panel>
          <title>混雑度の推移(過去1時間)</title>
          <chart>
            <search>
              <query>
                index=railway_data sourcetype=station_status
                | timechart span=5m avg(crowd_level) by station_name limit=5
              </query>
              <earliest>-1h</earliest>
              <latest>now</latest>
            </search>
            <option name="charting.chart">line</option>
            <option name="charting.axisTitleX.text">時刻</option>
            <option name="charting.axisTitleY.text">混雑度(%)</option>
          </chart>
        </panel>
      </row>
    </dashboard>
    ```
    
    ---
    
    ## 完全なコード例
    
    ### props.conf(データ取り込み設定)
    
    ```conf
    [railway_data]
    DATETIME_CONFIG = 
    INDEXED_EXTRACTIONS = json
    KV_MODE = none
    NO_BINARY_CHECK = true
    SHOULD_LINEMERGE = false
    TIME_PREFIX = "timestamp"\s*:\s*"
    category = Custom
    disabled = false
    pulldown_type = true
    ```
    
    ### サンプルデータ生成スクリプト
    
    ```python
    import json
    import random
    import time
    from datetime import datetime
    
    stations = ['tokyo', 'shinjuku', 'shibuya', 'shinagawa', 'ikebukuro']
    lines = ['yamanote', 'chuo', 'keihin', 'sobu']
    
    def generate_station_data():
        """駅データを生成"""
        data = {
            'timestamp': datetime.now().isoformat(),
            'station_name': random.choice(stations),
            'line_name': random.choice(lines),
            'crowd_level': random.randint(30, 100),
            'delay_minutes': random.choice([0, 0, 0, 2, 5, 10]),
            'temperature': round(random.uniform(18, 28), 1),
            'status': random.choice(['normal', 'normal', 'normal', 'crowded', 'delayed'])
        }
        return json.dumps(data)
    
    # Splunkに送信(HTTPイベントコレクター使用)
    import requests
    
    HEC_URL = 'https://your-splunk:8088/services/collector'
    HEC_TOKEN = 'your-hec-token-here'
    
    while True:
        data = generate_station_data()
        
        headers = {
            'Authorization': f'Splunk {HEC_TOKEN}'
        }
        
        payload = {
            'event': data,
            'sourcetype': 'station_status',
            'index': 'railway_data'
        }
        
        response = requests.post(HEC_URL, json=payload, headers=headers, verify=False)
        print(f'Sent: {data} - Status: {response.status_code}')
        
        time.sleep(30)  # 30秒ごとにデータ送信
    ```
    
    ---
    
    ## まとめ
    
    ### 今回学んだこと
    
    1. ✅ **駅と路線の追加方法**
       - CSS座標の計算
       - 新路線のスタイル定義
       - HTMLでの配置方法
    
    2. ✅ **SPLでデータ取得**
       - `stats`コマンドで集計
       - `eval`コマンドで色判定
       - リアルタイム更新設定
    
    3. ✅ **動的な色変更**
       - JavaScriptでDOM操作
       - グラデーション色の適用
       - アニメーション効果
    
    4. ✅ **実践的な監視ダッシュボード**
       - 複数サーチの連携
       - インタラクティブな操作
       - 統計情報の表示
    
    ### 次のステップ
    
    - 🎯 アラート機能の追加(混雑度90%以上で通知)
    - 📱 モバイル対応のレスポンシブデザイン
    - 🗺️ より多くの路線・駅の追加
    - 🤖 機械学習による混雑予測
    
    ---
    
    ## 参考リンク
    
    - [Splunk Dashboard Examples App](https://splunkbase.splunk.com/app/1603/)
    - [Splunk JavaScript SDK](https://docs.splunk.com/Documentation/JavaScriptSDK)
    - [CSS Transform Reference](https://developer.mozilla.org/ja/docs/Web/CSS/transform)
    
    ---
    
    

    東京鉄道路線図 - 拡張版(35駅・10路線)

    画像
    <dashboard version="1.1">
      <!-- ============================================
           ダッシュボードのタイトル設定
      ============================================ -->
      <label>東京鉄道路線図 - 拡張版(35駅・10路線)</label>
      <!-- ============================================
           ダッシュボードの説明文
      ============================================ -->
      <description>HTML/CSSのみで実装した東京駅周辺の路線図</description>
      <!-- ============================================
           1つ目の行(Row)開始
      ============================================ -->
      <!-- 行終了 -->
      <row>
        <panel>
          <title>東京鉄道路線図 - 拡張版(35駅・10路線)</title>
          <!-- ============================================
               HTMLコンテンツ開始
          ============================================ -->
          <!-- HTMLコンテンツ終了 -->
          <html>
            <!-- ============================================
                 CSSスタイル定義開始
            ============================================ -->
            <style>
              /* ==========================================
                 全体のリセット(余白をゼロに)
              ========================================== */
              * {
                margin: 0; /* すべての要素の外側余白をゼロに */
                padding: 0; /* すべての要素の内側余白をゼロに */
                box-sizing: border-box; /* パディングとボーダーを幅に含める */
              }
              
              /* ==========================================
                 路線図全体のコンテナ
              ========================================== */
              .route-map {
                position: relative; /* 子要素の絶対配置の基準点にする */
                width: 100%; /* 幅を画面いっぱいに */
                min-height: 1400px; /* 最小高さを1400pxに設定(さらに縦長に) */
                background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%); /* 濃紺〜紫のグラデーション背景 */
                border-radius: 0; /* 角を丸くしない(画面いっぱい表示) */
                padding: 40px; /* 内側に40pxの余白 */
                overflow: hidden; /* はみ出した部分を隠す */
              }
              
              /* ==========================================
                 タイトルエリアのスタイル
              ========================================== */
              .map-title {
                text-align: center; /* テキストを中央揃え */
                color: #ffffff; /* 白文字 */
                font-size: 42px; /* 文字サイズを42pxに */
                font-weight: bold; /* 太字 */
                margin-bottom: 50px; /* 下に50pxの余白 */
                text-shadow: 0 0 20px rgba(255,255,255,0.3), 0 4px 10px rgba(0,0,0,0.8); /* 光る影効果 */
                letter-spacing: 4px; /* 文字間隔を4px空ける */
              }
              
              /* ==========================================
                 駅(四角形)の基本スタイル
              ========================================== */
              .station {
                position: absolute; /* 絶対配置(自由な位置に配置可能) */
                background: white; /* 背景色を白に */
                border: 5px solid; /* 枠線5px(色は個別に指定) */
                border-radius: 15px; /* 角を15px丸くする */
                padding: 15px 25px; /* 上下15px、左右25pxの内側余白 */
                box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 20px rgba(255,255,255,0.1); /* 影と光の効果 */
                text-align: center; /* テキストを中央揃え */
                font-weight: bold; /* 太字 */
                font-size: 15px; /* 文字サイズ15px */
                color: #222; /* 濃いグレーの文字色 */
                min-width: 110px; /* 最小幅110px */
                transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); /* アニメーション(バウンス効果) */
                z-index: 10; /* 重なり順(線より上に表示) */
                cursor: pointer; /* マウスカーソルをポインターに */
              }
              
              /* ==========================================
                 駅にマウスを乗せたときのエフェクト
              ========================================== */
              .station:hover {
                transform: scale(1.15) rotate(2deg); /* 1.15倍に拡大&2度回転 */
                box-shadow: 0 15px 40px rgba(0,0,0,0.6), 0 0 30px rgba(255,255,255,0.3); /* 影を強化 */
                z-index: 100; /* 最前面に表示 */
              }
              
              /* ==========================================
                 駅のアイコン部分
              ========================================== */
              .station-icon {
                font-size: 28px; /* アイコンサイズ28px */
                margin-bottom: 8px; /* 下に8pxの余白 */
                filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); /* アイコンに影を付ける */
              }
              
              /* ==========================================
                 駅名テキスト部分
              ========================================== */
              .station-name {
                font-size: 14px; /* 文字サイズ14px */
                margin-top: 5px; /* 上に5pxの余白 */
                letter-spacing: 1px; /* 文字間隔を1px空ける */
              }
              
              /* ==========================================
                 路線(線)の基本スタイル
              ========================================== */
              .line {
                position: absolute; /* 絶対配置 */
                z-index: 1; /* 駅より下に表示 */
                transition: all 0.3s ease; /* アニメーション */
                box-shadow: 0 0 10px rgba(0,0,0,0.3); /* 線に影を付ける */
              }
              
              /* ==========================================
                 縦方向の路線スタイル
              ========================================== */
              .line-vertical {
                width: 8px; /* 幅8px */
                border-radius: 4px; /* 角を4px丸くする */
              }
              
              /* ==========================================
                 横方向の路線スタイル
              ========================================== */
              .line-horizontal {
                height: 8px; /* 高さ8px */
                border-radius: 4px; /* 角を4px丸くする */
              }
              
              /* ==========================================
                 JR山手線(緑色)のスタイル定義
              ========================================== */
              .yamanote {
                border-color: #9ACD32; /* 枠線の色:黄緑 */
                background: linear-gradient(135deg, #9ACD32 0%, #ffffff 100%); /* 黄緑から白へのグラデーション */
              }
              .line-yamanote {
                background: linear-gradient(180deg, #9ACD32 0%, #7FB800 100%); /* 黄緑のグラデーション */
              }
              
              /* ==========================================
                 JR中央線(オレンジ色)のスタイル定義
              ========================================== */
              .chuo {
                border-color: #FF6F00; /* 枠線の色:オレンジ */
                background: linear-gradient(135deg, #FF6F00 0%, #ffffff 100%); /* オレンジから白へのグラデーション */
              }
              .line-chuo {
                background: linear-gradient(90deg, #FF6F00 0%, #E65100 100%); /* オレンジのグラデーション */
              }
              
              /* ==========================================
                 JR京浜東北線(水色)のスタイル定義
              ========================================== */
              .keihin {
                border-color: #00BFFF; /* 枠線の色:水色 */
                background: linear-gradient(135deg, #00BFFF 0%, #ffffff 100%); /* 水色から白へのグラデーション */
              }
              .line-keihin {
                background: linear-gradient(180deg, #00BFFF 0%, #0099CC 100%); /* 水色のグラデーション */
              }
              
              /* ==========================================
                 JR総武線(黄色)のスタイル定義
              ========================================== */
              .sobu {
                border-color: #FFD700; /* 枠線の色:金色 */
                background: linear-gradient(135deg, #FFD700 0%, #ffffff 100%); /* 金色から白へのグラデーション */
              }
              .line-sobu {
                background: linear-gradient(90deg, #FFD700 0%, #FFC700 100%); /* 金色のグラデーション */
              }
              
              /* ==========================================
                 東京メトロ丸ノ内線(赤色)のスタイル定義
              ========================================== */
              .marunouchi {
                border-color: #DC143C; /* 枠線の色:赤 */
                background: linear-gradient(135deg, #DC143C 0%, #ffffff 100%); /* 赤から白へのグラデーション */
              }
              .line-marunouchi {
                background: linear-gradient(90deg, #DC143C 0%, #B71C1C 100%); /* 赤のグラデーション */
              }
              
              /* ==========================================
                 東京メトロ銀座線(オレンジ色)のスタイル定義
              ========================================== */
              .ginza {
                border-color: #FF9500; /* 枠線の色:明るいオレンジ */
                background: linear-gradient(135deg, #FF9500 0%, #ffffff 100%); /* オレンジから白へのグラデーション */
              }
              .line-ginza {
                background: linear-gradient(90deg, #FF9500 0%, #FF8C00 100%); /* オレンジのグラデーション */
              }
              
              /* ==========================================
                 東京メトロ東西線(水色)のスタイル定義
              ========================================== */
              .tozai {
                border-color: #009BBF; /* 枠線の色:青緑 */
                background: linear-gradient(135deg, #009BBF 0%, #ffffff 100%); /* 青緑から白へのグラデーション */
              }
              .line-tozai {
                background: linear-gradient(90deg, #009BBF 0%, #00838F 100%); /* 青緑のグラデーション */
              }
              
              /* ==========================================
                 東京メトロ副都心線(茶色)のスタイル定義 ★NEW★
              ========================================== */
              .fukutoshin {
                border-color: #9C5E31; /* 枠線の色:茶色 */
                background: linear-gradient(135deg, #9C5E31 0%, #ffffff 100%); /* 茶色から白へのグラデーション */
              }
              .line-fukutoshin {
                background: linear-gradient(180deg, #9C5E31 0%, #8B4513 100%); /* 茶色のグラデーション */
              }
              
              /* ==========================================
                 東急東横線(ピンク色)のスタイル定義 ★NEW★
              ========================================== */
              .toyoko {
                border-color: #E6004C; /* 枠線の色:ピンク */
                background: linear-gradient(135deg, #E6004C 0%, #ffffff 100%); /* ピンクから白へのグラデーション */
              }
              .line-toyoko {
                background: linear-gradient(180deg, #E6004C 0%, #D10045 100%); /* ピンクのグラデーション */
              }
              
              /* ==========================================
                 新幹線(青色)のスタイル定義
              ========================================== */
              .shinkansen {
                border-color: #1E90FF; /* 枠線の色:青 */
                background: linear-gradient(135deg, #1E90FF 0%, #ffffff 100%); /* 青から白へのグラデーション */
              }
              .line-shinkansen {
                background: linear-gradient(135deg, #1E90FF 0%, #1976D2 100%); /* 青のグラデーション */
              }
              
              /* ==========================================
                 駅の配置(座標指定)
                 ※画面いっぱいに駅を配置
              ========================================== */
              
              /* 山手線エリア(左側縦ライン) */
              .pos-ueno { top: 80px; left: 150px; } /* 上野駅 */
              .pos-akihabara { top: 200px; left: 150px; } /* 秋葉原駅 */
              .pos-tokyo { top: 320px; left: 150px; } /* 東京駅(中心) */
              .pos-yurakucho { top: 440px; left: 150px; } /* 有楽町駅 */
              .pos-shinbashi { top: 560px; left: 150px; } /* 新橋駅 */
              .pos-hamamatsucho { top: 680px; left: 150px; } /* 浜松町駅 */
              .pos-tamachi { top: 800px; left: 150px; } /* 田町駅 */
              .pos-shinagawa { top: 920px; left: 150px; } /* 品川駅 */
              .pos-meguro { top: 1040px; left: 150px; } /* 目黒駅 ★NEW★ */
              .pos-ebisu { top: 1160px; left: 150px; } /* 恵比寿駅 ★NEW★ */
              .pos-shibuya { top: 1280px; left: 150px; } /* 渋谷駅 ★NEW★ */
              
              /* 中央線エリア(横ライン) */
              .pos-ochanomizu { top: 320px; left: 20px; } /* 御茶ノ水駅 */
              .pos-yotsuya { top: 320px; left: 350px; } /* 四ツ谷駅 */
              .pos-shinjuku { top: 320px; left: 550px; } /* 新宿駅 */
              .pos-nakano { top: 320px; left: 750px; } /* 中野駅 */
              .pos-koenji { top: 320px; left: 950px; } /* 高円寺駅 ★NEW★ */
              
              /* 京浜東北線エリア(右側縦ライン) */
              .pos-omiya { top: 80px; left: 450px; } /* 大宮駅 */
              .pos-kawaguchi { top: 200px; left: 450px; } /* 川口駅 */
              .pos-yokohama { top: 920px; left: 450px; } /* 横浜駅 */
              .pos-kawasaki { top: 800px; left: 450px; } /* 川崎駅 */
              
              /* 総武線エリア(横ライン) */
              .pos-chiba { top: 200px; left: 950px; } /* 千葉駅 */
              .pos-funabashi { top: 200px; left: 750px; } /* 船橋駅 */
              
              /* 丸ノ内線エリア(右上縦ライン) */
              .pos-ikebukuro { top: 80px; left: 850px; } /* 池袋駅 */
              .pos-shinjuku3 { top: 200px; left: 850px; } /* 新宿三丁目駅 */
              .pos-ginza { top: 440px; left: 350px; } /* 銀座駅 */
              
              /* 銀座線エリア(横ライン) */
              .pos-asakusa { top: 80px; left: 350px; } /* 浅草駅 */
              .pos-ueno-ginza { top: 80px; left: 250px; } /* 上野駅(銀座線) */
              .pos-shibuya-ginza { top: 1280px; left: 350px; } /* 渋谷駅(銀座線) ★NEW★ */
              
              /* 東西線エリア(横ライン) */
              .pos-nakano-tozai { top: 440px; left: 850px; } /* 中野駅(東西線) */
              .pos-takadanobaba { top: 440px; left: 650px; } /* 高田馬場駅 */
              .pos-otemachi { top: 440px; left: 250px; } /* 大手町駅 */
              .pos-nishifunabashi { top: 440px; left: 1050px; } /* 西船橋駅 */
              
              /* 副都心線エリア(右側縦ライン) ★NEW★ */
              .pos-wakoshi { top: 20px; left: 1050px; } /* 和光市駅 ★NEW★ */
              .pos-kotake { top: 140px; left: 1050px; } /* 小竹向原駅 ★NEW★ */
              .pos-ikebukuro-fuku { top: 260px; left: 1050px; } /* 池袋駅(副都心線) ★NEW★ */
              .pos-shinjuku-fuku { top: 380px; left: 1050px; } /* 新宿駅(副都心線) ★NEW★ */
              .pos-shibuya-fuku { top: 1280px; left: 1050px; } /* 渋谷駅(副都心線) ★NEW★ */
              
              /* 東急東横線エリア(右下縦ライン) ★NEW★ */
              .pos-yokohama-toyoko { top: 1280px; left: 450px; } /* 横浜駅(東横線) ★NEW★ */
              .pos-musashikosugi { top: 1160px; left: 550px; } /* 武蔵小杉駅 ★NEW★ */
              
              /* 新幹線エリア */
              .pos-nagoya { top: 800px; left: 600px; } /* 名古屋駅 */
              .pos-kyoto { top: 920px; left: 750px; } /* 京都駅 */
              
              /* ==========================================
                 路線(線)の配置
                 ※各駅を結ぶ線を配置
              ========================================== */
              
              /* 山手線 縦線(左側) */
              .line1 { top: 120px; left: 197px; height: 80px; } /* 上野→秋葉原 */
              .line2 { top: 240px; left: 197px; height: 80px; } /* 秋葉原→東京 */
              .line3 { top: 360px; left: 197px; height: 80px; } /* 東京→有楽町 */
              .line4 { top: 480px; left: 197px; height: 80px; } /* 有楽町→新橋 */
              .line5 { top: 600px; left: 197px; height: 80px; } /* 新橋→浜松町 */
              .line6 { top: 720px; left: 197px; height: 80px; } /* 浜松町→田町 */
              .line7 { top: 840px; left: 197px; height: 80px; } /* 田町→品川 */
              .line8 { top: 960px; left: 197px; height: 80px; } /* 品川→目黒 ★NEW★ */
              .line9 { top: 1080px; left: 197px; height: 80px; } /* 目黒→恵比寿 ★NEW★ */
              .line10 { top: 1200px; left: 197px; height: 80px; } /* 恵比寿→渋谷 ★NEW★ */
              
              /* 中央線 横線 */
              .line11 { top: 337px; left: 90px; width: 60px; } /* 御茶ノ水→東京 */
              .line12 { top: 337px; left: 220px; width: 130px; } /* 東京→四ツ谷 */
              .line13 { top: 337px; left: 420px; width: 130px; } /* 四ツ谷→新宿 */
              .line14 { top: 337px; left: 620px; width: 130px; } /* 新宿→中野 */
              .line15 { top: 337px; left: 820px; width: 130px; } /* 中野→高円寺 ★NEW★ */
              
              /* 京浜東北線 縦線(右側) */
              .line16 { top: 120px; left: 497px; height: 80px; } /* 大宮→川口 */
              .line17 { top: 240px; left: 497px; height: 80px; } /* 川口→東京 */
              .line18 { top: 360px; left: 497px; height: 440px; } /* 東京→川崎 */
              .line19 { top: 840px; left: 497px; height: 80px; } /* 川崎→横浜 */
              
              /* 総武線 横線 */
              .line20 { top: 217px; left: 220px; width: 530px; } /* 秋葉原→船橋 */
              .line21 { top: 217px; left: 820px; width: 130px; } /* 船橋→千葉 */
              
              /* 丸ノ内線 縦線 */
              .line22 { top: 120px; left: 897px; height: 80px; } /* 池袋→新宿三丁目 */
              .line23 { top: 240px; left: 897px; height: 200px; } /* 新宿三丁目→銀座方面 */
              
              /* 丸ノ内線 横線(銀座まで) */
              .line24 { top: 457px; left: 397px; width: 500px; } /* 銀座→新宿三丁目 */
              
              /* 銀座線 横線 */
              .line25 { top: 97px; left: 290px; width: 60px; } /* 上野→浅草 */
              .line26 { top: 97px; left: 220px; width: 630px; } /* 上野→渋谷(拡張) ★NEW★ */
              .line27 { top: 1297px; left: 220px; width: 130px; } /* 渋谷→銀座方向 ★NEW★ */
              
              /* 東西線 横線 */
              .line28 { top: 457px; left: 290px; width: 360px; } /* 大手町→高田馬場 */
              .line29 { top: 457px; left: 720px; width: 130px; } /* 高田馬場→中野 */
              .line30 { top: 457px; left: 920px; width: 130px; } /* 中野→西船橋 */
              
              /* 副都心線 縦線 ★NEW★ */
              .line31 { top: 60px; left: 1097px; height: 80px; } /* 和光市→小竹向原 ★NEW★ */
              .line32 { top: 180px; left: 1097px; height: 80px; } /* 小竹向原→池袋 ★NEW★ */
              .line33 { top: 300px; left: 1097px; height: 80px; } /* 池袋→新宿 ★NEW★ */
              .line34 { top: 420px; left: 1097px; height: 860px; } /* 新宿→渋谷 ★NEW★ */
              
              /* 東急東横線 斜め線 ★NEW★ */
              .line35 {
                top: 1180px; /* 上から1180px */
                left: 520px; /* 左から520px */
                width: 530px; /* 幅530px */
                height: 8px; /* 高さ8px */
                transform: rotate(10deg); /* 10度回転(斜め) ★NEW★ */
                transform-origin: left center; /* 回転の基準点:左中央 */
              }
              .line36 {
                top: 1200px; /* 武蔵小杉→渋谷(副都心線) ★NEW★ */
                left: 620px; /* 左から620px */
                width: 430px; /* 幅430px */
                height: 8px; /* 高さ8px */
                transform: rotate(10deg); /* 10度回転 ★NEW★ */
                transform-origin: left center; /* 回転の基準点:左中央 */
              }
              
              /* 新幹線 斜め線 */
              .line37 {
                top: 360px; /* 上から360px */
                left: 220px; /* 左から220px */
                width: 380px; /* 幅380px */
                height: 8px; /* 高さ8px */
                transform: rotate(25deg); /* 25度回転(斜め) */
                transform-origin: left center; /* 回転の基準点:左中央 */
              }
              .line38 {
                top: 840px; /* 上から840px */
                left: 650px; /* 左から650px */
                width: 100px; /* 幅100px */
                height: 8px; /* 高さ8px */
                transform: rotate(35deg); /* 35度回転(斜め) */
                transform-origin: left center; /* 回転の基準点:左中央 */
              }
              
              /* ==========================================
                 凡例(路線の説明)エリア
              ========================================== */
              .legend {
                position: absolute; /* 絶対配置 */
                bottom: 40px; /* 下から40px */
                right: 40px; /* 右から40px */
                background: rgba(255,255,255,0.95); /* 半透明の白背景 */
                border-radius: 20px; /* 角を20px丸くする */
                padding: 25px; /* 内側に25pxの余白 */
                box-shadow: 0 15px 40px rgba(0,0,0,0.4), 0 0 20px rgba(255,255,255,0.2); /* 影と光の効果 */
                z-index: 50; /* 最前面に表示 */
                max-width: 300px; /* 最大幅300px */
              }
              
              /* 凡例のタイトル */
              .legend-title {
                font-size: 22px; /* 文字サイズ22px */
                font-weight: bold; /* 太字 */
                margin-bottom: 20px; /* 下に20pxの余白 */
                color: #222; /* 濃いグレー */
                text-align: center; /* 中央揃え */
                border-bottom: 3px solid #ddd; /* 下に3pxの線 */
                padding-bottom: 10px; /* 下に10pxのパディング */
              }
              
              /* 凡例の各項目 */
              .legend-item {
                display: flex; /* フレックスボックス */
                align-items: center; /* 垂直方向中央揃え */
                margin: 10px 0; /* 上下10pxの余白 */
                gap: 12px; /* 要素間の間隔12px */
              }
              
              /* 凡例の色サンプル(線) */
              .legend-color {
                width: 40px; /* 幅40px */
                height: 8px; /* 高さ8px */
                border-radius: 4px; /* 角を4px丸くする */
                box-shadow: 0 2px 5px rgba(0,0,0,0.2); /* 影を付ける */
              }
              
              /* 凡例のテキスト */
              .legend-text {
                font-size: 15px; /* 文字サイズ15px */
                color: #444; /* 濃いグレー */
                font-weight: 600; /* やや太字 */
              }
              
            </style>
            <!-- CSSスタイル定義終了 -->
            
            <!-- ============================================
                 HTMLコンテンツ(路線図本体)開始
            ============================================ -->
            <div class="route-map">
              <!-- ============================================
                   タイトル表示
              ============================================ -->
              <div class="map-title">🚃 東京鉄道路線図 - 拡張版(35駅)</div>
              
              <!-- ============================================
                   駅(Station)の配置 - すべての駅を絶対配置
              ============================================ -->
              
              <!-- ========== 山手線の駅群 ========== -->
              <div class="station yamanote pos-ueno">
                <div class="station-icon">🏛️</div> <!-- 上野駅のアイコン -->
                <div class="station-name">上野</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-akihabara">
                <div class="station-icon">🎮</div> <!-- 秋葉原駅のアイコン -->
                <div class="station-name">秋葉原</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-tokyo">
                <div class="station-icon">🏢</div> <!-- 東京駅のアイコン -->
                <div class="station-name">東京</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-yurakucho">
                <div class="station-icon">🎭</div> <!-- 有楽町駅のアイコン -->
                <div class="station-name">有楽町</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-shinbashi">
                <div class="station-icon">🏙️</div> <!-- 新橋駅のアイコン -->
                <div class="station-name">新橋</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-hamamatsucho">
                <div class="station-icon">🗼</div> <!-- 浜松町駅のアイコン -->
                <div class="station-name">浜松町</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-tamachi">
                <div class="station-icon">🏪</div> <!-- 田町駅のアイコン -->
                <div class="station-name">田町</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-shinagawa">
                <div class="station-icon">🚄</div> <!-- 品川駅のアイコン -->
                <div class="station-name">品川</div> <!-- 駅名 -->
              </div>
              
              <div class="station yamanote pos-meguro">
                <div class="station-icon">🌳</div> <!-- 目黒駅のアイコン ★NEW★ -->
                <div class="station-name">目黒</div> <!-- 駅名 ★NEW★ -->
              </div>
              
              <div class="station yamanote pos-ebisu">
                <div class="station-icon">🍺</div> <!-- 恵比寿駅のアイコン ★NEW★ -->
                <div class="station-name">恵比寿</div> <!-- 駅名 ★NEW★ -->
              </div>
              
              <div class="station yamanote pos-shibuya">
                <div class="station-icon">🎵</div> <!-- 渋谷駅のアイコン ★NEW★ -->
                <div class="station-name">渋谷</div> <!-- 駅名 ★NEW★ -->
              </div>
              
              <!-- ========== 中央線の駅群 ========== -->
              <div class="station chuo pos-ochanomizu">
                <div class="station-icon">📚</div> <!-- 御茶ノ水駅のアイコン -->
                <div class="station-name">御茶ノ水</div> <!-- 駅名 -->
              </div>
              
              <div class="station chuo pos-yotsuya">
                <div class="station-icon">🏯</div> <!-- 四ツ谷駅のアイコン -->
                <div class="station-name">四ツ谷</div> <!-- 駅名 -->
              </div>
              
              <div class="station chuo pos-shinjuku">
                <div class="station-icon">🌃</div> <!-- 新宿駅のアイコン -->
                <div class="station-name">新宿</div> <!-- 駅名 -->
              </div>
              
              <div class="station chuo pos-nakano">
                <div class="station-icon">🎪</div> <!-- 中野駅のアイコン -->
                <div class="station-name">中野</div> <!-- 駅名 -->
              </div>
              
              <div class="station chuo pos-koenji">
                <div class="station-icon">🎸</div> <!-- 高円寺駅のアイコン ★NEW★ -->
                <div class="station-name">高円寺</div> <!-- 駅名 ★NEW★ -->
              </div>
              
              <!-- ========== 京浜東北線の駅群 ========== -->
              <div class="station keihin pos-omiya">
                <div class="station-icon">⚽</div> <!-- 大宮駅のアイコン -->
                <div class="station-name">大宮</div> <!-- 駅名 -->
              </div>
              
              <div class="station keihin pos-kawaguchi">
                <div class="station-icon">🏭</div> <!-- 川口駅のアイコン -->
                <div class="station-name">川口</div> <!-- 駅名 -->
              </div>
              
              <div class="station keihin pos-kawasaki">
                <div class="station-icon">🏭</div> <!-- 川崎駅のアイコン -->
                <div class="station-name">川崎</div> <!-- 駅名 -->
              </div>
              
              <div class="station keihin pos-yokohama">
                <div class="station-icon">⛵</div> <!-- 横浜駅のアイコン -->
                <div class="station-name">横浜</div> <!-- 駅名 -->
              </div>
              
              <!-- ========== 総武線の駅群 ========== -->
              <div class="station sobu pos-funabashi">
                <div class="station-icon">⚓</div> <!-- 船橋駅のアイコン -->
                <div class="station-name">船橋</div> <!-- 駅名 -->
              </div>
              
              <div class="station sobu pos-chiba">
                <div class="station-icon">🥜</div> <!-- 千葉駅のアイコン -->
                <div class="station-name">千葉</div> <!-- 駅名 -->
              </div>
              
              <!-- ========== 丸ノ内線の駅群 ========== -->
              <div class="station marunouchi pos-ikebukuro">
                <div class="station-icon">🦉</div> <!-- 池袋駅のアイコン -->
                <div class="station-name">池袋</div> <!-- 駅名 -->
              </div>
              
              <div class="station marunouchi pos-shinjuku3">
                <div class="station-icon">🛍️</div> <!-- 新宿三丁目駅のアイコン -->
                <div class="station-name">新宿三丁目</div> <!-- 駅名 -->
              </div>
              
              <div class="station marunouchi pos-ginza">
                <div class="station-icon">💎</div> <!-- 銀座駅のアイコン -->
                <div class="station-name">銀座</div> <!-- 駅名 -->
              </div>
              
              <!-- ========== 銀座線の駅群 ========== -->
              <div class="station ginza pos-asakusa">
                <div class="station-icon">🏮</div> <!-- 浅草駅のアイコン -->
                <div class="station-name">浅草</div> <!-- 駅名 -->
              </div>
              
              <div class="station ginza pos-ueno-ginza">
                <div class="station-icon">🎨</div> <!-- 上野駅(銀座線)のアイコン -->
                <div class="station-name">上野</div> <!-- 駅名 -->
              </div>
              
              <div class="station ginza pos-shibuya-ginza">
                <div class="station-icon">🎤</div> <!-- 渋谷駅(銀座線)のアイコン ★NEW★ -->
                <div class="station-name">渋谷</div> <!-- 駅名 ★NEW★ -->
              </div>
              
              <!-- ========== 東西線の駅群 ========== -->
              <div class="station tozai pos-otemachi">
                <div class="station-icon">🏦</div> <!-- 大手町駅のアイコン -->
                <div class="station-name">大手町</div> <!-- 駅名 -->
              </div>
              
              <div class="station tozai pos-takadanobaba">
                <div class="station-icon">🎓</div> <!-- 高田馬場駅のアイコン -->
                <div class="station-name">高田馬場</div> <!-- 駅名 -->
              </div>
              
              <div class="station tozai pos-nakano-tozai">
                <div class="station-icon">🎬</div> <!-- 中野駅(東西線)のアイコン -->
                <div class="station-name">中野</div> <!-- 駅名 -->
              </div>
              
              <div class="station tozai pos-nishifunabashi">
                <div class="station-icon">🚢</div> <!-- 西船橋駅のアイコン -->
                <div class="station-name">西船橋</div> <!-- 駅名 -->
              </div>
              
              <!-- ========== 副都心線の駅群 ★NEW★ ========== -->
              <div class="station fukutoshin pos-wakoshi">
                <div class="station-icon">🏘️</div> <!-- 和光市駅のアイコン ★NEW★ -->
                <div class="station-name">和光市</div> <!-- 駅名 ★NEW★ -->
              </div>
              
              <div class="station fukutoshin pos-kotake">
                <div class="station-icon">🌸</div> <!-- 小竹向原駅のアイコン ★NEW★ -->
                <div class="station-name">小竹向原</div> <!-- 駅名 ★NEW★ -->
              </div>
              
              <div class="station fukutoshin pos-ikebukuro-fuku">
                <div class="station-icon">🎯</div> <!-- 池袋駅(副都心線)のアイコン ★NEW★ -->
                <div class="station-name">池袋</div> <!-- 駅名 ★NEW★ -->
              </div>
              
              <div class="station fukutoshin pos-shinjuku-fuku">
                <div class="station-icon">🏙️</div> <!-- 新宿駅(副都心線)のアイコン ★NEW★ -->
                <div class="station-name">新宿</div> <!-- 駅名 ★NEW★ -->
              </div>
              
              <div class="station fukutoshin pos-shibuya-fuku">
                <div class="station-icon">🎨</div> <!-- 渋谷駅(副都心線)のアイコン ★NEW★ -->
                <div class="station-name">渋谷</div> <!-- 駅名 ★NEW★ -->
              </div>
              
              <!-- ========== 東急東横線の駅群 ★NEW★ ========== -->
              <div class="station toyoko pos-yokohama-toyoko">
                <div class="station-icon">🎡</div> <!-- 横浜駅(東横線)のアイコン ★NEW★ -->
                <div class="station-name">横浜</div> <!-- 駅名 ★NEW★ -->
              </div>
              
              <div class="station toyoko pos-musashikosugi">
                <div class="station-icon">🏗️</div> <!-- 武蔵小杉駅のアイコン ★NEW★ -->
                <div class="station-name">武蔵小杉</div> <!-- 駅名 ★NEW★ -->
              </div>
              
              <!-- ========== 新幹線の駅群 ========== -->
              <div class="station shinkansen pos-nagoya">
                <div class="station-icon">🏯</div> <!-- 名古屋駅のアイコン -->
                <div class="station-name">名古屋</div> <!-- 駅名 -->
              </div>
              
              <div class="station shinkansen pos-kyoto">
                <div class="station-icon">⛩️</div> <!-- 京都駅のアイコン -->
                <div class="station-name">京都</div> <!-- 駅名 -->
              </div>
              
              <!-- ============================================
                   路線(Line)の配置 - 各駅を結ぶ線
              ============================================ -->
              
              <!-- ========== 山手線の縦線群(左側ライン) ========== -->
              <div class="line line-vertical line-yamanote line1"/> <!-- 上野→秋葉原 -->
              <div class="line line-vertical line-yamanote line2"/> <!-- 秋葉原→東京 -->
              <div class="line line-vertical line-yamanote line3"/> <!-- 東京→有楽町 -->
              <div class="line line-vertical line-yamanote line4"/> <!-- 有楽町→新橋 -->
              <div class="line line-vertical line-yamanote line5"/> <!-- 新橋→浜松町 -->
              <div class="line line-vertical line-yamanote line6"/> <!-- 浜松町→田町 -->
              <div class="line line-vertical line-yamanote line7"/> <!-- 田町→品川 -->
              <div class="line line-vertical line-yamanote line8"/> <!-- 品川→目黒 ★NEW★ -->
              <div class="line line-vertical line-yamanote line9"/> <!-- 目黒→恵比寿 ★NEW★ -->
              <div class="line line-vertical line-yamanote line10"/> <!-- 恵比寿→渋谷 ★NEW★ -->
              
              <!-- ========== 中央線の横線群 ========== -->
              <div class="line line-horizontal line-chuo line11"/> <!-- 御茶ノ水→東京 -->
              <div class="line line-horizontal line-chuo line12"/> <!-- 東京→四ツ谷 -->
              <div class="line line-horizontal line-chuo line13"/> <!-- 四ツ谷→新宿 -->
              <div class="line line-horizontal line-chuo line14"/> <!-- 新宿→中野 -->
              <div class="line line-horizontal line-chuo line15"/> <!-- 中野→高円寺 ★NEW★ -->
              
              <!-- ========== 京浜東北線の縦線群(右側ライン) ========== -->
              <div class="line line-vertical line-keihin line16"/> <!-- 大宮→川口 -->
              <div class="line line-vertical line-keihin line17"/> <!-- 川口→東京 -->
              <div class="line line-vertical line-keihin line18"/> <!-- 東京→川崎 -->
              <div class="line line-vertical line-keihin line19"/> <!-- 川崎→横浜 -->
              
              <!-- ========== 総武線の横線群 ========== -->
              <div class="line line-horizontal line-sobu line20"/> <!-- 秋葉原→船橋 -->
              <div class="line line-horizontal line-sobu line21"/> <!-- 船橋→千葉 -->
              
              <!-- ========== 丸ノ内線の線群 ========== -->
              <div class="line line-vertical line-marunouchi line22"/> <!-- 池袋→新宿三丁目 -->
              <div class="line line-vertical line-marunouchi line23"/> <!-- 新宿三丁目→銀座方面 -->
              <div class="line line-horizontal line-marunouchi line24"/> <!-- 銀座→新宿三丁目 -->
              
              <!-- ========== 銀座線の横線群 ========== -->
              <div class="line line-horizontal line-ginza line25"/> <!-- 上野→浅草 -->
              <div class="line line-horizontal line-ginza line26"/> <!-- 上野→渋谷(拡張) ★NEW★ -->
              <div class="line line-horizontal line-ginza line27"/> <!-- 渋谷→銀座方向 ★NEW★ -->
              
              <!-- ========== 東西線の横線群 ========== -->
              <div class="line line-horizontal line-tozai line28"/> <!-- 大手町→高田馬場 -->
              <div class="line line-horizontal line-tozai line29"/> <!-- 高田馬場→中野 -->
              <div class="line line-horizontal line-tozai line30"/> <!-- 中野→西船橋 -->
              
              <!-- ========== 副都心線の縦線群 ★NEW★ ========== -->
              <div class="line line-vertical line-fukutoshin line31"/> <!-- 和光市→小竹向原 ★NEW★ -->
              <div class="line line-vertical line-fukutoshin line32"/> <!-- 小竹向原→池袋 ★NEW★ -->
              <div class="line line-vertical line-fukutoshin line33"/> <!-- 池袋→新宿 ★NEW★ -->
              <div class="line line-vertical line-fukutoshin line34"/> <!-- 新宿→渋谷 ★NEW★ -->
              
              <!-- ========== 東急東横線の斜め線群 ★NEW★ ========== -->
              <div class="line line-horizontal line-toyoko line35"/> <!-- 横浜→武蔵小杉(斜め) ★NEW★ -->
              <div class="line line-horizontal line-toyoko line36"/> <!-- 武蔵小杉→渋谷(斜め) ★NEW★ -->
              
              <!-- ========== 新幹線の斜め線群 ========== -->
              <div class="line line-horizontal line-shinkansen line37"/> <!-- 東京→名古屋(斜め) -->
              <div class="line line-horizontal line-shinkansen line38"/> <!-- 名古屋→京都(斜め) -->
              
              <!-- ============================================
                   凡例(Legend)エリア - 画面右下に路線の説明
              ============================================ -->
              <div class="legend">
                <!-- 凡例のタイトル -->
                <div class="legend-title">🚃 路線凡例</div>
                
                <!-- JR山手線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #9ACD32 0%, #7FB800 100%);"/>
                  <div class="legend-text">JR山手線</div>
                </div>
                
                <!-- JR中央線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #FF6F00 0%, #E65100 100%);"/>
                  <div class="legend-text">JR中央線</div>
                </div>
                
                <!-- JR京浜東北線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #00BFFF 0%, #0099CC 100%);"/>
                  <div class="legend-text">JR京浜東北線</div>
                </div>
                
                <!-- JR総武線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #FFD700 0%, #FFC700 100%);"/>
                  <div class="legend-text">JR総武線</div>
                </div>
                
                <!-- 東京メトロ丸ノ内線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #DC143C 0%, #B71C1C 100%);"/>
                  <div class="legend-text">メトロ丸ノ内線</div>
                </div>
                
                <!-- 東京メトロ銀座線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #FF9500 0%, #FF8C00 100%);"/>
                  <div class="legend-text">メトロ銀座線</div>
                </div>
                
                <!-- 東京メトロ東西線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #009BBF 0%, #00838F 100%);"/>
                  <div class="legend-text">メトロ東西線</div>
                </div>
                
                <!-- 東京メトロ副都心線 ★NEW★ -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #9C5E31 0%, #8B4513 100%);"/>
                  <div class="legend-text">メトロ副都心線</div>
                </div>
                
                <!-- 東急東横線 ★NEW★ -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #E6004C 0%, #D10045 100%);"/>
                  <div class="legend-text">東急東横線</div>
                </div>
                
                <!-- 新幹線 -->
                <div class="legend-item">
                  <div class="legend-color" style="background: linear-gradient(90deg, #1E90FF 0%, #1976D2 100%);"/>
                  <div class="legend-text">新幹線</div>
                </div>
              </div>
              <!-- 凡例エリア終了 -->
              
            </div>
            <!-- 路線図本体終了 -->
            
          </html>
        </panel>
      </row>
    </dashboard><!-- ダッシュボード終了 -->

    完成しました!🎉

    拡張版路線図の追加内容:

    新規追加駅(11駅)

    山手線:

    • 🌳 目黒駅

    • 🍺 恵比寿駅

    • 🎵 渋谷駅

    中央線:

    • 🎸 高円寺駅

    銀座線:

    • 🎤 渋谷駅(銀座線)

    副都心線(完全新規路線):

    • 🏘️ 和光市駅

    • 🌸 小竹向原駅

    • 🎯 池袋駅(副都心線)

    • 🏙️ 新宿駅(副都心線)

    • 🎨 渋谷駅(副都心線)

    東急東横線(完全新規路線):

    • 🎡 横浜駅(東横線)

    • 🏗️ 武蔵小杉駅

    合計

    • 35駅(元28駅 + 7駅)

    • 10路線(元8路線 + 2路線)

    • 38本の路線(元28本 + 10本)

    このコードをSplunkダッシュボードにコピー&ペーストすれば、さらに豪華な路線図が表示されます!


    【新人エンジニア向け】Splunk路線図を自分でカスタマイズする完全ガイド 🚃✨

    はじめに

    この記事では、Splunkダッシュボードで作成した路線図に自分で駅や路線を追加する方法を、新人エンジニア向けに図解付きで徹底解説します!

    「コードが長くて難しそう...」と思うかもしれませんが、実は4つのステップを理解すれば誰でも追加できます。

    この記事で学べること

    • ✅ 駅を追加する手順(座標の計算方法)

    • ✅ 路線(線)を追加する手順

    • ✅ 新しい路線カラーを定義する方法

    • ✅ 実際の追加例(池袋→大塚駅を追加)


    📚 目次

    1. 路線図の構造を理解する

    2. 駅を追加する4ステップ

    3. 路線(線)を追加する3ステップ

    4. 新しい路線を追加する方法

    5. 実践:池袋→大塚駅を追加してみよう

    6. トラブルシューティング


    路線図の構造を理解する

    まず、Splunk路線図がどのような構造になっているか理解しましょう。

    構造の全体像

    路線図 = 駅(四角) + 路線(線) + 凡例
    
    ┌─────────────────────────────────────────┐
    │  路線図コンテナ (.route-map)              │
    │                                         │
    │  ┌───┐    ━━━━━━    ┌───┐             │
    │  │駅A│ ←  路線線  → │駅B│             │
    │  └───┘              └───┘             │
    │                                         │
    │                      ┌──────────┐      │
    │                      │   凡例    │      │
    │                      └──────────┘      │
    └─────────────────────────────────────────┘
    

    コードの3つの主要部分

    部分 役割 記述場所 CSS 見た目を定義(色、サイズ、位置) <style> タグ内 HTML(駅) 駅の配置 <div class="station"> HTML(線) 路線の配置 <div class="line">


    駅を追加する4ステップ

    📍 Step 1: 座標を決める

    駅は絶対座標で配置されます。既存の駅を参考に座標を計算しましょう。

    座標の考え方

            X軸(横方向)
            ←────────────→
        0   150   350   550   750
        │    │     │     │     │
    ┌───┼────┼─────┼─────┼─────┼───
    │   │ 上野│     │     │     │
    │ Y │(150,│     │     │     │
    │ 軸│ 80) │     │     │     │
    │(縦│    │     │     │     │
    │方 ├────┼─────┼─────┼─────┼───
    │向)│秋葉原    │     │     │
    │   │(150,│     │     │     │
    │↓ │200) │     │     │     │
    

    計算例:上野の次の駅を追加する

    既存の駅:
    - 上野駅: top: 80px, left: 150px
    - 秋葉原駅: top: 200px, left: 150px
    
    間隔 = 200 - 80 = 120px
    
    新駅「御徒町」を上野と秋葉原の間に追加
    → top: 80 + 60 = 140px, left: 150px
    

    🎨 Step 2: CSSで座標を定義

    /* 御徒町駅の座標を定義 */
    .pos-okachimachi { 
      top: 140px;   /* 上から140px */
      left: 150px;  /* 左から150px */
    }
    

    CSSクラス命名規則

    .pos-[駅名のローマ字]
    

    例:

    • 渋谷 → .pos-shibuya

    • 新宿 → .pos-shinjuku

    • 池袋 → .pos-ikebukuro

    🏗️ Step 3: HTMLで駅要素を追加

    <!-- 御徒町駅を追加 -->
    <div class="station yamanote pos-okachimachi">
      <div class="station-icon">🛒</div>
      <div class="station-name">御徒町</div>
    </div>
    

    HTMLタグの構造解説

    <div class="station yamanote pos-okachimachi">
         ────────── ────────── ─────────────────
             ↓          ↓              ↓
        基本スタイル  路線カラー   座標クラス
        
      <div class="station-icon">🛒</div>
           ────────────────────  ─
                  ↓              ↓
             アイコンエリア    絵文字
      
      <div class="station-name">御徒町</div>
           ────────────────────  ──────
                  ↓              ↓
             駅名エリア       駅名テキスト
    </div>
    

    ✅ Step 4: 動作確認

    1. SplunkダッシュボードのXMLエディタに貼り付け

    2. 保存

    3. ダッシュボードを開いて表示確認


    路線(線)を追加する3ステップ

    📏 Step 1: 線の位置を計算する

    駅と駅を結ぶ線の座標を計算します。

    縦線の計算方法

    駅A ──┐
          │← この線の位置を計算
    駅B ──┘
    
    計算式:
    線の左位置 = 駅の左位置 + (駅の幅 / 2) - (線の幅 / 2)
    線の上位置 = 駅Aの下端
    線の高さ = 駅Bの上端 - 駅Aの下端
    

    具体例:上野→御徒町の線

    上野駅: top: 80px, left: 150px, 高さ: 40px, 幅: 110px
    御徒町駅: top: 140px
    
    計算:
    線の左位置 = 150 + (110 / 2) - (8 / 2) = 197px
    線の上位置 = 80 + 40 = 120px
    線の高さ = 140 - 120 = 20px
    

    🎨 Step 2: CSSで線の座標を定義

    /* 上野→御徒町の線 */
    .line-ueno-okachimachi {
      top: 120px;      /* 上から120px */
      left: 197px;     /* 左から197px */
      height: 20px;    /* 高さ20px */
    }
    

    🏗️ Step 3: HTMLで線要素を追加

    <!-- 上野→御徒町の縦線 -->
    <div class="line line-vertical line-yamanote line-ueno-okachimachi"></div>
         ────  ────────────  ─────────────  ──────────────────────────
           ↓        ↓              ↓                    ↓
       基本     縦/横の指定    路線カラー           座標クラス
    

    クラスの意味

    クラス 役割 例 line 線の基本スタイル 必須 line-vertical 縦線 縦の場合 line-horizontal 横線 横の場合 line-yamanote 路線カラー 山手線の緑色 line-ueno-okachimachi 座標 個別の位置


    新しい路線を追加する方法

    例:都営大江戸線を追加する

    Step 1: 路線カラーを定義(CSS)

    /* ==========================================
       都営大江戸線(マゼンタ)のスタイル定義
    ========================================== */
    .oedo {
      border-color: #E4007F; /* 枠線の色:マゼンタ */
      background: linear-gradient(135deg, #E4007F 0%, #ffffff 100%);
    }
    
    .line-oedo {
      background: linear-gradient(90deg, #E4007F 0%, #D1006F 100%);
    }
    

    Step 2: 駅を追加(HTML)

    <!-- 都庁前駅 -->
    <div class="station oedo pos-tocho">
      <div class="station-icon">🏛️</div>
      <div class="station-name">都庁前</div>
    </div>
    

    Step 3: 凡例に追加

    <!-- 凡例に都営大江戸線を追加 -->
    <div class="legend-item">
      <div class="legend-color" style="background: linear-gradient(90deg, #E4007F 0%, #D1006F 100%);"></div>
      <div class="legend-text">都営大江戸線</div>
    </div>
    

    実践:池袋→大塚駅を追加してみよう

    実際に手を動かして、池袋駅の次に大塚駅を追加してみましょう!

    📋 現在の状況

    既存:
    池袋駅 (top: 80px, left: 850px) ← 丸ノ内線
    

    🎯 目標

    池袋駅
      ↓ ← 新しい線
    大塚駅 ← 新規追加
    

    Step 1: 座標を決める

    大塚駅の位置:
    - 池袋の下に配置
    - 間隔: 120px
    - 計算: top: 80 + 120 = 200px, left: 850px
    

    Step 2: CSSに座標を追加

    どこに書くか: .pos-ikebukuro の近くに追加

    /* 丸ノ内線エリア(右上縦ライン) */
    .pos-ikebukuro { top: 80px; left: 850px; }   /* 池袋駅 */
    .pos-otsuka { top: 200px; left: 850px; }      /* 大塚駅 ← 追加 */
    .pos-shinjuku3 { top: 200px; left: 850px; }  /* 新宿三丁目駅 */
    

    Step 3: HTMLに駅を追加

    どこに書くか: <!-- ========== 丸ノ内線の駅群 ========== --> の中

    <!-- ========== 丸ノ内線の駅群 ========== -->
    <div class="station marunouchi pos-ikebukuro">
      <div class="station-icon">🦉</div>
      <div class="station-name">池袋</div>
    </div>
    
    <!-- 大塚駅を追加 ★NEW★ -->
    <div class="station marunouchi pos-otsuka">
      <div class="station-icon">🌸</div>
      <div class="station-name">大塚</div>
    </div>
    
    <div class="station marunouchi pos-shinjuku3">
      <div class="station-icon">🛍️</div>
      <div class="station-name">新宿三丁目</div>
    </div>
    

    Step 4: 線を追加

    4-1. 線の座標を計算

    池袋→大塚の線:
    - 左位置: 850 + (110 / 2) - (8 / 2) = 897px
    - 上位置: 80 + 40 = 120px
    - 高さ: 200 - 120 = 80px
    

    4-2. CSSに線の座標を追加

    /* 丸ノ内線 縦線 */
    .line22 { top: 120px; left: 897px; height: 80px; } /* 池袋→大塚 ★NEW★ */
    .line23 { top: 240px; left: 897px; height: 200px; } /* 大塚→新宿三丁目 */
    

    4-3. HTMLに線を追加

    <!-- ========== 丸ノ内線の線群 ========== -->
    <div class="line line-vertical line-marunouchi line22"></div> <!-- 池袋→大塚 ★NEW★ -->
    <div class="line line-vertical line-marunouchi line23"></div> <!-- 大塚→新宿三丁目 -->
    

    ✅ 完成図

    🦉 池袋駅
     ║ ← 線(line22)
     ║
    🌸 大塚駅
     ║ ← 線(line23)
     ║
    🛍️ 新宿三丁目駅
    

    座標計算チートシート

    縦線(駅を縦に並べる)

    駅の間隔: 120px が標準
    
    例:
    駅A: top: 100px
    駅B: top: 220px (100 + 120)
    駅C: top: 340px (220 + 120)
    
    線の計算:
    線の左位置 = 駅の左位置 + 47px (110/2 - 8/2)
    線の上位置 = 駅の top + 40px (駅の高さ)
    線の高さ = 80px (次の駅までの間隔 - 駅の高さ)
    

    横線(駅を横に並べる)

    駅の間隔: 200px が標準
    
    例:
    駅A: left: 150px
    駅B: left: 350px (150 + 200)
    駅C: left: 550px (350 + 200)
    
    線の計算:
    線の上位置 = 駅の top + 17px (40/2 - 8/2)
    線の左位置 = 駅の left + 110px (駅の幅)
    線の幅 = 次の駅の left - この駅の left - 110px
    

    トラブルシューティング

    ❌ 駅が表示されない

    原因1: CSSの座標クラスが定義されていない

    /* NG: この定義がない */
    .pos-otsuka { top: 200px; left: 850px; }
    

    解決策: CSSに座標を追加する


    原因2: HTMLのクラス名が間違っている

    <!-- NG: クラス名のスペルミス -->
    <div class="station marunouchi pos-ootsuka">
    
    <!-- OK: 正しいスペル -->
    <div class="station marunouchi pos-otsuka">
    

    解決策: CSSとHTMLのクラス名を一致させる


    ❌ 線がずれている

    原因: 線の座標計算が間違っている

    /* NG: 計算ミス */
    .line-new { top: 100px; left: 800px; }
    
    /* OK: 正しい計算 */
    .line-new { top: 120px; left: 897px; }
    

    解決策: 上記の計算式を使って再計算


    ❌ 線の色が付かない

    原因: 路線カラーのクラスが抜けている

    <!-- NG: line-yamanote がない -->
    <div class="line line-vertical line22"></div>
    
    <!-- OK: 路線カラーを追加 -->
    <div class="line line-vertical line-yamanote line22"></div>
    

    まとめ

    駅追加の3ステップ

    1. ✅ CSS: 座標を定義 .pos-xxx

    2. ✅ HTML: 駅要素を追加 <div class="station">

    3. ✅ HTML: 線要素を追加 <div class="line">

    重要なポイント

    ポイント 説明 🎯 座標は既存駅を基準に 間隔を一定に保つと綺麗 📏 線の幅は8px固定 計算式に使う 🎨 路線カラーは必須 line-yamanote など 📝 クラス名は統一 CSS と HTML で一致させる

    次のステップ

    • 🔄 他の駅も追加してみる

    • 🎨 オリジナルの路線を作る

    • 📊 SPLでデータ連動させる(次回記事で解説予定)


    参考資料

    絵文字一覧

    駅のアイコンに使える絵文字:

    🏛️ 上野(美術館)    🎮 秋葉原(ゲーム)
    🏢 東京(オフィス)   🎭 有楽町(劇場)
    🏙️ 新橋(ビル街)    🗼 浜松町(東京タワー)
    🚄 品川(新幹線)    🌳 目黒(公園)
    🍺 恵比寿(ビール)   🎵 渋谷(音楽)
    📚 御茶ノ水(大学)   🏯 四ツ谷(お城)
    🌃 新宿(夜景)      🎪 中野(サーカス)
    

    路線カラーコード

    山手線: #9ACD32 (黄緑)
    中央線: #FF6F00 (オレンジ)
    京浜東北線: #00BFFF (水色)
    総武線: #FFD700 (金色)
    丸ノ内線: #DC143C (赤)
    銀座線: #FF9500 (オレンジ)
    東西線: #009BBF (青緑)
    副都心線: #9C5E31 (茶色)
    東横線: #E6004C (ピンク)
    

    #Splunk #初心者向け #可視化 #HTML #CSS #ダッシュボード #路線図 #新人エンジニア

    あなたへのおすすめ