ColdFusion での散布図の作成

散布図は、2 つの変数間の関係を表示するグラフです。散布図は、2D グラフ上の個々のデータポイントを表し、1 つの変数が x 軸(横軸)にプロットされ、別の変数が y 軸(縦軸)にプロットされます。

散布図には通常、次のものが含まれます。

  • X 軸:1 つの変数(独立変数)を表します。
  • Y 軸:別の変数(従属変数)を表します。
  • 散布図上の各データポイントは、x 軸に沿った値と y 軸に沿った値のペアに対応し、これらの交点でポイントを形成します。

cfchart タグを使用して散布図を作成できます。次に例を示します。

<cfchart format=&quot;html&quot; type=&quot;scatter&quot; showMarkers =&quot;true&quot; 
showLegend=&quot;FALSE&quot; width=&quot;600&quot; height=&quot;400&quot; title=&quot;散布図&quot;>
     <cfchartseries>
        <cfchartdata item = &quot;2015&quot; value = 20 >
        <cfchartdata item = &quot;2016&quot; value = 27 >
        <cfchartdata item = &quot;2017&quot; value = 19 >
        <cfchartdata item = &quot;2018&quot; value = 80 >
        <cfchartdata item = &quot;2019&quot; value = 56 >
        <cfchartdata item = &quot;2020&quot; value = 39 >
        <cfchartdata item = &quot;2021&quot; value = 91 >
        <cfchartdata item = &quot;2022&quot; value = 71 >
        <cfchartdata item = &quot;2023&quot; value = 28 >
    </cfchartseries>
</cfchart>

出力

次のスクリプトは、データベースのテーブルを使用して散布図を表示します。

<cfquery name=&quot;getEmployeeData&quot; datasource=&quot;cfdocexamples&quot;>
    SELECT emp_id, Salary
    FROM employee
    WHERE EMP_ID < 1955
</cfquery>
<cfchart format=&quot;html&quot; chartheight=&quot;400&quot; chartwidth=&quot;600&quot; title=&quot;従業員 ID と給与の散布図&quot; showLegend=&quot;FALSE&quot;>
    <cfchartseries type=&quot;scatter&quot; query=&quot;getEmployeeData&quot; itemColumn=&quot;Emp_ID&quot; valueColumn=&quot;Salary&quot;/>
</cfchart>

出力

ヘルプをすばやく簡単に入手

新規ユーザーの場合