PDA

View Full Version : [CLOSED] Add ChartTip to BarSeries



T3rryChan
Apr 27, 2012, 6:35 PM
Hi,

I am trying to add the ChartTip to the BarSeries (MVC3, Razor ViewEngine) like this



Tips(tips => tips.Add(Html.X().ChartTip().Renderer(renderer => new JFunction("this.setTitle(storeItem.get('Name') + ': ' + storeItem.get('Data1') + ' views');"))))


but got an exception saying "Object reference not set to an instance of an object.". Is this a bug? If not, could someone show me the proper way to add the ChartTip?

Also, I am not able to set the TrackMouse property like this tips.TrackMouse(true), which throws an "TrackMouse is undefined" exception.

Thanks.

Vladimir
Apr 27, 2012, 10:48 PM
Please update from SVN and retest
Here is sample code for ChartTip


... .Tips(Html.X().ChartTip())...

T3rryChan
Apr 30, 2012, 11:08 AM
Please update from SVN and retest
Here is sample code for ChartTip


... .Tips(Html.X().ChartTip())...


Hi,

I have to add the ChartTip recommanded



Tips(Html.X().ChartTip())


but got an exception saying "The best overloaded method match for 'Ext.Net.AbstractSeries.Builder<Ext.Net.BarSeries,Ext.Net.BarSeries.Builder>.Tips(System.Action<Ext.Net.ChartTip>)' has some invalid arguments"

Are there any arguments that must be passed to the constructor when initializing a ChartTip instance?

T3rryChan
Apr 30, 2012, 11:30 AM
Oops.... My bad. Forget to re-compile. It is working now. Thanks.

T3rryChan
Apr 30, 2012, 11:35 AM
Another question thou, how to do set the Renderer property of the ChartTip?

I tried it this way:



Html.X().ChartTip() {Renderer = new JFunction("this.setTitle(storeItem.get('Name') + ': ' + storeItem.get('Data1') + ' views');")}


But then a exception is thrown saying that the Renderer property is read only.

Daniil
Apr 30, 2012, 1:40 PM
Hi,

Example

@(Html.X().ChartTip()
.Renderer(r =>
r.Handler = "return 'Hello!';"
)
)

T3rryChan
Apr 30, 2012, 1:58 PM
Hi,

Example

@(Html.X().ChartTip()
.Renderer(r =>
r.Handler = "return 'Hello!';"
)
)

Nice! Thank you

Binai
Jul 09, 2012, 11:27 AM
Hi please send me fully code

Thanks
Binai

Daniil
Jul 09, 2012, 4:16 PM
Hi @Binai,

Do you need an example of the Chart using the Razor engine? Here you are.

Example View

<!DOCTYPE html>

<html>
<head>
<title>Ext.Net.MVC v2 Example</title>
</head>
<body>
@Html.X().ResourceManager()

@(Html.X().Chart()
.Width(400)
.Height(400)
.Store(store =>
store.Add(Html.X().Store()
.Model(model =>
model.Add(Html.X().Model()
.Fields(fields =>
{
fields.Add(Html.X().ModelField().Name("x"));
fields.Add(Html.X().ModelField().Name("y"));
}
)
)
)
.DataSource(Model)
)
)
.Axes(axes =>
{
axes.Add(Html.X().NumericAxis()
.Title("X")
.Fields(new string[] { "x" })
.Position(Position.Bottom)
);
axes.Add(Html.X().NumericAxis()
.Title("Y")
.Fields(new string[] { "y" })
.Position(Position.Left)
);
}
)
.Series(series =>
series.Add(Html.X().LineSeries()
.Title("LineSeries")
.XField(new string[] { "x" })
.YField(new string[] { "y" })
)
)
)
</body>
</html>


Example Controller Action

public ActionResult TestRazor()
{
object chartData = new object[]
{
new
{
x = 0,
y = 0
},
new
{
x = 50,
y = 50
},
new
{
x = 100,
y = 100
}
};
return View(chartData);
}

Please start new forum threads for all possible related questions with, if you wish, cross-linking between the threads.