jQuery の jqPlot プラグインで作る半透明の面グラフ

jQueryのjqPlotプラグインで作る面グラフにおいて、面を半透明にする方法。

  • seriesDefaultsオプションのshowMarkerプロパティに「false」を指定し、マーカーを非表示にする。
  • seriesDefaultsオプションのfillプロパティに「true」を指定し、折れ線グラフの系列の線の下を塗りつぶす。
  • seriesDefaultsオプションのfillAlphaプロパティに「0.7」を指定し、折れ線グラフの系列の線の下の色を半透明にする。
  • axesオプションのxaxisのpadプロパティに「0」を指定し、x軸の余白をなくす。

実装例(サンプル)

実装例(サンプル)の動作について

各系列にカーソルを合わせると、前面に現れる。

実装例(サンプル)のソースコード

読み込み

パスは、それぞれ、アップロードした場所を指定する。

<script language="javascript" type="text/javascript" src="jquery-1.7.1.min.js"></script>
<!--[if lt IE 9]>
    <script language="javascript" type="text/javascript" src="excanvas.min.js"></script>
<![endif]-->
<script language="javascript" type="text/javascript" src="jquery.jqplot.min.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.jqplot.min.css" />

読み込むファイル。

JavaScript

<script>
jQuery( function() {
    Tarou = [ [ 1, 65 ], [ 2, 72 ], [ 3, 74 ], [ 4, 63 ], [ 5, 85 ], [ 6, 90 ] ];
    Hanako = [ [ 1, 83 ], [ 2, 81 ], [ 3, 79 ], [ 4, 88 ], [ 5, 78 ], [ 6, 96 ] ];
    Ichirou = [ [ 1, 81 ], [ 2, 86 ], [ 3, 71 ], [ 4, 69 ], [ 5, 58 ], [ 6, 82 ] ];
    jQuery . jqplot(
        'jqPlot-sample',
        [
            Hanako, Tarou, Ichirou
        ],
        {
            axes: {
                xaxis: {
                    pad: 0
                }
            },
            seriesDefaults: {
                showMarker: false,
                fill: true,
                fillAlpha: 0.7,
            },
        }
    );
} );
</script>

HTML

<div id="jqPlot-sample" style="height: 300px; width: 300px;"></div>

スポンサード リンク

カテゴリー: JavaScript, jqPlot, jQuery, グラフ、チャート, プラグイン, 面グラフ パーマリンク