Hi ,
I will appreciate if someone could help me with this issue.
I have a Model with the following structure:
public class PieChartModel
{
public string YearMonth { get; set; } //this have a data like 2013.05
public decimal Balance { get; set; }
public string ClientName { get; set; }
public decimal EndingPercentage { get; set; }
}
My task is to display this information in a graph that
contain multiple axis represented like in Image 1
The code I used to get the graph on Image 1 was this one:
@(Html.Kendo().Chart<AccutracDashboard.Models.PieChartModel>()
.Name(Model.ChartName)
.HtmlAttributes(new {style = "height: 500px"})
.Title(Model.ChartTitle)
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom)
)
.DataSource(ds => ds.Read(read =>
read.Action(Model.ChartAction, Model.ChartController))
)
.Series(series => {
series.Column(model =>
model.Balance)
.GroupNameTemplate("#= group.value # (#= series.name #)").Labels(false);
series.Line(model =>
model.EndingPercentage).Name("Percent")
.Axis("percent").Labels(false);
})
.CategoryAxis(axis => axis
.Categories(model => model.ClientName)
.Labels(label => label.Visible(true).Rotation(45))
.AxisCrossingValue(0, 21)
)
.ValueAxis(axis => axis.Numeric()
.Labels(labels => labels
.Format("${0}")
).Title("Indicator
$"))
.ValueAxis(axis => axis
.Numeric("percent")
.Title("Frequency")
.Labels(labels => labels.Format("{0}%"))
.Min(0).Max(100)
)
.Tooltip(tooltip => tooltip
.Visible(true)
.Format("{0:N0}")
)
)
but our client wants each bar to have a different color and
be shown as a legend in the graph as you can see on Image 2
Grouping by client I can implement this request, but then the line graph is not represented properly.
The code I used to group is almost the same
@(Html.Kendo().Chart<AccutracDashboard.Models.PieChartModel>()
.Name(Model.ChartName)
.HtmlAttributes(new {style = "height: 500px"})
.Title(Model.ChartTitle)
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom)
)
.DataSource(ds => ds.Read(read =>
read.Action(Model.ChartAction, Model.ChartController))
.Group(group => group.Add(model => model.ClientName)))
.Series(series => {
series.Column(model => model.Balance)
.GroupNameTemplate("#= group.value # (#= series.name #)").Labels(false);
series.Line(model =>
model.EndingPercentage).Name("Percent")
.Axis("percent").Labels(false);
})
.CategoryAxis(axis => axis
.Categories(model => model.ClientName)
.Labels(label => label.Visible(true).Rotation(45))
.AxisCrossingValue(0, 21)
)
.ValueAxis(axis => axis.Numeric()
.Labels(labels => labels
.Format("${0}")
).Title("Indicator
$")
)
.ValueAxis(axis => axis
.Numeric("percent")
.Title("Frequency")
.Labels(labels => labels.Format("{0}%"))
.Min(0).Max(100)
)
.Tooltip(tooltip => tooltip
.Visible(true)
.Format("{0:N0}")
)
)
What do I need to do in order to show the data in the graph displaying the bars with different color and showing a legend per client, and at the same time be able to see properly the line chart?
Please let me know if you need more information.
Thanks, Ainel
I will appreciate if someone could help me with this issue.
I have a Model with the following structure:
public class PieChartModel
{
public string YearMonth { get; set; } //this have a data like 2013.05
public decimal Balance { get; set; }
public string ClientName { get; set; }
public decimal EndingPercentage { get; set; }
}
My task is to display this information in a graph that
contain multiple axis represented like in Image 1
The code I used to get the graph on Image 1 was this one:
@(Html.Kendo().Chart<AccutracDashboard.Models.PieChartModel>()
.Name(Model.ChartName)
.HtmlAttributes(new {style = "height: 500px"})
.Title(Model.ChartTitle)
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom)
)
.DataSource(ds => ds.Read(read =>
read.Action(Model.ChartAction, Model.ChartController))
)
.Series(series => {
series.Column(model =>
model.Balance)
.GroupNameTemplate("#= group.value # (#= series.name #)").Labels(false);
series.Line(model =>
model.EndingPercentage).Name("Percent")
.Axis("percent").Labels(false);
})
.CategoryAxis(axis => axis
.Categories(model => model.ClientName)
.Labels(label => label.Visible(true).Rotation(45))
.AxisCrossingValue(0, 21)
)
.ValueAxis(axis => axis.Numeric()
.Labels(labels => labels
.Format("${0}")
).Title("Indicator
$"))
.ValueAxis(axis => axis
.Numeric("percent")
.Title("Frequency")
.Labels(labels => labels.Format("{0}%"))
.Min(0).Max(100)
)
.Tooltip(tooltip => tooltip
.Visible(true)
.Format("{0:N0}")
)
)
but our client wants each bar to have a different color and
be shown as a legend in the graph as you can see on Image 2
Grouping by client I can implement this request, but then the line graph is not represented properly.
The code I used to group is almost the same
@(Html.Kendo().Chart<AccutracDashboard.Models.PieChartModel>()
.Name(Model.ChartName)
.HtmlAttributes(new {style = "height: 500px"})
.Title(Model.ChartTitle)
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom)
)
.DataSource(ds => ds.Read(read =>
read.Action(Model.ChartAction, Model.ChartController))
.Group(group => group.Add(model => model.ClientName)))
.Series(series => {
series.Column(model => model.Balance)
.GroupNameTemplate("#= group.value # (#= series.name #)").Labels(false);
series.Line(model =>
model.EndingPercentage).Name("Percent")
.Axis("percent").Labels(false);
})
.CategoryAxis(axis => axis
.Categories(model => model.ClientName)
.Labels(label => label.Visible(true).Rotation(45))
.AxisCrossingValue(0, 21)
)
.ValueAxis(axis => axis.Numeric()
.Labels(labels => labels
.Format("${0}")
).Title("Indicator
$")
)
.ValueAxis(axis => axis
.Numeric("percent")
.Title("Frequency")
.Labels(labels => labels.Format("{0}%"))
.Min(0).Max(100)
)
.Tooltip(tooltip => tooltip
.Visible(true)
.Format("{0:N0}")
)
)
What do I need to do in order to show the data in the graph displaying the bars with different color and showing a legend per client, and at the same time be able to see properly the line chart?
Please let me know if you need more information.
Thanks, Ainel