简体   繁体   English

动态字体大小和宽度的响应式图表

[英]responsive highcharts with dynamic font size and widths

Im trying to make my Pie Chart fully responsive so it can be viewed on smaller devices. 我试图使饼图完全响应,以便可以在较小的设备上查看它。 Im using the latest Highcharts version (Version 5) to draw the charts. 我使用最新的Highcharts版本(版本5)绘制图表。

I have used the below code to give the chart a maximum and minimum width so the chart doest expand or shrink too too much 我使用下面的代码为图表提供了最大和最小宽度,因此图表不会扩大或缩小得太多

JS Code JS代码

responsive: {
  rules: [{
    condition: {
      maxWidth: 500,
      minWidth: 100
    },
    chartOptions: {
      legend: {
        enabled: true
      }
    }
  }]
},

But unfortunately this doesnt seems to be working. 但不幸的是,这似乎不起作用。 The max and minimum width is not being applied to the chart. 最大和最小宽度未应用于图表。

Also how can i set the font size in the legend and chart (both percentage and the center text) dynamically (smaller) when its viewed on small screens. 当在小屏幕上查看时,如何动态(较小)设置图例和图表中的字体大小(百分比和中心文本)。 Now the font size remains the same on smaller screens which takes up lots of space and breaks the chart 现在,在较小的屏幕上,字体大小保持不变,这会占用大量空间并破坏图表

I have setuped a demo over here https://jsfiddle.net/livewirerules/6wu282fu/11/ 我已经在这里设置了一个演示https://jsfiddle.net/livewirerules/6wu282fu/11/

Any help will be appreciated 任何帮助将不胜感激

I answer this for upcoming referee 我为即将到来的裁判回答

as of Highcharts 5, you have an ability to change font size with a dynamic value with em numbers eg: 1em 从Highcharts 5开始,您可以使用带有em号的动态值来更改字体大小,例如:1em

you can see it in action here : 您可以在此处查看其运行情况:

 [http://jsfiddle.net/gh/get/jquery/1.7.2/highcharts/highcharts/tree/master/samples/highcharts/css/em/][1]

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

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