MVC :: Chart Controls Returned As FileResult?
Sep 8, 2010
I wanted to use the ASP.NET Chart Controls, but since all of the available examples used a code-behind page reminiscent of Web Forms, I shied away from this. Then I found an example returning the Chart Control as a FileResult, and tried it out. It worked, I was happy and all was good in the world. Except that occasionally I'll get a broken link showing instead of the image it should resolve to.
Here's how I have it set up:
In the View, the code is very simple. It's just an image tag that has its src attribute set to the Controller method. I didn't realize this was possible, and thought it pretty cool:
[Code]....
In the Controller, I instantiate and build the Chart Control in its entirety, and then output it as a FileResult:
[Code]....
Yes, it's a bit long and involves, but that's what you get when programmatically building something inititally set up to be a server control. All of this works, and even when I get the output that shows a broken link, if I refresh the page, it generally fixes itself. Here's the code from the FileResult created for this purpose - it's not a Controller, but I placed it in with the Controllers just while testing:
[Code]....
I'm thinking that the reason behind the occasional broken link is related to the DataContext object, not any of the above code. It seems reasonable that if the DataContext doesn't build and return a FileResult quickly enough, perhaps because it's doing too many other things, the broken link would show because no file had been built where it was expected. I've included the code anyway, in case someone can find an issue that would cause the problems I've been encountering. Any advice would be greatly appreciated. I had this working with Flex chart components that I genericized so that they worked with MVC methods, but they were way too slow to complete rendering. It often took 3-7 seconds, which was just too long for a user to wait for their page to load. These Chart Controls are really fast and are a perfect solution - if I can get them to render consistently.
View 8 Replies
Similar Messages:
Jun 19, 2010
How to reproduce:
1. Start a new class library project in VS 2010
2. Add System.Web and System.Web.Mvc assemblies to the project
3. Implement Class1 as follows:
[Code]....
4. When you try to compile you will get these errors:
error CS0115: 'ClassLibrary1.Class1.WriteFile(System.Web.HttpResponseBase)': no suitable method found to override
error CS0534: 'ClassLibrary1.Class1' does not implement inherited abstract member 'System.Web.Mvc.FileResult.WriteFile(System.Web.HttpResponseBase)'
Notes:
1. This only happens in VS 2010. Works fine in VS 2008.
2. I tried it on two different machines with the same result.
View 1 Replies
Nov 11, 2010
I'm having problems with FileResult returning a file with a specific filename. In the database the filename is just and ID + extension (e.g: 456789.mp3)
This piece of code
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
return File(fs, "application/octet-stream", "myfile.mp3");
Work well in every browser except Webkit browsers (Chrome, Safari). Chrome and Safari receive files as original filename (456789.mp3). When I add headers with
Response.AppendHeader("Content-Disposition", "attachment;filename=myfile.mp3");
Safari receives the file as myfile.mp3attach (notice "attach" appended to the extension?), however Chrome receives this file as myfile.mp3,attach (it appends ",attach" to the extension)
View 3 Replies
Jul 9, 2010
I have an issue in using dot net chart control. In chart last column is not completely shown which give bad appearance and on right side of chart it looks like TickMark are enabled. I set MajorTickMark of AxisY2 disabled but still tick marks on right side.
View 2 Replies
Feb 24, 2010
how to freeze the x axis of the chart control in ms chart? need to use because data displayed at large amount that is scrollable.
View 1 Replies
Jan 28, 2011
I have a drop downlist,and next to it there is an MS bar chart.i want to change the datate of the MS chart ,once the user selects another year from the dropdownlist.
When the page loads ,the chart displays the default year(2011) and it works.The problem is that is does not change the data when you select another year from the dropdownlist.
View 1 Replies
Apr 28, 2010
Am I going mad/blind? Probably a combination of the two.
How does one go about removing the data labels from a pie chart with the new chart control in .net 4?
I can get these to display as tooltips absolutely fine, but ultiamtely I'd like the labels not to be present as it looks rather busy.
I've searched previous answers and seen code behind resolutions but surely there must be some sort of code infront option to turn these labels off?
View 2 Replies
Aug 12, 2010
I am using MS Chart control (3.5), and have a requirement where I need to display 2 pie charts. The datapoints for the pie charts is set programatically. My doubts are as follows:
1. Can I display both the pie charts in a single chart control and area, or do I have to use two controls? (Currently I am using two controls)
2. How can I maintain the same size for both the pie charts? This is my main concern, since the pie sizes keep changing, depending on the number of datapoints. I tried using custom properties like "MinimumRelativePieSize", but it's not working.
View 1 Replies
Nov 17, 2010
i'm trying to create a stacked bar chart on a vb web form using vs2010.My data source returns:
Error in Functionality Awaiting on Supplier
1IMT IssuesmActive6
IMT Issues,Awaiting on Supplier
2,IMT Issues,Awaiting on User 4
IMT Issues Closed 120
Login / Password Active
But I can't get this into a stacked chart. I know I must have to do quite a bit of work declaring what the series are and soforth, or having a different dataset but can't find any documentation on it.A link to some documentation or an example of a stacked chart from an sql datasource would be much appreciated.
View 1 Replies
May 21, 2010
I started using the awesome chart controls with my asp.net apps recently and so far they've been nothing short of breath taking. Right now I have a weird problem, on the first load of my page, the chart control appears correctly and the tooltip is correct, however, when I update it with new data, the chart displays correctly, but the tooltips are for the previous set of data.
I hope this makes sense. The first time I load the chart, the pie chart segments and tooltips are correct, after a partial postback (to get the new data), the pie chart segments are correct but the tooltips are for the previous data set.
Basically once the tooltips are set the first time, they can't be updated after that without a full page postback.
Here's how I set the tooltip:
[Code]....
Anyone else noticed this behaviour and have a work around?
Currently my only workaround is to check for a partial postback and not render the tooltip, which I'd rather not do as the tooltip display actual statistical data as opposed to the pie itself (which uses percentages).
View 2 Replies
Apr 21, 2010
Does anyone know how to explode a certain section of the piechart, which is part of microsoft chart controls?
View 5 Replies
Jul 19, 2010
I have X and Y data columns coming from database.
I have to show scatter plot chart with Linear, Exponential, Log, power using asp.net chart control.
How to do that?
View 2 Replies
Jan 16, 2014
I referred this link [URL] ...
In order to add pie chart into my website, but i want to remove black border and add % sign to the numbers showing graph and also want to set colours in pie chart based on my website theme.
View 1 Replies
Jun 7, 2010
im trying to create simple pie chart using the MS Chart controls. When my pie chart gets rendered in the browser i get padding around the pie chart that i cant get rid of. i would like the pie chart to sit up against the edge of the image with no padding or margin. in my code below the padding is highlighted in blue. i.e Chart1.BackColor = System.Drawing.Color.Blue;
<script type="text/C#" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
//Set the chart type
Chart1.Series["Series1"].ChartType = SeriesChartType.Pie;
//add points
Chart1.Series["Series1"].Points.AddY(12);
Chart1.Series["Series1"].Points.AddY(45);
Chart1.Series["Series1"].Points.AddY(67);
//set back color of chart object
Chart1.BackColor = System.Drawing.Color.Blue;
//set back color of chart area
Chart1.ChartAreas["ChartArea1"].BackColor = System.Drawing.Color.Green;
}
</script>
<asp:Chart ID="Chart1" runat="server">
<Series>
<asp:Series Name="Series1" ChartType="Pie">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
View 1 Replies
Dec 22, 2010
I'm trying to put Google's BarChart and PieChart both the client side version, and i'm experiencing some problems with the labels over the pie and the labels on the left of the vertical axis (of the bar chart).
I checked the code a lot of times and it seems to be like that you can see in the examples.I've tried the same page on Firefox and Chrome and it shows the labels without problems.If i try the examples on IE8 the labels are shown but not in my page.Sincerely I've not any idea where to start to fix this thing.
View 1 Replies
Jan 28, 2011
Is it possible to specify what color each section of the pie looks like? Also, is it possible to display the legend on the side?
For ex: in the chart below, can I some specify that , "Pass" shows up as green, Fail as red and unknown as grey?
public ActionResult GetRainfallChart()
{
var key = new Chart(width: 600, height: 400).AddSeries(
chartType: "pie",
legend: "Test pass",
xValue: new[] { "Pass", "Fail", "Unknown" },
yValues: new[] { "50", "30", "20" })
.Write();
return null;
}
If its not possible with the "chart" control that comes in System.Web.Helpers assembly, then can someone point me how to do this with asp.net control for webforms in a MVC project
View 3 Replies
Jul 27, 2010
I am having a problem with my visual studio and crystal report. It's my first time using it.
When I add a new crystal report to my project, and try to add a chart, the chart menu is greyed out. Do I need to download any addin or I have missed out some .dll.
View 1 Replies
Jan 5, 2011
I am a novice programmer using ms chart control for my dashboard, I have a problem displaying chart series.
Here is my sample query & result
Sample Query: "SELECT Brand, sales, Manufacturer From TABLE"
Sample Result:
[code]....
How can I display BrandA for XValueMember & Salesvalue(10000) for YValueMembers as Series1 having a column chart type.
And to display BrandY & BrandZ for XValueMember ; Salesvalue for YValueMembers as Series2 having a line chart type.
I want my chart to have 2 Y-axis; Series1 for primary Y-axis & series2 for secondary Y-axis.
My problem here is how can I display BrandA in Series1 and BrandY,BrandZ in Series2 where the values are in the same field?
Or is it possible to set more than one data source for the chart control?
I've been working on this for two days but I wasn't able to get the desired result.
View 1 Replies
May 5, 2010
have 2 tables in SQL 2000 developer edition identicals, Prereception and eceptions, on the table Recepcions I have the following trigger:
CREATE TRIGGER [AumentaInventario] ON dbo.Recepcion
FOR INSERT
AS
declare @Codigo nvarchar (50)
,@Cantidad int
[code]...
View 2 Replies
Feb 16, 2011
im working on visual Studio 2010, and i have an error on an update.
this is the code in VB.
[Code]....
Thats the code and the error is:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.`
View 4 Replies
Aug 24, 2010
When a sql query returns NULL , I can use the following code to evaluate:
[Code]....
When a sql query returns nothing, neither IsDBNull nor is Nothing works. I don't know why some sql queries return null while some return nothing when there are no data returned. But anyway, can somebody tell me how to evaluate nothing value returned in sql datareader in vb.net? When I put the cursor over signInfo variable in debug mode, I can see Nothing show as its value. But the line does not work
[Code]....
View 3 Replies
Feb 18, 2010
I've managed to connect to the database and return a record based upon a login name. I can itterate through the rows printing out the password but I know there's only 1 row (or can test for that) so how do I get the value of the password for the one row without the loop?
Dim supervisorAdapter As New SupervisorTableAdapters.SupervisorTableAdapter
Dim supervisors As Supervisor.SupervisorDataTable
supervisors = supervisorAdapter.GetSupervisorByLogin(login)
For Each count As Supervisor.SupervisorRow In supervisors
Response.Write(count.password)
Next
View 3 Replies
Feb 25, 2011
I'm trying to use a variable returned from the database as an integer. My thought is to use a Link button and when my user clicks it, it should open a new window. However, its giving me an error stating the value is in the wrong format. Here is my link button code.
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Bind("Name") %>' PostBackUrl='profiles/profile.aspx?id=<%# Bind("ID") %>'></asp:LinkButton>
</ItemTemplate>
The error I get when I click is:
System.FormatException was unhandled by user code
Message=Input string was not in a correct format.
Source=mscorlib
StackTrace:
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Convert.ToInt32(String value)
at Training_profiles_profile.Page_Load(Object sender, EventArgs e) in d:projectsDIETMIWEB_svn-trunkDIETMIWEB_svnTrainingprofilesprofile.aspx.cs:line 25
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
View 1 Replies
May 13, 2010
I am having a requirement, where I need to have a pie-chart, i need text around pie-chart , the text should be a hyperlink. Ex: we have 3 three fields A,B,C. A's ratio is 30%, B's ratio is 40%, c's ratio is 30% So pie chart gets divided into 3 parts, outside the graph , we should get the label A(in A's area only), when we point on , tool tip should say "A's ratio is 30 %'. I am working in .Net 3.5, VS 2008, using MS chart control(added explicitly by executing MSChart.exe.
View 1 Replies
May 27, 2010
I am viewing items returned from a dataset in an Infragistics chart control. My problem is that due to a weak point in the control, I am left looking for a way to manipulate the height of the chart based on the count/number of items returned by the ObjectDataSource(DataSet).
Does anyone one have an existing C# sample they could let me view of accessing the count of records returned within the code-behind of a page that I could then use within a case statement to set the hight of the control?
View 7 Replies