久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='k6WqV'><style id='k6WqV'><dir id='k6WqV'><q id='k6WqV'></q></dir></style></legend>
  • <small id='k6WqV'></small><noframes id='k6WqV'>

    <i id='k6WqV'><tr id='k6WqV'><dt id='k6WqV'><q id='k6WqV'><span id='k6WqV'><b id='k6WqV'><form id='k6WqV'><ins id='k6WqV'></ins><ul id='k6WqV'></ul><sub id='k6WqV'></sub></form><legend id='k6WqV'></legend><bdo id='k6WqV'><pre id='k6WqV'><center id='k6WqV'></center></pre></bdo></b><th id='k6WqV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='k6WqV'><tfoot id='k6WqV'></tfoot><dl id='k6WqV'><fieldset id='k6WqV'></fieldset></dl></div>
    <tfoot id='k6WqV'></tfoot>

          <bdo id='k6WqV'></bdo><ul id='k6WqV'></ul>

        MPAndroidChart x 軸日期/時間標簽格式

        MPAndroidChart x-axis date/time label formatting(MPAndroidChart x 軸日期/時間標簽格式)
            <tbody id='AdpRs'></tbody>
        1. <i id='AdpRs'><tr id='AdpRs'><dt id='AdpRs'><q id='AdpRs'><span id='AdpRs'><b id='AdpRs'><form id='AdpRs'><ins id='AdpRs'></ins><ul id='AdpRs'></ul><sub id='AdpRs'></sub></form><legend id='AdpRs'></legend><bdo id='AdpRs'><pre id='AdpRs'><center id='AdpRs'></center></pre></bdo></b><th id='AdpRs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='AdpRs'><tfoot id='AdpRs'></tfoot><dl id='AdpRs'><fieldset id='AdpRs'></fieldset></dl></div>

          <small id='AdpRs'></small><noframes id='AdpRs'>

            <tfoot id='AdpRs'></tfoot>

                <bdo id='AdpRs'></bdo><ul id='AdpRs'></ul>
                <legend id='AdpRs'><style id='AdpRs'><dir id='AdpRs'><q id='AdpRs'></q></dir></style></legend>

                  本文介紹了MPAndroidChart x 軸日期/時間標簽格式的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  背景

                  對于我應用中的一些圖表,我使用的是 MPAndroidChart 庫.我的圖表的所有水平軸都是基于時間的,它們可以跨越一整年、一個月、一周、一天或一個小時.它總是顯示一個完整的時間段,例如 1 月至 12 月、周一至周日、0:00 - 24:00 等.軸的值始終是紀元時間戳(以秒為單位).

                  For some charts in my app, I'm using the MPAndroidChart library. All horizontal axis' of my graphs are time based, they can span a full year, a month, a week, a day or span one hour. It always shows a full period, so January-December, Monday-Sunday, 0:00 - 24:00 etc. The value of the axis is always the epoch-timestamp (in seconds).

                  要求

                  我希望 x 軸標簽遵循以下規則:

                  I want the x-axis labels to follow these rules:

                  • 月 1 日(如果是 跨度);
                  • 一天的開始,如果是跨度;
                  • 在任何整小時 (##:00)(并非全部),如果是跨度;
                  • 小時跨度的任何5分鐘點上.
                  • at 1st of month in case of year span;
                  • at start of day in case of month or week span;
                  • on any full hour (##:00) (not perse all) in case of a day span;
                  • on any 5 minute point on an hour span.

                  問題

                  我可以設置 x 軸的 granularity,這樣可以確保兩點之間的空間不小于粒度所說的,但這可能意味著(在一天跨度的情況下)第一個標簽是凌晨 1:00,第二個是凌晨 2:01,第三個是凌晨 3:16,因為這符合(最小)60 分鐘的粒度.

                  I can set the granularity of the x-axis, which makes sure there is no less space between two points then the granularity says, but that can mean that (in case of day span) the first label is at 1:00am, and the second at 2:01am and the third is at 3:16am, since that fits a granularity of (minimum) 60 minutes.

                  當前不正確的情況,最好是 [0:00, 3:00, 6:00, 9:00 ..]

                  Current incorrect situation, which would ideally be something like [0:00, 3:00, 6:00, 9:00 ..]

                  問題

                  有沒有辦法控制x軸標簽的定位來達到上面的效果?

                  Is there a way to control the positioning of the x-axis labels to achieve the results above?

                  推薦答案

                  我也做過,試試這個,

                   XAxis xAxis = mChart.getXAxis();
                      xAxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
                      xAxis.setDrawGridLines(false);
                      xAxis.setGranularity(1f); // only intervals of 1 day
                      xAxis.setTypeface(mTfLight);
                      xAxis.setTextSize(8);
                      xAxis.setTextColor(ContextCompat.getColor(this, R.color.colorYellow));
                      xAxis.setValueFormatter(new GraphXAxisValueFormatter(range, interval, slot));
                  

                  在你的情況下,在這個 range 中.如果你想要一個月,那么有 12 個,如果是第 7 周等等.

                  in this range in your case. If you want month then there is 12, in case of week 7 etc.

                  interval 中你通過了 1.

                  in interval you pass 1.

                  slot 你必須通過,識別你的數據,比如月、年、日,我為此使用了枚舉.

                  in slot you have to pass, identification of your data like month, year, day, i have use enum for this.

                  public class GraphXAxisValueFormatter implements IAxisValueFormatter {
                  
                  private static int MINUTES_INTERVAL = 5;
                  private String[] mValues;
                  private int mInterval;
                  private SensorInterval.Interval mSlot;
                  
                  public GraphXAxisValueFormatter(List<BinSensorData> range, int interval, SensorInterval.Interval slot) {
                      mValues = new String[range.size()];
                      mInterval = interval;
                      mSlot = slot;
                  
                      Calendar calendar = Calendar.getInstance();
                      for (int i = 0; i < range.size(); i++) {
                          calendar.setTimeInMillis(range.get(i).getTime());
                  
                          int unroundedMinutes = calendar.get(Calendar.MINUTE);
                          int mod = unroundedMinutes % MINUTES_INTERVAL;
                          calendar.add(Calendar.MINUTE, mod < 8 ? -mod : (MINUTES_INTERVAL - mod));
                  
                  
                          String s = "";
                  
                          if (slot.equals(SensorInterval.Interval.HOUR) || slot.equals(SensorInterval.Interval.DAY))
                              s = Util.getTimeFromTimestamp(calendar.getTimeInMillis());
                          else if (slot.equals(SensorInterval.Interval.WEEK))
                              s = Util.getDayFromTimestamp(calendar.getTimeInMillis());
                          else if (slot.equals(SensorInterval.Interval.MONTH))
                              s = Util.getMonthFromTimestamp(calendar.getTimeInMillis());
                          else if (slot.equals(SensorInterval.Interval.YEAR))
                              s = Util.getYearFromTimestamp(calendar.getTimeInMillis());
                  
                  
                          Util.setLog("Time : "+s);
                          mValues[i] = s;
                      }
                  }
                  
                  @Override
                  public String getFormattedValue(float value, AxisBase axis) {
                      Util.setLog("Value : "+ value);
                      if (value % mInterval == 0 && value >= 0) {
                          return mValues[(int) value % mValues.length];
                      } else
                          return "";
                  
                  }
                  
                  @Override
                  public int getDecimalDigits() {
                      return 0;
                  }
                  

                  參見:http://prntscr.com/dbn62x

                  這篇關于MPAndroidChart x 軸日期/時間標簽格式的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)
                  Get current location during app launch(在應用啟動期間獲取當前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)
                    <tbody id='oNKdt'></tbody>
                    <bdo id='oNKdt'></bdo><ul id='oNKdt'></ul>

                    • <tfoot id='oNKdt'></tfoot>

                      <i id='oNKdt'><tr id='oNKdt'><dt id='oNKdt'><q id='oNKdt'><span id='oNKdt'><b id='oNKdt'><form id='oNKdt'><ins id='oNKdt'></ins><ul id='oNKdt'></ul><sub id='oNKdt'></sub></form><legend id='oNKdt'></legend><bdo id='oNKdt'><pre id='oNKdt'><center id='oNKdt'></center></pre></bdo></b><th id='oNKdt'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='oNKdt'><tfoot id='oNKdt'></tfoot><dl id='oNKdt'><fieldset id='oNKdt'></fieldset></dl></div>

                      <small id='oNKdt'></small><noframes id='oNKdt'>

                        1. <legend id='oNKdt'><style id='oNKdt'><dir id='oNKdt'><q id='oNKdt'></q></dir></style></legend>
                          • 主站蜘蛛池模板: 99一区二区 | 久久夜视频| www.国产精 | 亚洲精品一区二三区不卡 | 久久国产福利 | 日本精品一区二区三区在线观看视频 | 天天操网 | 亚洲精品字幕 | 久久一级免费视频 | www.操.com| 国内精品99 | 在线视频一区二区 | 欧美精品中文字幕久久二区 | 久久88| 欧美另类视频在线 | 密色视频 | 国内精品久久精品 | 97精品一区二区 | 伊人网综合在线观看 | 日日摸夜夜添夜夜添精品视频 | 国产9久 | 日韩中文字幕av | 521av网站| 欧洲精品一区 | 国产一区二区三区在线免费观看 | 欧美一区2区三区4区公司二百 | 成人免费看黄网站在线观看 | 波多野结衣中文字幕一区二区三区 | 国产伦精品一区二区三区照片91 | 一区二区三区免费 | 亚洲欧洲日韩精品 中文字幕 | 国产成人综合亚洲欧美94在线 | 亚洲精品永久免费 | 成人精品在线视频 | 看亚洲a级一级毛片 | 亚洲精品一区中文字幕乱码 | 日韩毛片免费看 | 国产精品一区二区在线播放 | 色欧美片视频在线观看 | 亚洲精品乱码久久久久久9色 | 久久国产一区二区三区 |