Home Forums Chart Support Dynamic name Option

Dynamic name Option

Viewing 5 posts - 1 through 5 (of 5 total)
  • #21183

    Hello,

    i sent a custom value from array and in data i just want to show that custom value in name which is dynamic.
    ie – data: [{name: “Year2005”,}]
    and just want to show like this ‘Profit OR Loss’ : value

    Thanks

    #21194

    @Chetnath,

    You can assign any valid string as dataSeries name either directly or by passing a variable that’s a string. Please take a look at this jsfiddle.

    If you are looking for something else, can kindly create a jsfiddle and brief further about your requirement so that we can understand it better and help you out?


    Vishwas R
    Team CanvasJS

    #21199

    Thanks for the reply

    please check the tooltip in given url, in both images tooltip are showing “Growth” text while it should be show “Profit” when line goes positive and “Loss” when it goes down (Negative).

    https://prnt.sc/jxpgmu
    https://prnt.sc/jxphag

    my code

    $(function () {

    var chart = new CanvasJS.Chart(“PLBYMContainer”, {
    animationEnabled: true,
    exportEnabled: true,
    theme: “light2”, // “light1”, “light2”, “dark1”, “dark2”
    title:{
    text: “Profit & Loss (By month)”,
    fontSize: 25
    },
    axisX:{
    reversed: false,
    title: “Profit & loss”
    },
    axisY:{
    title: “Range (in %)”,
    suffix: “%”,
    includeZero: false
    },
    toolTip:{
    shared: true
    },
    data: [{
    type: “line”,
    showInLegend: false,
    indexLabelFormatter: function ( e ) {
    return “₹ “+e.dataPoint.value;
    },
    name: “Growth”,
    yValueFormatString: “#,##0.0#\”%\””,
    dataPoints: <?php echo json_encode($PLByMonth, JSON_NUMERIC_CHECK); ?>
    }]
    });

    #21203

    @chetnath,

    You can use toolTip contentFormatter to format the content to the be displayed in toolTip. Please take a look at this JSFiddle.

    For further queries, kindly create JSFiddle along with sample data, so that we can look into working code, understand it better and help you out.


    Vishwas R
    Team CanvasJS

    #21221

    Yes..it’s working

    Thanks

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.