AspNetCoreSamples icon indicating copy to clipboard operation
AspNetCoreSamples copied to clipboard

How to add annotations?

Open fracampit opened this issue 3 years ago • 2 comments

How would you add annotations to your example?

fracampit avatar Aug 21 '22 11:08 fracampit

Can you try this code?

var pizza = new[]
{
    new {Name = "Mushrooms", Count = 3},
    new {Name = "Onions", Count = 1},
    new {Name = "Olives", Count = 1},
    new {Name = "Zucchini", Count = 1},
    new {Name = "Pepperoni", Count = 2}
};
var column1 = new Column(ColumnType.String, "Topping");
var column2 = new Column(ColumnType.Number, "Slices");
column1.Role = "annotation";
column2.Role = "annotation";
var json = pizza.ToGoogleDataTable()
                .NewColumn(column1, x => x.Name)
                .NewColumn(column2, x => x.Count)
                .Build()
                .GetJson();

return Content(json);

anuraj avatar Aug 25 '22 05:08 anuraj

Thanks for the reply. I have tried that but unfortunately adding that column1.Role = "annotation"; column2.Role = "annotation"; makes no difference. It looks like it needs something else in addition to setting the Role to annotation.

In the google docs they use three columns. Perhaps it needs a third column with the role of 'annotation'? and the value associated with that column will go on top of the bars?

fracampit avatar Aug 25 '22 09:08 fracampit