0 votes

Series name dxchart devextreme

I currently work with ASP.NET and devextreme component. My question is: How can I give name to my "series" of the graph from the C# code? Devextreme shows how to do it from the client side but not from the server side.

My example project is very similar to the example taken in this page: https://www.devexpress.com/Support/Center/Example/Details/E4470 )

The arguments and the values work well, but not the series.

This is my code, but it does not work:

Jscript:

$(function () {



  $("#chartContainer").dxChart({
    dataSource: chartData,


    commonSeriesSettings: {
        type: "line",

        hoverMode: "allArgumentPoints",
        selectionMode: "allArgumentPoints",
        label: {
            visible: false,

        },


    },

    tooltip: {
        enabled: true,
        format: "fixedPoint",
        precision: 2,

        customizeText: function () {
            return this.valueText + ' Q';
        }

    },


    series: [

        { argumentField: 'argumento1', valueField: 'valor1', name: 'Ano_A', color: 'DarkSeaGreen' },
        { argumentField: 'argumento2', valueField: 'valor2', name: 'Ano_B', color: 'LightBlue' },

    ],

    argumentAxis: {
        tickInterval: 1,

    },

    legend: {
        horizontalAlignment: 'center'
    }



});   });

Datahelper C#:

using System;
using System.Collections;
using System.Collections.Generic;
using Dashboard.ks.Dashboard.ks;


public class DataHelper
{


public DataHelper()
{
    Dashboard.Query.Sale.Instance.ListSaleDaily = Dashboard.Query.Sale.LevelOne.UnionOrderSale();


}

public IEnumerable GetItemsQ()
{

    List<KBInfo> kbItems = new List<KBInfo>();


    foreach (var day in inicio.ListA)
    {

        kbItems.Add(new KBInfo()
        {
            argumento1 = (day.Day),
            valor1 = (day.Qtysold),
           // Ano_A=(inicio.Ano),

            Ano_A = 2016,

        });
    }

    foreach (var day in inicio.ListB)
    {
        kbItems.Add(new KBInfo()
        {
            argumento2 = (day.Day),
            valor2 = (day.Qtysold),
           // Ano_B = (inicio.Ano - 1),
            Ano_B = 2015,


        });
    }


    return kbItems;
}



}

public class KBInfo
{
public int argumento1 { get; set; }
public int argumento2 { get; set; }
public decimal valor1 { get; set; }
public decimal valor2 { get; set; }
public int Ano_A { get; set; }
public int Ano_B { get; set; }
}

0voto

N'oel C'alero Points 317

Initially unaware of the Jquery code. The answer was very simple.

Just change the string of the series.

Where it says value1, and value2 now sutituye with any name you want to call the variable.

series: [

    { argumentField: 'argumento1', valueField: 'NUEVO VALOR 1', name: 'Ano_A', color: 'DarkSeaGreen' },
    { argumentField: 'argumento2', valueField: 'NUEVO VALOR 1', name: 'Ano_B', color: 'LightBlue' },

],

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X