ヒストグラム

ヒストグラムは、データの頻度を表します。このグラフでは、分析対象のデータと、データ頻度の間隔を表すビン数という、2種類のデータを使用します。
 ABCDE
1点数リスト    
20    
325    
425    
545    
645    
745    
860    
960    
1075    
1175    
1275    
1388    
14100    
   

ソースコード

別ウィンドウで表示
using FarPoint.Web.Chart;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class chart_histogram : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            return;
        }

        // SPREADの設定
        InitSpread(FpSpread1);

        // シート設定
        InitSpreadStyles(FpSpread1.Sheets[0]);
    }

    private void InitSpread(FarPoint.Web.Spread.FpSpread spread)
    {
        spread.CssClass = "spreadStyle2";
        spread.UseClipboard = false;
    }

    private void InitSpreadStyles(FarPoint.Web.Spread.SheetView sheet)
    {
        // 行列の設定
        sheet.RowCount = 14;
        sheet.ColumnCount = 5;
        sheet.PageSize = 25;
        sheet.DefaultColumnWidth = 100;
        sheet.DefaultRowHeight = 26;

        sheet.Columns[0].Width = 232;

        // シートのフォントサイズの設定
        sheet.DefaultStyle.Font.Size = FontUnit.Parse("90%");
        sheet.ColumnHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%");
        sheet.RowHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%");
        sheet.SheetCorner.DefaultStyle.Font.Size = FontUnit.Parse("80%");

        // グリッド線の設定
        sheet.GridLines = GridLines.None;

        // 罫線の設定
        for (int i = 0; i < 14; i++)
        {
            sheet.Cells[i, 0].Border = new FarPoint.Web.Spread.Border(BorderStyle.Solid, Color.LightGray, 1);
            sheet.Cells[i, 0].HorizontalAlign = HorizontalAlign.Center;
            sheet.Cells[i, 0].VerticalAlign = VerticalAlign.Middle;
        }

        // テストデータの設定
        sheet.SetClipValue(0, 0, 1, 1, "点数リスト");
        sheet.SetClipValue(1, 0, 1, 1, "0");
        sheet.SetClipValue(2, 0, 1, 1, "25");
        sheet.SetClipValue(3, 0, 1, 1, "25");
        sheet.SetClipValue(4, 0, 1, 1, "45");
        sheet.SetClipValue(5, 0, 1, 1, "45");
        sheet.SetClipValue(6, 0, 1, 1, "45");
        sheet.SetClipValue(7, 0, 1, 1, "60");
        sheet.SetClipValue(8, 0, 1, 1, "60");
        sheet.SetClipValue(9, 0, 1, 1, "75");
        sheet.SetClipValue(10, 0, 1, 1, "75");
        sheet.SetClipValue(11, 0, 1, 1, "75");
        sheet.SetClipValue(12, 0, 1, 1, "88");
        sheet.SetClipValue(13, 0, 1, 1, "100");

        // SPREADへチャートを追加
        FpSpread1.Sheets[0].AddChart(new FarPoint.Web.Spread.Model.CellRange(1, 0, 13, 1), typeof(FarPoint.Web.Chart.HistogramSeries), 388, 300, 242, 46);

        FarPoint.Web.Chart.HistogramSeries hseries = (FarPoint.Web.Chart.HistogramSeries)FpSpread1.Sheets[0].Charts[0].Model.PlotAreas[0].Series[0];
        hseries.BinOption.BinSize = 20;
        hseries.BinOption.AutoOverFlow = true;
        hseries.BinOption.AutoUnderFlow = true;

        // 凡例非表示
        FpSpread1.Sheets[0].Charts[0].Model.LegendAreas.Clear();
    }
}
Imports FarPoint.Web.Chart
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Partial Public Class chart_histogram
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(sender As Object, e As EventArgs)
        If IsPostBack Then
            Return
        End If

        ' SPREADの設定
        InitSpread(FpSpread1)

        ' シート設定
        InitSpreadStyles(FpSpread1.Sheets(0))
    End Sub

    Private Sub InitSpread(spread As FarPoint.Web.Spread.FpSpread)
        spread.CssClass = "spreadStyle2"
        spread.UseClipboard = False
    End Sub

    Private Sub InitSpreadStyles(sheet As FarPoint.Web.Spread.SheetView)
        ' 行列の設定
        sheet.RowCount = 14
        sheet.ColumnCount = 5
        sheet.PageSize = 25
        sheet.DefaultColumnWidth = 100
        sheet.DefaultRowHeight = 26

        sheet.Columns(0).Width = 232

        ' シートのフォントサイズの設定
        sheet.DefaultStyle.Font.Size = FontUnit.Parse("90%")
        sheet.ColumnHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%")
        sheet.RowHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%")
        sheet.SheetCorner.DefaultStyle.Font.Size = FontUnit.Parse("80%")

        ' グリッド線の設定
        sheet.GridLines = GridLines.None

        ' 罫線の設定
        For i As Integer = 0 To 13
            sheet.Cells(i, 0).Border = New FarPoint.Web.Spread.Border(BorderStyle.Solid, Color.LightGray, 1)
            sheet.Cells(i, 0).HorizontalAlign = HorizontalAlign.Center
            sheet.Cells(i, 0).VerticalAlign = VerticalAlign.Middle
        Next

        ' テストデータの設定
        sheet.SetClipValue(0, 0, 1, 1, "点数リスト")
        sheet.SetClipValue(1, 0, 1, 1, "0")
        sheet.SetClipValue(2, 0, 1, 1, "25")
        sheet.SetClipValue(3, 0, 1, 1, "25")
        sheet.SetClipValue(4, 0, 1, 1, "45")
        sheet.SetClipValue(5, 0, 1, 1, "45")
        sheet.SetClipValue(6, 0, 1, 1, "45")
        sheet.SetClipValue(7, 0, 1, 1, "60")
        sheet.SetClipValue(8, 0, 1, 1, "60")
        sheet.SetClipValue(9, 0, 1, 1, "75")
        sheet.SetClipValue(10, 0, 1, 1, "75")
        sheet.SetClipValue(11, 0, 1, 1, "75")
        sheet.SetClipValue(12, 0, 1, 1, "88")
        sheet.SetClipValue(13, 0, 1, 1, "100")

        ' SPREADへチャートを追加
        FpSpread1.Sheets(0).AddChart(New FarPoint.Web.Spread.Model.CellRange(1, 0, 13, 1), GetType(FarPoint.Web.Chart.HistogramSeries), 388, 300, 242, 46)

        Dim hseries As FarPoint.Web.Chart.HistogramSeries = DirectCast(FpSpread1.Sheets(0).Charts(0).Model.PlotAreas(0).Series(0), FarPoint.Web.Chart.HistogramSeries)
        hseries.BinOption.BinSize = 20
        hseries.BinOption.AutoOverFlow = True
        hseries.BinOption.AutoUnderFlow = True

        ' 凡例非表示
        FpSpread1.Sheets(0).Charts(0).Model.LegendAreas.Clear()
    End Sub
End Class

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="histogramchart.aspx.cs" Inherits="chart_histogram" %>

<%@ Register Assembly="FarPoint.Web.SpreadJ" Namespace="FarPoint.Web.Spread" TagPrefix="FarPoint" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceHolder1" runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="#A0A0A0" BorderStyle="Solid"
        BorderWidth="1px">
        <CommandBar BackColor="#F6F6F6" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight"
            ButtonShadowColor="ControlDark">
        </CommandBar>
        <Sheets>
            <FarPoint:SheetView SheetName="Sheet1">
            </FarPoint:SheetView>
        </Sheets>
    </FarPoint:FpSpread>
</asp:Content>