This is a migrated thread and some comments may be shown as answers.

Hide Chart Y Axis

1 Answer 1275 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Hannah
Top achievements
Rank 1
Hannah asked on 23 Oct 2014, 03:10 PM
I'm trying to eliminate the chart's y axis. I can accomplish this through CSS, but then I have a margin to eliminate. I'd rather do this through the JS, but the kendo examples weren't working in Kendo Dojo so I'm not sure of the correct way to do this.

This is my HTML
<span class="w50 left">"Job Name"</span>
<span class="">
      <div id="profitChart" ></div>
</span>

This is my CSS to hide it (I commented this out to take the screen grab - see attached)
/*hides sidebar of Cost Discount Profit Bar*/
#k10000 > path:first-child, #k10000 > path:nth-child(2), #k10000 > path:nth-child(3){
    display:none !important;
}

This is my JS
// Creates the Profit bar chart on Job Info screen
function createChart() {
    $("#profitChart").kendoChart({
        chartArea: {
            height: 80,
            margin: {
                top:5,
                bottom:5
            }
        },
        //title: {
        //    text: "Job Name"
        //},
        legend: {
            visible: true,
            position: "bottom",
            labels: {
              font: "20px sans-serif",
            }
        },
        seriesDefaults: {
            type: "bar",
            stack: {
                type: "100%"
            }
        },
        series: [{
            name: "Cost",
            data: [50],
            color: "#3498db"
        },  {
            name: "Discount",
            data: [10],
            color: "#FFA500"
        }, {
            name: "Profit",
            data: [40],
            color: "#61B329"
        }],
         
        valueAxis: {
            visible: false,
            majorGridLines: {
                visible: false
            },
            minorGridLines: {
                visible: false
            }
        },
         
        categoryAxis: {
            categories: [],
            majorGridLines: {
                visible: false
            },
            minorGridLines: {
              visible: false
            },
        },
        tooltip: {
            visible: false,
            template: "#= series.name #: #= value #"
        },
        panes: [
        { height: 50 }]
    });
}
 
$(document).ready(createChart);
$(document).bind("kendo:skinChange", createChart);

1 Answer, 1 is accepted

Sort by
0
Accepted
Iliana Dyankova
Telerik team
answered on 28 Oct 2014, 02:58 PM
Hi Jon,

You can achieve the expected result as setting categoryAxis.visible option to false
$("#profitChart").kendoChart({
  //....
  categoryAxis: {
     visible: false,
     //....
  }
});

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Charts
Asked by
Hannah
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Share this question
or