valensoft

OpenFlashChart之3D柱状图开发

页面文件

<%@ Page Language="C#" AutoEventWireup="true"
 CodeBehind="3dBar.aspx.cs" Inherits="OFCDemo.data._dBar"
 ResponseEncoding="GB2312" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <ofc:Chart ID="ofc3dBar" runat="server" Url="../data/3DBarData.aspx" Width="90%"
            Height="500px" />
    </div>
    </form>
</body>
</html>

数据代码:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OpenFlashChart;
using System.Text;

namespace OFCDemo.ofc
{
    public partial class _DBarData : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Graph graph = new Graph();
            //定义图表的标题。。
            graph.Title = new Title("3D页面浏览统计柱状图",
                "{font-size:20px; color: #736AFF; margin: 5px; padding:5px; padding-left: 20px; padding-right: 20px;}");
            graph.MaxY = 100;
            //定义柱状对象(链接透明度,bar条颜色,项目标题,项目标题字体大小)
            OpenFlashChart.Charts.Bar3D bar =
                new OpenFlashChart.Charts.Bar3D(75, "#D54C78", "页面浏览(万PV/月)", 15);

            OpenFlashChart.Charts.Bar3D bar2 =
              new OpenFlashChart.Charts.Bar3D(75, "#5500FF", "IP浏览(IP/月)", 15);

            //赋值份额
            Random rd = new Random();
            for (int i = 1; i < 13; i++)
            {
                bar.Data.Add(rd.Next(1, 100));
                bar2.Data.Add(rd.Next(1, 100));
                //X轴标签
                graph.LabelsX.Add(string.Format("{0}月",i));
            }
            //3d X轴宽度。
            graph.AxisX3D = 12;
            //x,y轴颜色。
            graph.AxisColorX = "#909090";
            graph.AxisColorY = "#909090";
            //Y轴标签
            graph.LegendY = new LegendY("PV(万)", 15, "#736AFF");
         
            graph.Data.Add(bar);
            graph.Data.Add(bar2);
            //输出数据
            //Response.ContentEncoding = System.Text.Encoding.Default;
            Response.Clear();
            Response.Write(graph.ToString());
            Response.End();
          
        }
    }
}

这个图表的Y轴和项目栏的中文不能正确显示出来,但是英文就可以,估计是一Bug,但是还未找到解决方法,各位朋友如果解决了请写信给告知完善版本。

分类:

技术点:

相关文章:

  • 2021-12-19
  • 2022-01-18
  • 2022-12-23
  • 2022-01-25
  • 2021-11-24
  • 2021-08-28
  • 2021-07-05
  • 2021-11-06
猜你喜欢
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
相关资源
相似解决方案