[CLOSED] Add ChartTip to BarSeries

  1. #1

    [CLOSED] Add ChartTip to BarSeries

    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.
    Last edited by Daniil; Apr 30, 2012 at 2:12 PM. Reason: [CLOSED]
  2. #2
    Please update from SVN and retest
    Here is sample code for ChartTip
    ... .Tips(Html.X().ChartTip())...
  3. #3
    Quote Originally Posted by Vladimir View Post
    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?
  4. #4
    Oops.... My bad. Forget to re-compile. It is working now. Thanks.
  5. #5
    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.
  6. #6
    Hi,

    Example
    @(Html.X().ChartTip()
        .Renderer(r =>
            r.Handler = "return 'Hello!';"
        )
    )
  7. #7
    Quote Originally Posted by Daniil View Post
    Hi,

    Example
    @(Html.X().ChartTip()
        .Renderer(r =>
            r.Handler = "return 'Hello!';"
        )
    )
    Nice! Thank you
  8. #8
    Hi please send me fully code

    Thanks
    Binai
  9. #9
    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.

Similar Threads

  1. Add charttip in code behind
    By cerqueira81 in forum 2.x Help
    Replies: 3
    Last Post: Jun 21, 2012, 1:28 PM
  2. [CLOSED] [Razor] How to use ChartTip?
    By Stijn in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Jun 05, 2012, 12:34 PM

Tags for this Thread

Posting Permissions