esnet / react-timeseries-charts

Declarative and modular timeseries charting components for React
http://software.es.net/react-timeseries-charts
Other
861 stars 284 forks source link

Change EventMarker Label style #374

Open mtrsklnkvMM opened 5 years ago

mtrsklnkvMM commented 5 years ago

Hello.

markerLabelStyle does not seem to work at all for when the type of the EventMarker is "flag". (it works ok when it's a point)

What I am trying to do is change the color of the label, but it stays grey.

My code:

<EventMarker
                type="flag"
                axis="axis"
                event={this.state.trackerEvent}
                column="level"
                info={[{ label: "Level", value: this.state.trackerValue }]}
                infoTimeFormat="%d-%b-%y @  %H:%M %p"
                infoWidth={120}
                markerRadius={2}
                markerLabelStyle={{ fill: "black"}} >> not working
                stemStyle={{ stroke:"black" }}
                markerStyle={{ fill: "black" }}
                infoStyle={{ fill: "white", stroke:"black" }}
/>
gajus commented 5 years ago

@sartaj10 This looks like an enhancement, rather than a question. I don't see such capability being documented. I wasn't able to check time color or label value given current configuration options.

Screenshot 2019-04-02 at 16 10 29
gajus commented 5 years ago

Just in case, this is where it is hard-coded:

wtesler commented 5 years ago

I was just looking how to do this. Looks like it's not possible yet.

vladyslav-dotsenko commented 4 years ago

In case if someone needs a solution, you can pass a tag with infoTimeFormat property. Stylize it whatever you like.

e.g.

<BarChart
      style={style}
      series={series}
      columns={columns}
      info={this.state.infoValues}
      // --------- magic goes here
      infoTimeFormat={() => (<tspan style={{ fill: '#f00' }}>I AM RED</tspan>)}
/>)

Yet, that light-grey color is still hard-coded, you can inject SVG attributes all-over the places where formatting callbacks are supported.

natejenkins commented 4 years ago

You need to pass in infoStyle instead of markerInfoStyle and it should be of the following form:

<EventMarker
  type="flag"
  info={'this is my label'}
  infoWidth={100}
  infoStyle={{
    label: {
      fontWeight: 500,
      fontSize: 14,
      font: '"Goudy Bookletter 1911", sans-serif"',
      fill: 'white',
    },
    box: {
      fill: 'blue',
      stroke: 'red',
    },
  }}
  markerRadius={4}
  markerStyle={{fill: 'white'}}
/>
UsmanHaider15 commented 4 years ago

I think documentation needs to be fixed to reflect infoStyle schema http://software.es.net/react-timeseries-charts/#/api/charts/EventMarker