简体   繁体   English

amcharts在酒吧内显示价值

[英]amcharts showing value inside bar

I'm using amCharts, and i want to show values inside bar 我正在使用amCharts,我想在条形图中显示值

This is how it looks at the moment: 这就是它当下的样子: 图表的当前状态

and I want it to be like this: 我希望它像这样: 预期的图表状态

This is my code to display chart: 这是我显示图表的代码:

AmCharts.ready(function() {

    generateWidgetData('week');
    // SERIAL CHART
    chart = new AmCharts.AmSerialChart();
    chart.dataProvider = graphData;
    chart.categoryField = 'date';
    chart.startDuration = 1;
    chart.columnWidth = 0.60;
    chart.dataDateFormat = 'YYYY-MM-DD';
    chart.startEffect = 'easeInSine';
     chart.stackType =  'regular';
    // AXES
    // category
    var categoryAxis = chart.categoryAxis;
    categoryAxis.parseDates = true;
    categoryAxis.minPeriod = 'DD';
    categoryAxis.plotAreaBorderAlpha = 0.01;
    categoryAxis.labelRotation = 90;
    categoryAxis.axisThickness = 0;
     categoryAxis.stackType =  'regular';
    categoryAxis.gridThickness = 0;

    categoryAxis.inside = false;
    //categoryAxis.gridPosition = 'start';
    //categoryAxis.startDate = '2014-05-08';


    // value
    // in case you don't want to change default settings of value axis,
    // you don't need to create it, as one value axis is created automatically.

    // GRAPH
    var graph = new AmCharts.AmGraph();
    graph.maxColumns = 1;
    graph.valueField = 'Self-entered';
    graph.balloonText = '[[category]]: <b>[[value]]</b>';
    graph.type = 'column';
    graph.lineAlpha = 0;
    graph.labelText =  '[[value]]';     
    graph.fillAlphas = 0.8;
    graph.stackType = 'regular';                    
    chart.addGraph(graph);
    graph.cornerRadiusTop = 8;

    // CURSOR
    var chartCursor = new AmCharts.ChartCursor();
    chartCursor.cursorAlpha = 0;
    chartCursor.zoomable = false;
    chartCursor.categoryBalloonEnabled = false;
    chart.addChartCursor(chartCursor);

    chart.creditsPosition = 'top-right';

    chart.write('stepschart');
});

Thanks in advance. 提前致谢。

I fixed this so i will post answer, maybe it will help to someone 我修好了这个,所以我会发布回答,也许这对某人有帮助

its really simple all you need to do is to add 2 lines of code: 它真的很简单你需要做的就是添加两行代码:

graph.labelText = '[[value]]'; graph.labelText ='[[value]]'; // this will insert values in labels //这会在标签中插入值
graph.labelPosition = 'inside'; graph.labelPosition ='inside'; // and with this we put our label inside bar //并且我们将标签放在栏内

Hope this will help to someone who also need to do same thing 希望这对那些也需要做同样事情的人有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM