样式表作为Google Analytics图表和返回图像 [英] Style Chart as Google Analytics Chart and Return Image

查看:70
本文介绍了样式表作为Google Analytics图表和返回图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在尝试创建一个与Google Analytics访问图表类似的区域图表:

I am trying to create an area chart that looks like the Google Analytics visits chart:

http://www.flyondreams.net/Lab/chart.gif

I需要将其作为图像传递。不需要银光或某种花哨的东西。

I need to deliver it as an image. No need for silverlight or something fancy.

有人可以帮我解决这个问题吗?

Could someone, please, help me out with this?

谢谢,

Miguel

 

推荐答案

以下是Windows.Forms图表的示例..它也应该与asp.net一起使用。只需复制相关代码:

Here is an example with Windows.Forms charts.. it should work with asp.net too. Just copy the relevant code:


Imports System.Windows.Forms.DataVisualization.Charting

Public Class Form1

	Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

		'Add a chart to the form with the designer 
		'(or to the web page if using ASP.NET, make sure it has at least one series and one chart area)

		'There is no legend in the picture you provided, so..
		Chart1.Legends.Clear()

		'Test data
		Dim xValues As Date() = _
		{#9/14/2010#, #9/15/2010#, #9/16/2010#, #9/17/2010#, #9/18/2010#, #9/19/2010#, #9/20/2010#, #9/21/2010#, #9/22/2010#, _
		 #9/23/2010#, #9/24/2010#, #9/25/2010#, #9/26/2010#, #9/27/2010#, #9/28/2010#, #9/29/2010#, #9/30/2010#, #10/1/2010#}

		Dim yValues As Integer() = {300, 400, 200, 100, 150, 200, 250, 400, 350, 300, 400, 200, 100, 150, 200, 250, 400, 350}

		Dim series As Series = Chart1.Series(0)
		series.Points.DataBindXY(xValues, yValues)

		series.ChartType = SeriesChartType.Area

		series.Color = Color.FromArgb(100, 190, 220, 240) 'light blue
		series.BorderColor = Color.FromArgb(255, 0, 120, 255) 'darker blue
		series.BorderWidth = 4

		series.MarkerSize = 10
		series.MarkerColor = Color.FromArgb(255, 0, 120, 255) 'darker blue
		series.MarkerBorderColor = Color.White
		series.MarkerStyle = MarkerStyle.Circle

		Dim area As ChartArea = Chart1.ChartAreas(0)

		area.AxisX.Interval = 7
		area.AxisX.IntervalType = DateTimeIntervalType.Days

		area.AxisX.IsMarginVisible = False
		area.AxisX.LabelStyle.Format = "MMM dd, yyyy"
		area.AxisX.MajorGrid.LineColor = Color.LightGray

		area.AxisY.MajorGrid.LineColor = Color.LightGray
		area.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot
		area.AxisY.LineColor = Color.Transparent

		area.AxisY2.Enabled = AxisEnabled.True
		area.AxisY2.MajorGrid.Enabled = False
		area.AxisY2.LineColor = Color.Transparent

		'Uncomment this to save the chart as an image
		'Chart1.SaveImage("c:\temp\test.png", System.Drawing.Imaging.ImageFormat.Png)

	End Sub

End Class


这篇关于样式表作为Google Analytics图表和返回图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆