Home Forums Chart Support Dynamic name Option

Dynamic name Option

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


    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




    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


    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).


    my code

    $(function () {

    var chart = new CanvasJS.Chart(“PLBYMContainer”, {
    animationEnabled: true,
    exportEnabled: true,
    theme: “light2”, // “light1”, “light2”, “dark1”, “dark2”
    text: “Profit & Loss (By month)”,
    fontSize: 25
    reversed: false,
    title: “Profit & loss”
    title: “Range (in %)”,
    suffix: “%”,
    includeZero: false
    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); ?>



    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


    Yes..it’s working


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

You must be logged in to reply to this topic.