AspNetCoreSamples
AspNetCoreSamples copied to clipboard
How to add annotations?
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);
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?