为Google Visualization表格图表设置选定的行css属性

时间:2016-02-23 11:22:57

标签: javascript html css google-visualization

我很难理解在使用Google Visualization API中的cssClassNames属性时如何覆盖CSS属性,我认为从文档here中可以清楚地看到它,但不知何故我无法使其工作。

我的最终目标是为所选行设置自定义背景颜色。到目前为止,我的努力是使用cssClassNames为所选行指定一个类,并在我的CSS中为文档设置它。我可以看到字体属性正常工作(字体样式,文本修饰等),但是当尝试使用background-color属性时它就不起作用了!

我的js:

$.ajax({
            type: 'POST',
            url: getContextPath()+"/cons/trackConsOrders",
            data: {}, 
            dataType: "json",
            success: function(resdata) {
                      count = Object.keys(resdata).length;
                      $("#id-dynamic-order-track").empty();



                      for(i=0;i<count;i++){

                          for(j=0;j<resdata[i].excount;j++){
                            alert(resdata[i].ex"+j+".status);
                           }
                     }

CSS:

$current_user_id = get_current_user_id();

$query = new WP_Query( array( 'author' => $current_user_id ) );

https://jsfiddle.net/6e2xw5cd/4/

我也尝试了其他可用的类,但这些似乎能够很好地实现CSS背景属性。在下面的JSFiddle中,您可以注意到oddTableRows设置与selectedTableRows相同时的行为:https://jsfiddle.net/3kecdaz0/

所以我想知道是否可以为Google Visualization Chart Table元素中的选定行设置背景属性?

2 个答案:

答案 0 :(得分:2)

我认为您应该使用background-color: beige !important;覆盖背景颜色。

.selectedTableRow {
    font-style: italic;
    color: purple;
    font-size:15px;
    text-decoration: underline;
    border: 3px solid gold;
    background-color: beige !important;
  }

<强> Fiddle

或者尝试在table.css之后添加自定义css文件。

答案 1 :(得分:1)

为了覆盖你必须添加的proeperty值!important;

更改#!C:\Python34\python.exe import datetime import pymssql import cgi import os from connection_data import NationalAverages myDB = NationalAverages() from pm_authenticate import authenticate_user_against_group #logging import logging logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) handler=logging.FileHandler('error_log.log') logger.addHandler(handler) # Connection details for the database cursor = myDB.connect_to_db() conn = myDB.conn form = cgi.FieldStorage() def right(string): return string[len(string)-1] def default_value(value): if value is None: return ' ' else: return value def left(string): return string[0:3] def save_data(form): group = form.getfirst("group", "7bg/IL4") AP = form.getfirst("AP", "AP2") academic_year = form.getfirst("year", "14/15") list_of_ids = [] # get ids of the rows on page for key in form.keys(): if ((left(key) == 'ta_' or left(key) == 'da_') and right(key).isnumeric()): if int(right(key)) in list_of_ids: continue else: list_of_ids.append(int(right(key))) else: continue cursor.execute('SELECT DISTINCT ID FROM Teacher_Actions WHERE Academic_Year = %s AND group_code = %s AND AP = %s', (academic_year, group, AP)) existing_ids = cursor.fetchall() for id in existing_ids: if id in list_of_ids: continue else: cursor.execute('DELETE FROM Teacher_Actions WHERE ID = %d AND Academic_Year = %s AND group_code = %s AND AP = %s', (id, academic_year, group, AP)) conn.commit() for id in list_of_ids: cursor.execute('SELECT * FROM Teacher_Actions WHERE ID = %d AND Academic_Year = %s AND AP= %s AND group_code =%s', (id, academic_year, AP, group)) existing_data = cursor.fetchone() if not existing_data: cursor.execute('INSERT INTO Teacher_Actions VALUES (%d, %s, %s, %s, %s, %s, %s, %s)', (id, academic_year, group, AP, form.getvalue('ta_students_' + str(id)), form.getvalue('ta_gaps_' + str(id)), form.getvalue('ta_action_when_' + str(id)), form.getvalue('ta_success_point_' + str(id)))) conn.commit() else: cursor.execute('UPDATE Teacher_Actions SET Students = %s, Gaps = %s, Action_When = %s, Success_Point = %s WHERE ID = %d AND Academic_Year = %s AND Group_Code = %s AND AP = %s', (form.getvalue('ta_students_' + str(id)), form.getvalue('ta_gaps_' + str(id)), form.getvalue('ta_action_when_' + str(id)), form.getvalue('ta_success_point_' + str(id)), id, academic_year, group, AP)) conn.commit() try: save_data(form) except: logger.exception(datetime.datetime.now()) ;到

background-color: beige