パレート図

パレート図には、棒グラフと折れ線グラフの両方が含まれます。個々の値は降順で棒グラフによって表され、累計が折れ線グラフによって表されます。パレート図は、一連の値の中で、最も重要な項目を際立たせるために使用します。
 ABCDEF
1ページPV数    
2製品120    
3製品135    
4資料340    
5資料355    
6ヘルプ480    
7資料160    
8ヘルプ561    
9事例785    
10ヘルプ960    
11事例260    
   

ソースコード

別ウィンドウで表示
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_pareto : 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 = 11;
        sheet.ColumnCount = 6;
        sheet.PageSize = 25;
        sheet.DefaultColumnWidth = 100;
        sheet.DefaultRowHeight = 34;

        int dataColumnWidth = 116;
        sheet.Columns[0].Width = dataColumnWidth;
        sheet.Columns[1].Width = dataColumnWidth;

        // シートのフォントサイズの設定
        sheet.DefaultStyle.Font.Size = FontUnit.Parse("80%");
        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 < 11; i++)
        {
            for (int j = 0; j < 2; j++)
            {
                sheet.Cells[i, j].Border = new FarPoint.Web.Spread.Border(BorderStyle.Solid, Color.LightGray, 1);
                sheet.Cells[i, j].HorizontalAlign = HorizontalAlign.Center;
                sheet.Cells[i, j].VerticalAlign = VerticalAlign.Middle;

            }
        }

        // テストデータの設定
        sheet.SetClipValue(0, 0, 1, 2, "ページ\tPV数");
        sheet.SetClipValue(1, 0, 1, 2, "製品\t120");
        sheet.SetClipValue(2, 0, 1, 2, "製品\t135");
        sheet.SetClipValue(3, 0, 1, 2, "資料\t340");
        sheet.SetClipValue(4, 0, 1, 2, "資料\t355");
        sheet.SetClipValue(5, 0, 1, 2, "ヘルプ\t480");
        sheet.SetClipValue(6, 0, 1, 2, "資料\t160");
        sheet.SetClipValue(7, 0, 1, 2, "ヘルプ\t561");
        sheet.SetClipValue(8, 0, 1, 2, "事例\t785");
        sheet.SetClipValue(9, 0, 1, 2, "ヘルプ\t960");
        sheet.SetClipValue(10, 0, 1, 2, "事例\t260");

        // SPREADへチャートを追加
        FpSpread1.Sheets[0].AddChart(new FarPoint.Web.Spread.Model.CellRange(1, 0, 10, 2), typeof(FarPoint.Web.Chart.ParetoSeries), 388, 300, 242, 46);
        
        // フォントの設定
        Font labelFont = new Font("メイリオ", 9);
        // データバーにあるラベルのフォント設定
        FpSpread1.Sheets[0].Charts[0].Model.PlotAreas[0].Series[0].LabelTextFont = labelFont;
        // X軸のフォント設定
        FarPoint.Web.Spread.Chart.SpreadChart chart1 = FpSpread1.Sheets[0].Charts[0];
        YPlotArea plotArea = (YPlotArea)chart1.Model.PlotAreas[0];
        plotArea.XAxis.LabelTextFont = labelFont;

        // 凡例非表示
        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_pareto
    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 = 11
        sheet.ColumnCount = 6
        sheet.PageSize = 25
        sheet.DefaultColumnWidth = 100
        sheet.DefaultRowHeight = 34

        Dim dataColumnWidth As Integer = 116
        sheet.Columns(0).Width = dataColumnWidth
        sheet.Columns(1).Width = dataColumnWidth

        ' シートのフォントサイズの設定
        sheet.DefaultStyle.Font.Size = FontUnit.Parse("80%")
        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 10
            For j As Integer = 0 To 1
                sheet.Cells(i, j).Border = New FarPoint.Web.Spread.Border(BorderStyle.Solid, Color.LightGray, 1)
                sheet.Cells(i, j).HorizontalAlign = HorizontalAlign.Center

                sheet.Cells(i, j).VerticalAlign = VerticalAlign.Middle
            Next
        Next

        ' テストデータの設定
        sheet.SetClipValue(0, 0, 1, 2, "ページ" & vbTab & "PV数")
        sheet.SetClipValue(1, 0, 1, 2, "製品" & vbTab & "120")
        sheet.SetClipValue(2, 0, 1, 2, "製品" & vbTab & "135")
        sheet.SetClipValue(3, 0, 1, 2, "資料" & vbTab & "340")
        sheet.SetClipValue(4, 0, 1, 2, "資料" & vbTab & "355")
        sheet.SetClipValue(5, 0, 1, 2, "ヘルプ" & vbTab & "480")
        sheet.SetClipValue(6, 0, 1, 2, "資料" & vbTab & "160")
        sheet.SetClipValue(7, 0, 1, 2, "ヘルプ" & vbTab & "561")
        sheet.SetClipValue(8, 0, 1, 2, "事例" & vbTab & "785")
        sheet.SetClipValue(9, 0, 1, 2, "ヘルプ" & vbTab & "960")
        sheet.SetClipValue(10, 0, 1, 2, "事例" & vbTab & "260")

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

        ' フォントの設定
        Dim labelFont As New Font("メイリオ", 9)
        ' データバーにあるラベルのフォント設定
        FpSpread1.Sheets(0).Charts(0).Model.PlotAreas(0).Series(0).LabelTextFont = labelFont
        ' X軸のフォント設定
        Dim chart1 As FarPoint.Web.Spread.Chart.SpreadChart = FpSpread1.Sheets(0).Charts(0)
        Dim plotArea As YPlotArea = DirectCast(chart1.Model.PlotAreas(0), YPlotArea)
        plotArea.XAxis.LabelTextFont = labelFont

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

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

<%@ 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>