Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
adding chart series dynamically

Im adding chart series dynamically but i cant get any legends to shoiw on the graph. Ive tried all the methods in the api and help sections but nothing works (the suggestions just break the graph and nothing gets rendered)  can anyone show me how to sad legends to dynamicallky added series ?

I define my chart in an MVC helper like this

                                                    .Axes(axis =>
                                                        axis.CategoryX("DateAxis").Title("Date").Label(l => l.CloseDateAsString).Overlap(1.0).UseEnhancedIntervalManagement(true);
                                                        axis.NumericY("PriceAxis").Title("Price (£/MWh)").LabelLocation(AxisLabelsLocation.OutsideLeft);

then I have some javascript that detects if a property on the model has a value, if it does, I create a series (I have multiple proiperties, one for each series i may or may not show)

this work and I render the appropriate series, but I dont get a legend !  this is driving me nuts and none of the suggestions work,

if (model.Series1EnergyProduct.length > 0)
                $("#chart").igDataChart("option", "series", [{ name: model.Series1EnergyProduct, remove: true }]);
                $("#chart").igDataChart("option", "series", [{
                    type: "line",
                    name: model.Series1EnergyProduct,
                    title: model.Series1EnergyProduct,
                    xAxis: "DateAxis",
                    yAxis: "PriceAxis",
                    valueMemberPath: model.Series1ValuePathName,
                    isTransitionInEnabled: true,
                    isHighlightingEnabled: true,
                    thickness: 2,
                    brush: "#E01512",
                    showTooltip: true
                    //legend: $("legend"),
                    //labelMemberPath: model.Series1EnergyProduct
                    //legendLabelMemberPath: model.Series1EnergyProduct

  • 2600
    Offline posted

    Hello Mark,

    Thank you for contacting us.

    Judging by your most recent cases, you managed to solve this issue? Can you confirm?

    I am looking forward to hearing from you.