0
votes

I Have used below code for kendo stacked bar chart. Seems everything is fine but am not able to customize the shared template. I want to remove the tooltip for entries whose value is zero In the series.

@(Html.Kendo().Chart()
                .Name("chrtMonth_" + ContextId)
                .Legend(legend => legend.Position(ChartLegendPosition.Top).Visible(true))
                        .SeriesDefaults(seriesDefaults => seriesDefaults.Column().Visual("columnVisual").Stack(true)
                .Highlight(highlight => highlight.Toggle("toggleHandler")))
                .DataSource(ds => ds.Read(read => read.Action("GetWeeklyMonthlyGraphData", "CMCDashboard")))

                .Series(series =>
                {
                    foreach (var row in Model.Rows)
                    {

                        var monthOnMontValues =
                            new double[]
                                {
                                   Convert.ToDouble(((System.Data.DataRow)row)[1])<0?0:Convert.ToDouble(((System.Data.DataRow)row)[1]),
                                  Convert.ToDouble(((System.Data.DataRow)row)[2])<0? 0:Convert.ToDouble(((System.Data.DataRow)row)[2]),
                                  Convert.ToDouble(((System.Data.DataRow)row)[3])<0? 0:Convert.ToDouble(((System.Data.DataRow)row)[3]),
                                  Convert.ToDouble(((System.Data.DataRow)row)[4])<0? 0:Convert.ToDouble(((System.Data.DataRow)row)[4]),
                                  Convert.ToDouble(((System.Data.DataRow)row)[5])<0? 0:Convert.ToDouble(((System.Data.DataRow)row)[5]),
                                  Convert.ToDouble(((System.Data.DataRow)row)[6])<0? 0:Convert.ToDouble(((System.Data.DataRow)row)[6]),
                                  Convert.ToDouble(((System.Data.DataRow)row)[7])<0? 0:Convert.ToDouble(((System.Data.DataRow)row)[7]),
                                  Convert.ToDouble(((System.Data.DataRow)row)[8])<0? 0:Convert.ToDouble(((System.Data.DataRow)row)[8]),
                                  Convert.ToDouble(((System.Data.DataRow)row)[9])<0? 0:Convert.ToDouble(((System.Data.DataRow)row)[9]),
                                  Convert.ToDouble(((System.Data.DataRow)row)[10])<0? 0:Convert.ToDouble(((System.Data.DataRow)row)[10]),
                                  Convert.ToDouble(((System.Data.DataRow)row)[11])<0? 0:Convert.ToDouble(((System.Data.DataRow)row)[11]),
                                  Convert.ToDouble(((System.Data.DataRow)row)[12])<0? 0:Convert.ToDouble(((System.Data.DataRow)row)[12])
                                };
                        series.Column(monthOnMontValues).Name(Convert.ToString(((System.Data.DataRow)row)["Status"]));
                    }


                })
                                .CategoryAxis(axis =>
                                {
                                    string[] names = null;
                                    string colNames = string.Empty;
                                    for (int i = 0; i < Model.Columns.Count; i++)
                                    {
                                        if (i != 0)
                                        {
                                            colNames = colNames + Model.Columns[i] + ",";
                                        }
                                    }
                                    names = colNames.Split(',').Where(p => !string.IsNullOrEmpty(p)).ToArray();
                                    axis.Categories(names).Visible(true);
                                }

                    )
            .Panes(panes => panes.Add().Clip(false))
            .ValueAxis(axis => axis.Numeric()
                        .Labels(labels =>
                        labels.Template("#= kendo.format('{0:N0}', value) # ")
                    )
            .Line(line => line.Visible(false))
                    ).Tooltip(t => t.Visible(true).Shared(true))


            )

Shared Tool Tip Is appearing fine But I want to remove entries for data whose values is zero attaching sharedtooltip screen shot.

Thanks,
Munna[enter image description here][1]


  [1]: https://i.stack.imgur.com/6jnGx.png
1

1 Answers

0
votes
.SharedTemplate("<table> #  for (var i = 0; i < points.length; i++) { #" 
+ "# if (points[i].value !== 0) { #"
+ "<tr>   <td style='word-wrap:break-word;'>#: points[i].series.name  #</td>" 
+"  <td style='width:20%;text-align:right;'>#: points[i].value #</td></tr>" + "# } #" 
+"# } # </table>")