|
|
When I postback the page, I change the data for the chart based on some filter.. But, nothing gets displayed in the chart.
Please help!
|
|
|
|
I am getting :
Unable to cast object of type 'Highchart.Core.ToolTip' to type 'System.String'.
When I perform a postback based on some dropdownlist filter.
Did you find a solution?
|
|
|
|
ashish_mundra wrote:
When I postback the page, I change the data for the chart based on some filter.. But, nothing gets displayed in the chart.
Please help!
Have you enabled the ViewState for the page as I think this is crucial for these sorts of things.
|
|
Developer
Aug 30, 2011 at 4:14 AM
Edited Aug 30, 2011 at 4:33 AM
|
Simply enabling viewstate will not be enough to maintain chart state after a postback. You will also need to make the following changes to GenericChart.cs :
Replace:
public virtual SerieCollection Series
{
get
{
if (_series == null)
{
_series = new SerieCollection();
if (IsTrackingViewState)
_series.TrackViewState();
}
return _series;
}
}
With:
public virtual SerieCollection Series
{
get
{
_series = (SerieCollection) ViewState["SeriesCollection"];
if (_series == null)
{
_series = new SerieCollection();
if (IsTrackingViewState)
{
_series.TrackViewState();
ViewState["SeriesCollection"] = _series;
}
return _series;
}
if (IsTrackingViewState)
ViewState["SeriesCollection"] = _series;
return _series;
}
}
This will save the data associated with the chart in viewstate. However, remember that for graphs with a large number of datapoints, the data saved in the viewstate might become huge. Caution is advised.
Let me know if you still face a problem though.
|
|
Developer
Aug 30, 2011 at 4:29 AM
Edited Aug 30, 2011 at 4:30 AM
|
inversechi wrote:
I am getting :
Unable to cast object of type 'Highchart.Core.ToolTip' to type 'System.String'.
When I perform a postback based on some dropdownlist filter.
Did you find a solution?
The problem happens when you have a user defined value for <chart>.Tooltip. Oddly enough, the default value seems to work just fine..
To make it work, make the following changes in GenericCharts.cs,
Replace:
public virtual ToolTip Tooltip
{
get
{
object o = ViewState["ToolTip"];
if (o == null)
return new ToolTip("Highcharts.dateFormat('%e %b %Y', this.x) + '<br/> <b>' + this.series.name + ':</b> '+ this.y");
return (ToolTip)o;
}
set
{
ViewState["ToolTip"] = value;
}
}
With:
public virtual string Tooltip
{
get
{
object o = ViewState["ToolTip"];
if (o == null)
return (new ToolTip("this.x + '<br/> <b>' + this.series.name + ':</b> '+ this.y")).ToString();
return (string)o;
}
set
{
ViewState["ToolTip"] = value;
}
}
As for usage replace existing usage with:
hcVendas.Tooltip = (new ToolTip("Highcharts.dateFormat('%A, %e %b, %Y', this.x) + ' <br/>' + this.series.name + '<br/><b> Hrs: </b> '+ Highcharts.dateFormat('%H:%M', this.y)").ToString());
I really dont understand what the problem is, since the default object seems to work just fine, but the problem is easily sidestepped by saving a string instead.
|
|
|
|
I want as ashish_mundra said , to run the report by click on asp.net command . its not working ,,
I don't know what happend ,,
After I change all changes above , it give an error below :
Type 'Highchart.Core.SerieCollection' in Assembly 'Highchart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
Please help ,,
Faris
|
|
|
|
Any help please ..
|
|
Developer
Nov 18, 2011 at 11:21 AM
Edited Nov 20, 2011 at 10:03 AM
|
Try adding [Serializable] to the top of your class Highchart.Core.SerieCollection
So the beginning of your class should look like..
[Serializable]
public
class SerieCollection :
List<Serie>,
IStateManager
{
...
Let me know if you still face problems.
Rahul Sud
|
|
|
|
Hello Rahul ,
The error is gone now , But my case is not working well , when I click on the button with some parameter as a filter , first time is not get any thing and the chart is not render ,
and second click on the button , the chart is working ,
and the third click , the chart is take the new data source plus the old one , so the chart is added the series from the as one chart with two datasource ..
What I want , is to click on the button in the first time and directlly to view the chart , and in the send click it must clear the first chart and render the new one from the scratch ..
You can see the screenshot fro my case , on this link : http://www.alphaclc.com/HighChartWithButton.png
I hope to complete this case ,,
Did you have any working sample project for this case ,,??
Please help,,
Thanks
|
|
|
|
Ohh ,, I just fix the multi series on the chart using this code :
protected void Button1_Click(object sender, EventArgs e)
{
hcTemperatura.Series.Clear();
Exemplo03();
}
I still need , when the user click on the button , simply to view the chart in first click , in my case the chart is render when the user click on the button twice ,,
I just tell you that is to share the ideas between us ,,
Thanks my friend .
|
|
|
|
I put the code on this link , if you can see my case :
Highchart asp.net project
I can't fix it until now ..
Thanks Rahul ..
|
|
Developer
Nov 18, 2011 at 3:58 PM
Edited Nov 20, 2011 at 10:03 AM
|
You will need to make the following changes:
In Highchart.UI.<YourChartType>
Replace:
protected
override void OnLoad(EventArgs e)
{
RenderType =
RenderType.areaspline;
Render();
base.OnLoad(e);
}
With:
protected
override void OnLoad(EventArgs e)
{
base.OnLoad(e);
}
protected
override void OnPreRender(EventArgs e)
{
RenderType =
RenderType.area;
Render();
}
In Highchart.UI.Chart
Replace:
protected
override void OnLoad(EventArgs e)
{
base.OnLoad(e);
}
protected
override void OnPreRender(EventArgs e)
{
string[] scripts = {
"Highchart.HighchartAPI.highcharts.js",
"Highchart.HighchartAPI.exporting.js" };
foreach (string js
in scripts)
{
string url = Page.ClientScript.GetWebResourceUrl(GetType(), js);
if (!Page.ClientScript.IsClientScriptBlockRegistered(GetType(), js))
{
Page.ClientScript.RegisterClientScriptInclude(GetType(), js, url);
}
}
base.OnPreRender(e);
}
With:
protected
override void OnLoad(EventArgs e)
{
try
{
string[] scripts = {
"Highchart.HighchartAPI.themes.js",
"Highchart.HighchartAPI.highcharts.js", "Highchart.HighchartAPI.exporting.js" };
foreach (string js
in scripts)
{
string url = Page.ClientScript.GetWebResourceUrl(GetType(), js);
if (!Page.ClientScript.IsClientScriptBlockRegistered(GetType(), js))
{
Page.ClientScript.RegisterClientScriptInclude(GetType(), js, url);
}
}
}
catch (Exception E)
{
HttpContext.Current.Response.Write(E.ToString());
}
base.OnLoad(e);
}
protected
override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
}
That should do it. Let me know if you still have a problem.
|
|
|
|
Excellent ,, well done man ,, Its works fine ,,
The button now response from the first time ,,
Thanks A lot Rahul ..
|
|